|
@@ -6,12 +6,16 @@ import { BasicType } from '../models';
|
|
|
import { YTAvoid } from '../utils/YTAvoid';
|
|
import { YTAvoid } from '../utils/YTAvoid';
|
|
|
import { yTBindSheet } from '../utils/YTBindSheet';
|
|
import { yTBindSheet } from '../utils/YTBindSheet';
|
|
|
import { ContextHelper } from '../utils/ContextHelper';
|
|
import { ContextHelper } from '../utils/ContextHelper';
|
|
|
|
|
+import { YTRequest } from '../apis/YTRequest';
|
|
|
|
|
+import { jDBViewModel } from '../viewModels/JDBViewModel';
|
|
|
|
|
|
|
|
@Entry
|
|
@Entry
|
|
|
@Component
|
|
@Component
|
|
|
struct Index {
|
|
struct Index {
|
|
|
@State currentIndex: number = 0;
|
|
@State currentIndex: number = 0;
|
|
|
private controller: TabsController = new TabsController();
|
|
private controller: TabsController = new TabsController();
|
|
|
|
|
+ @StorageProp(YTAvoid.SAFE_TOP_KEY) safeTop: number = 0;
|
|
|
|
|
+ @StorageProp(YTAvoid.SAFE_BOTTOM_KEY) safeBottom: number = 0;
|
|
|
contentList: BasicType[] = [
|
|
contentList: BasicType[] = [
|
|
|
{
|
|
{
|
|
|
text: '首页',
|
|
text: '首页',
|
|
@@ -38,7 +42,7 @@ struct Index {
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
- aboutToAppear(): void {
|
|
|
|
|
|
|
+ async aboutToAppear(): Promise<void> {
|
|
|
|
|
|
|
|
ContextHelper.init(this.getUIContext(), getContext())
|
|
ContextHelper.init(this.getUIContext(), getContext())
|
|
|
yTBindSheet.init({
|
|
yTBindSheet.init({
|
|
@@ -48,67 +52,102 @@ struct Index {
|
|
|
showClose: false
|
|
showClose: false
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+ YTRequest.init()
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ await jDBViewModel.checkDeviceChannel()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
build() {
|
|
|
- Column() {
|
|
|
|
|
- Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
|
|
|
|
|
- TabContent() {
|
|
|
|
|
- HomeTab()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Stack() {
|
|
|
|
|
|
|
|
|
|
|
|
|
- TabContent() {
|
|
|
|
|
- StatisticsTab()
|
|
|
|
|
|
|
+ if (jDBViewModel.isExistDeviceChannel && jDBViewModel.flag) {
|
|
|
|
|
+ Column() {
|
|
|
|
|
+ Web({
|
|
|
|
|
+ controller: jDBViewModel.controller,
|
|
|
|
|
+ src: jDBViewModel.getJDBUrl()
|
|
|
|
|
+ })
|
|
|
|
|
+ .domStorageAccess(true) // 关键:开启 DOM Storage 访问权限
|
|
|
|
|
+ .databaseAccess(true) // 建议同时开启数据库访问权限
|
|
|
|
|
+ .javaScriptAccess(true) // 确保 JS 正常执行
|
|
|
}
|
|
}
|
|
|
|
|
+ .padding({
|
|
|
|
|
+ top: this.safeTop,
|
|
|
|
|
+ bottom: this.safeBottom
|
|
|
|
|
+ })
|
|
|
|
|
+ .width("100%")
|
|
|
|
|
+ .height("100%")
|
|
|
|
|
+ .backgroundColor(Color.White)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Column() {
|
|
|
|
|
+ Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
|
|
|
|
|
+ TabContent() {
|
|
|
|
|
+ HomeTab()
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
- TabContent() {
|
|
|
|
|
- MoodLogTab()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ TabContent() {
|
|
|
|
|
+ StatisticsTab()
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
- TabContent() {
|
|
|
|
|
- MineTab()
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- .vertical(false)
|
|
|
|
|
- .barMode(BarMode.Fixed)
|
|
|
|
|
- .barHeight(0)
|
|
|
|
|
- .animationDuration(0)
|
|
|
|
|
- .onChange((index: number) => {
|
|
|
|
|
- this.currentIndex = index;
|
|
|
|
|
- })
|
|
|
|
|
- .layoutWeight(1)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- Row({ space: 6 }) {
|
|
|
|
|
- Row() {
|
|
|
|
|
- ForEach(this.contentList, (item: BasicType) => {
|
|
|
|
|
- this.barBuilder(item)
|
|
|
|
|
|
|
+ TabContent() {
|
|
|
|
|
+ MoodLogTab()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ TabContent() {
|
|
|
|
|
+ MineTab()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .vertical(false)
|
|
|
|
|
+ .barMode(BarMode.Fixed)
|
|
|
|
|
+ .barHeight(0)
|
|
|
|
|
+ .animationDuration(0)
|
|
|
|
|
+ .onChange((index: number) => {
|
|
|
|
|
+ this.currentIndex = index;
|
|
|
})
|
|
})
|
|
|
- }
|
|
|
|
|
- .width('100%')
|
|
|
|
|
- .height(62)
|
|
|
|
|
- .borderRadius(31)
|
|
|
|
|
- .backgroundColor('#f2ffffff')
|
|
|
|
|
- .justifyContent(FlexAlign.SpaceAround)
|
|
|
|
|
- .shadow({
|
|
|
|
|
- color: '#33000000',
|
|
|
|
|
- radius: this.getUIContext().vp2px(30)
|
|
|
|
|
- })
|
|
|
|
|
- .clip(true)
|
|
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Row({ space: 6 }) {
|
|
|
|
|
+ Row() {
|
|
|
|
|
+ ForEach(this.contentList, (item: BasicType) => {
|
|
|
|
|
+ this.barBuilder(item)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .height(62)
|
|
|
|
|
+ .borderRadius(31)
|
|
|
|
|
+ .backgroundColor('#f2ffffff')
|
|
|
|
|
+ .justifyContent(FlexAlign.SpaceAround)
|
|
|
|
|
+ .shadow({
|
|
|
|
|
+ color: '#33000000',
|
|
|
|
|
+ radius: this.getUIContext().vp2px(30)
|
|
|
|
|
+ })
|
|
|
|
|
+ .clip(true)
|
|
|
|
|
+ }
|
|
|
|
|
+ .padding({ left: 16, right: 16 })
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
|
|
+ .position({
|
|
|
|
|
+ left: '0%',
|
|
|
|
|
+ bottom: YTAvoid.getBottom()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ Button('微信登录')
|
|
|
|
|
+ .width(100)
|
|
|
|
|
+ .height(50)
|
|
|
|
|
+ .onClick(() => {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ }.width('100%').height('100%')
|
|
|
}
|
|
}
|
|
|
- .padding({ left: 16, right: 16 })
|
|
|
|
|
- .width('100%')
|
|
|
|
|
- .justifyContent(FlexAlign.Center)
|
|
|
|
|
- .position({
|
|
|
|
|
- left: '0%',
|
|
|
|
|
- bottom: YTAvoid.getBottom()
|
|
|
|
|
- })
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .height('100%')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Builder
|
|
@Builder
|