徐勤民 5 kuukautta sitten
vanhempi
commit
f7c6e451e7

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "HarmonyOSBaseLibs"]
+	path = HarmonyOSBaseLibs
+	url = https://xuqinmin.com/xuqinmin12/HarmonyOSBaseLibs.git

+ 1 - 0
HarmonyOSBaseLibs

@@ -0,0 +1 @@
+Subproject commit c76be010962baf3e318d1cc3e76eb3128bdcc8de

+ 18 - 0
app/oh-package-lock.json5

@@ -0,0 +1,18 @@
+{
+  "meta": {
+    "stableOrder": true
+  },
+  "lockfileVersion": 3,
+  "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
+  "specifiers": {
+    "@szyx/sdk_base@../HarmonyOSBaseLibs": "@szyx/sdk_base@../HarmonyOSBaseLibs"
+  },
+  "packages": {
+    "@szyx/sdk_base@../HarmonyOSBaseLibs": {
+      "name": "@szyx/sdk_base",
+      "version": "1.0.4",
+      "resolved": "../HarmonyOSBaseLibs",
+      "registryType": "local"
+    }
+  }
+}

+ 3 - 1
app/oh-package.json5

@@ -5,6 +5,8 @@
   "main": "",
   "author": "",
   "license": "",
-  "dependencies": {}
+  "dependencies": {
+    "@szyx/sdk_base": "file:../HarmonyOSBaseLibs"
+  }
 }
 

+ 2 - 0
app/src/main/ets/appability/AppAbility.ets

@@ -1,6 +1,7 @@
 import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
 import { hilog } from '@kit.PerformanceAnalysisKit';
 import { window } from '@kit.ArkUI';
+import { GlobalContext } from '@szyx/sdk_base';
 
 export default class AppAbility extends UIAbility {
   onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
@@ -22,6 +23,7 @@ export default class AppAbility extends UIAbility {
       }
       hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
     });
+    GlobalContext.setContext(this.context)
   }
 
   onWindowStageDestroy(): void {

+ 67 - 11
app/src/main/ets/pages/Index.ets

@@ -1,20 +1,76 @@
-@Entry
+import { SZYXLocalStorageHelper, SZYXLocalStorageKeys, WindowHelper } from '@szyx/sdk_base';
+import { RouterBuilder, RouterKeys } from './RouterBuilder';
+
+@Entry(SZYXLocalStorageHelper.storage)
 @Component
 struct Index {
+  @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack()
   @State message: string = 'Hello World';
+  @State isLoading: boolean = false
+  @State isOut: boolean = false
+  @LocalStorageLink(SZYXLocalStorageKeys.HttpHandlerListLength) @Watch('loadingChange') handlerLength: number = 0
+
+  loadingChange() {
+    if (this.handlerLength > 0 && !this.isLoading && !this.isOut) {
+      this.isOut = true
+      setTimeout(() => {
+        this.isOut = false
+        if (this.handlerLength > 0) {
+          this.isLoading = true
+        }
+      }, 300)
+    } else if (this.handlerLength == 0) {
+      this.isLoading = false
+      this.isOut = false
+    }
+  }
+
+  aboutToAppear(): void {
+    WindowHelper.setWindowLayoutFullScreen(true)
+    WindowHelper.hideStatusBar()
+  }
 
   build() {
-    RelativeContainer() {
-      Text(this.message)
-        .id('HelloWorld')
-        .fontSize(50)
-        .fontWeight(FontWeight.Bold)
-        .alignRules({
-          center: { anchor: '__container__', align: VerticalAlign.Center },
-          middle: { anchor: '__container__', align: HorizontalAlign.Center }
+    Stack() {
+      Navigation(this.pageInfos) {
+        Column() {
+
+          Text(this.message)
+            .id('HelloWorld')
+            .fontSize(50)
+            .fontWeight(FontWeight.Bold)
+            .alignRules({
+              center: { anchor: '__container__', align: VerticalAlign.Center },
+              middle: { anchor: '__container__', align: HorizontalAlign.Center }
+            })
+            .onClick(() => {
+              this.pageInfos.pushPathByName(RouterKeys.Login, undefined)
+            })
+
+        }.width('100%').height('100%')
+        .linearGradient({
+          // 0点方向顺时针旋转为正向角度,线性渐变起始角度的默认值为180°
+          colors: [
+            [0xC1E7FC, 0], // 颜色断点1的颜色和比重,对应组件在180°方向上的起始位置
+            [0xffffff, 1.0],// 颜色断点2的颜色和比重,对应组件在180°方向上的终点位置
+          ]
         })
+
+      }.navDestination(RouterBuilder).hideTitleBar(true)
+
+      Column() {
+        LoadingProgress()
+          .color(Color.White)
+          .width(80).height(80)
+        Text('努力加载中..')
+          .fontSize(16)
+          .fontColor(Color.White)
+      }
+      .visibility(this.isLoading ? Visibility.Visible : Visibility.None)
+      .width('100%')
+      .height('100%')
+      .backgroundColor('#40000000')
+      .justifyContent(FlexAlign.Center)
     }
-    .height('100%')
-    .width('100%')
   }
 }

+ 13 - 0
app/src/main/ets/pages/RouterBuilder.ets

@@ -0,0 +1,13 @@
+import { LoginView } from './login/LoginView'
+
+
+export class RouterKeys {
+  public static Login = 'Login'
+}
+
+@Builder
+export function RouterBuilder(name: string, param: ESObject) {
+  if (name === RouterKeys.Login) {
+    LoginView()
+  }
+}

+ 34 - 0
app/src/main/ets/pages/login/LoginView.ets

@@ -0,0 +1,34 @@
+import { SafeView, WindowHelper } from '@szyx/sdk_base'
+
+@Component
+@Preview
+export struct LoginView {
+  @Consume('pageInfos') pageInfos: NavPathStack
+  // 手机号
+  @State phone: string | undefined = undefined
+  // 密码
+  @State pwd: string | undefined = undefined
+  // 是否勾选协议
+  @State checkAgreement: boolean = false
+  // 是不是验证码登录
+  @State isCode: boolean = true
+
+  aboutToAppear(): void {
+    WindowHelper.showStatusBar()
+  }
+
+  build() {
+    SafeView({
+      pageInfos: this.pageInfos ?? undefined
+    }) {
+      Text('登录')
+        .id('HelloWorld')
+        .fontSize(50)
+        .fontWeight(FontWeight.Bold)
+        .alignRules({
+          center: { anchor: '__container__', align: VerticalAlign.Center },
+          middle: { anchor: '__container__', align: HorizontalAlign.Center }
+        })
+    }
+  }
+}

+ 4 - 0
build-profile.json5

@@ -36,6 +36,10 @@
           ]
         }
       ]
+    },
+    {
+      "name": "basic",
+      "srcPath": "./HarmonyOSBaseLibs"
     }
   ]
 }