Showing
5 changed files
with
253 additions
and
85 deletions
| @@ -49,9 +49,12 @@ export struct AccountAndSecurityLayout { | @@ -49,9 +49,12 @@ export struct AccountAndSecurityLayout { | ||
| 49 | 49 | ||
| 50 | confirmDialogController: CustomDialogController = new CustomDialogController({ | 50 | confirmDialogController: CustomDialogController = new CustomDialogController({ |
| 51 | builder: ConfirmLogoutDialog({ | 51 | builder: ConfirmLogoutDialog({ |
| 52 | - cancel: () => { | ||
| 53 | - | ||
| 54 | - }, | 52 | + tipShow:false, |
| 53 | + title:"确认退出登录吗?", | ||
| 54 | + leftText:"确认", | ||
| 55 | + leftTextColor:$r('app.color.color_648DF2'), | ||
| 56 | + rightText:"取消", | ||
| 57 | + cancelIsLeft:false, | ||
| 55 | confirm: () => { | 58 | confirm: () => { |
| 56 | this.logout() | 59 | this.logout() |
| 57 | } | 60 | } |
| @@ -213,17 +216,6 @@ export struct AccountAndSecurityLayout { | @@ -213,17 +216,6 @@ export struct AccountAndSecurityLayout { | ||
| 213 | Column() { | 216 | Column() { |
| 214 | Button('退出登录',{ stateEffect: true ,type: ButtonType.Normal}).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').borderRadius('8lpx').onClick(()=>{ | 217 | Button('退出登录',{ stateEffect: true ,type: ButtonType.Normal}).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').borderRadius('8lpx').onClick(()=>{ |
| 215 | this.confirmDialogController.open() | 218 | this.confirmDialogController.open() |
| 216 | - | ||
| 217 | - // AlertDialog.show({ | ||
| 218 | - // title: '🥟id : ' + "button", | ||
| 219 | - // message: '标题:' + '退出登录', | ||
| 220 | - // confirm: { | ||
| 221 | - // value: "OK", | ||
| 222 | - // action: () => { | ||
| 223 | - // | ||
| 224 | - // }, | ||
| 225 | - // } | ||
| 226 | - // }) | ||
| 227 | }) | 219 | }) |
| 228 | } | 220 | } |
| 229 | } | 221 | } |
| @@ -2,6 +2,17 @@ | @@ -2,6 +2,17 @@ | ||
| 2 | 2 | ||
| 3 | @CustomDialog | 3 | @CustomDialog |
| 4 | export struct ConfirmLogoutDialog { | 4 | export struct ConfirmLogoutDialog { |
| 5 | + @State title: string = "标题" | ||
| 6 | + @State titleShow: boolean = true | ||
| 7 | + @State tipValue: string ="提示文字" | ||
| 8 | + @State tipShow: boolean = true | ||
| 9 | + @State cancelIsLeft :boolean = true//取消是否在左边 | ||
| 10 | + @State leftText: string = "取消" | ||
| 11 | + @State rightText: string = "确认" | ||
| 12 | + @State leftTextColor: Resource = $r('app.color.color_333333') | ||
| 13 | + @State rightTextColor: Resource = $r('app.color.color_648DF2') | ||
| 14 | + | ||
| 15 | + | ||
| 5 | controller: CustomDialogController | 16 | controller: CustomDialogController |
| 6 | cancel: () => void = () => { | 17 | cancel: () => void = () => { |
| 7 | } | 18 | } |
| @@ -10,51 +21,78 @@ export struct ConfirmLogoutDialog { | @@ -10,51 +21,78 @@ export struct ConfirmLogoutDialog { | ||
| 10 | 21 | ||
| 11 | build() { | 22 | build() { |
| 12 | Column() { | 23 | Column() { |
| 13 | - Text("确认退出登录吗?") | ||
| 14 | - .fontColor("#222222") | ||
| 15 | - .fontSize(18) | 24 | + Column(){ |
| 25 | + if(this.titleShow){ | ||
| 26 | + Text(this.title) | ||
| 27 | + .fontSize("32lpx") | ||
| 28 | + .fontColor($r('app.color.color_333333')) | ||
| 29 | + .lineHeight('50lpx') | ||
| 30 | + .fontWeight(600) | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + if(this.tipShow){ | ||
| 34 | + Text(this.tipValue) | ||
| 35 | + .margin({ top:this.titleShow?"10lpx":"0lpx" }) | ||
| 36 | + .fontSize("27lpx") | ||
| 37 | + .fontWeight(400) | ||
| 38 | + .lineHeight('38lpx') | ||
| 39 | + .fontColor($r('app.color.color_999999')) | ||
| 40 | + } | ||
| 41 | + }.padding({top:"48lpx",bottom:"48lpx"}) | ||
| 42 | + .alignItems(HorizontalAlign.Center) | ||
| 43 | + | ||
| 44 | + Divider() | ||
| 16 | .width("100%") | 45 | .width("100%") |
| 17 | - .fontWeight(FontWeight.Bold) | ||
| 18 | - .textAlign(TextAlign.Center) | ||
| 19 | - .margin({ top: 20 }) | ||
| 20 | - | ||
| 21 | - Divider().color("#999999").width("100%").margin({ top: 20 }).height('1vp') | ||
| 22 | - Row() { | ||
| 23 | - Text('确认') | ||
| 24 | - .fontSize(16) | ||
| 25 | - .fontColor("#648DF2") | ||
| 26 | - .layoutWeight(1) | ||
| 27 | - .fontWeight(FontWeight.Medium) | ||
| 28 | - .textAlign(TextAlign.Center) | 46 | + .strokeWidth('1lpx') |
| 47 | + .height('1lpx') | ||
| 48 | + .color($r('app.color.color_EEEEEE')) | ||
| 49 | + | ||
| 50 | + Row(){ | ||
| 51 | + Text(this.leftText) | ||
| 52 | + .fontSize('35lpx') | ||
| 53 | + .fontWeight(400) | ||
| 54 | + .fontColor(this.leftTextColor) | ||
| 29 | .onClick(() => { | 55 | .onClick(() => { |
| 30 | - this.controller.close() | ||
| 31 | - if (this.confirm) { | ||
| 32 | - this.confirm() | 56 | + if (this.controller != undefined){ |
| 57 | + if(this.cancelIsLeft){ | ||
| 58 | + this.controller.close() | ||
| 59 | + this.cancel() | ||
| 60 | + }else{ | ||
| 61 | + this.controller.close() | ||
| 62 | + this.confirm() | ||
| 63 | + } | ||
| 33 | } | 64 | } |
| 34 | - | ||
| 35 | - }) | ||
| 36 | - .height('100%') | ||
| 37 | - // Divider().color("#999999").height('100%').width('0.5vp') | ||
| 38 | - Text('取消') | ||
| 39 | - .fontSize(16) | ||
| 40 | - .fontColor("#648DF2") | ||
| 41 | - .layoutWeight(1) | ||
| 42 | - .fontWeight(FontWeight.Medium) | 65 | + }).layoutWeight(1) |
| 43 | .textAlign(TextAlign.Center) | 66 | .textAlign(TextAlign.Center) |
| 44 | - .border({ | ||
| 45 | - width: { left: 1 }, | ||
| 46 | - color: "#999999", | ||
| 47 | - style: { left: BorderStyle.Solid } | ||
| 48 | 67 | ||
| 49 | - }) | 68 | + Divider() |
| 69 | + .width("1lpx") | ||
| 70 | + .strokeWidth('1lpx') | ||
| 71 | + .vertical(true) | ||
| 72 | + .height('92lpx') | ||
| 73 | + .color($r('app.color.color_EEEEEE')) | ||
| 74 | + | ||
| 75 | + Text(this.rightText) | ||
| 76 | + .fontSize('35lpx') | ||
| 77 | + .textAlign(TextAlign.Center) | ||
| 78 | + .fontWeight(400) | ||
| 79 | + .fontColor(this.rightTextColor) | ||
| 50 | .onClick(() => { | 80 | .onClick(() => { |
| 51 | - this.controller.close() | ||
| 52 | - if (this.cancel) { | ||
| 53 | - this.cancel() | 81 | + if (this.controller != undefined) { |
| 82 | + if(this.cancelIsLeft){ | ||
| 83 | + this.controller.close() | ||
| 84 | + this.confirm() | ||
| 85 | + }else{ | ||
| 86 | + this.controller.close() | ||
| 87 | + this.cancel() | ||
| 88 | + } | ||
| 54 | } | 89 | } |
| 55 | - }) | ||
| 56 | - .height('100%') | ||
| 57 | - }.layoutWeight(1).justifyContent(FlexAlign.Center) | ||
| 58 | - }.height(110).backgroundColor(Color.White).borderRadius(6).width('74%') | 90 | + }).layoutWeight(1) |
| 91 | + } | ||
| 92 | + .alignItems(VerticalAlign.Center) | ||
| 93 | + .height('96lpx') | ||
| 94 | + }.borderRadius(10) | ||
| 95 | + .width("518lpx") | ||
| 96 | + .backgroundColor("#FFF") | ||
| 59 | } | 97 | } |
| 60 | } | 98 | } |
| @@ -20,40 +20,15 @@ import { HostEnum, HostManager, WDHttp } from 'wdNetwork'; | @@ -20,40 +20,15 @@ import { HostEnum, HostManager, WDHttp } from 'wdNetwork'; | ||
| 20 | import { LoginModule } from 'wdLogin/src/main/ets/LoginModule'; | 20 | import { LoginModule } from 'wdLogin/src/main/ets/LoginModule'; |
| 21 | import { ConfigurationConstant } from '@kit.AbilityKit'; | 21 | import { ConfigurationConstant } from '@kit.AbilityKit'; |
| 22 | import { WDPushNotificationManager } from 'wdHwAbility/Index'; | 22 | import { WDPushNotificationManager } from 'wdHwAbility/Index'; |
| 23 | +import { StartupManager } from '../startupmanager/StartupManager'; | ||
| 23 | 24 | ||
| 24 | export default class EntryAbility extends UIAbility { | 25 | export default class EntryAbility extends UIAbility { |
| 25 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { | 26 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { |
| 26 | - UmengStats.preInit(this.context) | ||
| 27 | - SPHelper.init(this.context); | 27 | + StartupManager.sharedInstance().appOnCreate(want, launchParam, this.context) |
| 28 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); | 28 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); |
| 29 | 29 | ||
| 30 | - // mPaaS 初始化 | ||
| 31 | - MpaasUtils.initApp(this.context) | ||
| 32 | - | ||
| 33 | - registerRouter(); | ||
| 34 | - LoginModule.startup() | ||
| 35 | - NetworkManager.getInstance().init() | ||
| 36 | - WDHttp.initHttpHeader() | ||
| 37 | - const spHostUrl = SPHelper.default.getSync('hostUrl', '') as string | ||
| 38 | - if (StringUtils.isNotEmpty(spHostUrl)) { | ||
| 39 | - HostManager.changeHost(spHostUrl as HostEnum) | ||
| 40 | - } | ||
| 41 | // 还没深色模式需求,暂直接不跟随系统。 | 30 | // 还没深色模式需求,暂直接不跟随系统。 |
| 42 | this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); | 31 | this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); |
| 43 | - // 注册监听网络连接 | ||
| 44 | - EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, ((str?: string) => { | ||
| 45 | - let type: NetworkType | null = null | ||
| 46 | - if (str) { | ||
| 47 | - type = JSON.parse(str) as NetworkType | ||
| 48 | - } | ||
| 49 | - Logger.info('network connected: ' + type?.toString()) | ||
| 50 | - })) | ||
| 51 | - // 注册监听网络断开 | ||
| 52 | - EmitterUtils.receiveEvent(EmitterEventId.NETWORK_DISCONNECTED, (() => { | ||
| 53 | - Logger.info('network disconnected') | ||
| 54 | - })) | ||
| 55 | - | ||
| 56 | - WDPushNotificationManager.getInstance().onWant(want) | ||
| 57 | } | 32 | } |
| 58 | 33 | ||
| 59 | // App活着情况下,点击推送通知进入 | 34 | // App活着情况下,点击推送通知进入 |
| @@ -63,7 +38,7 @@ export default class EntryAbility extends UIAbility { | @@ -63,7 +38,7 @@ export default class EntryAbility extends UIAbility { | ||
| 63 | 38 | ||
| 64 | onDestroy(): void { | 39 | onDestroy(): void { |
| 65 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); | 40 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); |
| 66 | - NetworkManager.getInstance().release() | 41 | + StartupManager.sharedInstance().appOnDestory() |
| 67 | } | 42 | } |
| 68 | 43 | ||
| 69 | onWindowStageCreate(windowStage: window.WindowStage): void { | 44 | onWindowStageCreate(windowStage: window.WindowStage): void { |
| @@ -14,6 +14,7 @@ import LaunchDataModel from '../viewModel/LaunchDataModel' | @@ -14,6 +14,7 @@ import LaunchDataModel from '../viewModel/LaunchDataModel' | ||
| 14 | import { Logger, SPHelper, UmengStats } from 'wdKit/Index'; | 14 | import { Logger, SPHelper, UmengStats } from 'wdKit/Index'; |
| 15 | import { SpConstants } from 'wdConstant/Index'; | 15 | import { SpConstants } from 'wdConstant/Index'; |
| 16 | import { TrackingModule } from 'wdTracking/Index' | 16 | import { TrackingModule } from 'wdTracking/Index' |
| 17 | +import { StartupManager } from '../../startupmanager/StartupManager' | ||
| 17 | 18 | ||
| 18 | @Entry | 19 | @Entry |
| 19 | @Component | 20 | @Component |
| @@ -45,10 +46,9 @@ struct LaunchPage { | @@ -45,10 +46,9 @@ struct LaunchPage { | ||
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | onConfirm() { | 48 | onConfirm() { |
| 48 | - UmengStats.initAfterAgreeProtocol() | ||
| 49 | - TrackingModule.startup(getContext(this) as common.UIAbilityContext) | ||
| 50 | // Save privacy agreement status. | 49 | // Save privacy agreement status. |
| 51 | this.saveIsPrivacy(); | 50 | this.saveIsPrivacy(); |
| 51 | + StartupManager.sharedInstance().appAgreedProtocol() | ||
| 52 | //跳转引导页 | 52 | //跳转引导页 |
| 53 | this.jumpToGuidePage(); | 53 | this.jumpToGuidePage(); |
| 54 | //同意隐私协议后请求启动页相关数据 | 54 | //同意隐私协议后请求启动页相关数据 |
| @@ -98,8 +98,7 @@ struct LaunchPage { | @@ -98,8 +98,7 @@ struct LaunchPage { | ||
| 98 | // } | 98 | // } |
| 99 | } else { | 99 | } else { |
| 100 | 100 | ||
| 101 | - UmengStats.initAfterAgreeProtocol() | ||
| 102 | - TrackingModule.startup(getContext(this) as common.UIAbilityContext) | 101 | + StartupManager.sharedInstance().appAgreedProtocol() |
| 103 | 102 | ||
| 104 | //需要根据请求数据判断是否需要进入广告页,广告数据为nil则直接跳转到首页 | 103 | //需要根据请求数据判断是否需要进入广告页,广告数据为nil则直接跳转到首页 |
| 105 | //获取本地存储的启动页数据 | 104 | //获取本地存储的启动页数据 |
| 1 | +import { AbilityConstant, common, Want } from '@kit.AbilityKit' | ||
| 2 | +import { WDPushNotificationManager } from 'wdHwAbility/Index' | ||
| 3 | +import { DeviceUtil, | ||
| 4 | + EmitterEventId, | ||
| 5 | + EmitterUtils, | ||
| 6 | + Logger, | ||
| 7 | + MpaasUtils, NetworkManager, | ||
| 8 | + NetworkType, | ||
| 9 | + SPHelper, | ||
| 10 | + StringUtils, | ||
| 11 | + TingyunAPM, | ||
| 12 | + UmengStats } from 'wdKit/Index' | ||
| 13 | +import { LoginModule } from 'wdLogin/Index' | ||
| 14 | +import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index' | ||
| 15 | +import { registerRouter } from 'wdRouter/Index' | ||
| 16 | +import { TrackingModule } from 'wdTracking/Index' | ||
| 17 | +import { JSON } from '@kit.ArkTS' | ||
| 18 | + | ||
| 19 | +const TAG = "[StartupManager]" | ||
| 20 | + | ||
| 21 | +/// 启动任务管理类 | ||
| 22 | +export class StartupManager { | ||
| 23 | + | ||
| 24 | + private context?: common.UIAbilityContext | ||
| 25 | + | ||
| 26 | + private static _manger?: StartupManager | ||
| 27 | + static sharedInstance(): StartupManager { | ||
| 28 | + if (!StartupManager._manger) { | ||
| 29 | + StartupManager._manger = new StartupManager() | ||
| 30 | + } | ||
| 31 | + return StartupManager._manger | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + // App启动 | ||
| 35 | + appOnCreate(want: Want, launchParam: AbilityConstant.LaunchParam, context: common.UIAbilityContext) { | ||
| 36 | + Logger.debug(TAG, "App onCreate: " + `\nwant: ${want}\nlaunchParam: ${launchParam}`) | ||
| 37 | + this.context = context | ||
| 38 | + | ||
| 39 | + // KV存储 | ||
| 40 | + SPHelper.init(context); | ||
| 41 | + | ||
| 42 | + // 路由注册 | ||
| 43 | + registerRouter(); | ||
| 44 | + | ||
| 45 | + // 网络模块 | ||
| 46 | + NetworkManager.getInstance().init() | ||
| 47 | + | ||
| 48 | + // App环境 | ||
| 49 | + const spHostUrl = SPHelper.default.getSync('hostUrl', '') as string | ||
| 50 | + if (StringUtils.isNotEmpty(spHostUrl)) { | ||
| 51 | + HostManager.changeHost(spHostUrl as HostEnum) | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + // 友盟预初始化 | ||
| 55 | + this.preInitUmentStat() | ||
| 56 | + | ||
| 57 | + // 通知栏点击后启动 | ||
| 58 | + WDPushNotificationManager.getInstance().onWant(want) | ||
| 59 | + Logger.debug(TAG, "App onCreate: finised") | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + appOnDestory() { | ||
| 63 | + Logger.debug(TAG, "App onDestory") | ||
| 64 | + NetworkManager.getInstance().release() | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + // 同意隐私协议之后,立即执行必要初始化 | ||
| 68 | + appAgreedProtocol() { | ||
| 69 | + Logger.debug(TAG, "App 已同意隐私等协议,开始必要初始化") | ||
| 70 | + this.initCheckDeviceId() | ||
| 71 | + | ||
| 72 | + this.initMpaas() | ||
| 73 | + this.initSensorData() | ||
| 74 | + | ||
| 75 | + this.initTingyun() | ||
| 76 | + | ||
| 77 | + this.initNetwork() | ||
| 78 | + | ||
| 79 | + this.initGeTuiPush() | ||
| 80 | + | ||
| 81 | + this.initUmengStat() | ||
| 82 | + | ||
| 83 | + this.initLocation() | ||
| 84 | + | ||
| 85 | + this.initAuthLogin() | ||
| 86 | + Logger.debug(TAG, "App 必要初始化完成") | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + // 到达主页后,初始化非必须部分 | ||
| 90 | + appReachMainPage() : Promise<void> { | ||
| 91 | + return new Promise((resolve) => { | ||
| 92 | + Logger.debug(TAG, "App 进入首页,开始其他任务初始化") | ||
| 93 | + //TODO: | ||
| 94 | + | ||
| 95 | + resolve() | ||
| 96 | + }) | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + // mPaaS 初始化,检测升级用 | ||
| 100 | + private initMpaas() { | ||
| 101 | + Logger.debug(TAG, "App mPaaS初始化") | ||
| 102 | + MpaasUtils.initApp(this.context!) | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + private initTingyun() { | ||
| 106 | + // Logger.debug(TAG, "App tingyunAPM 初始化") | ||
| 107 | + // TingyunAPM.initApp(this.context!, DeviceUtil.clientId()) | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + private initSensorData() { | ||
| 111 | + Logger.debug(TAG, "App 神策埋点 初始化") | ||
| 112 | + TrackingModule.startup(this.context!) | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + private preInitUmentStat() { | ||
| 116 | + UmengStats.preInit(this.context!) | ||
| 117 | + } | ||
| 118 | + private initUmengStat() { | ||
| 119 | + Logger.debug(TAG, "App 友盟统计 初始化") | ||
| 120 | + UmengStats.initAfterAgreeProtocol() | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + private initGeTuiPush() { | ||
| 124 | + // Logger.debug(TAG, "App 初始化") | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + private initLocation() { | ||
| 128 | + // Logger.debug(TAG, "App 初始化") | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + private initNetwork() { | ||
| 132 | + Logger.debug(TAG, "App 网络 初始化") | ||
| 133 | + WDHttp.initHttpHeader() | ||
| 134 | + // 注册监听网络连接 | ||
| 135 | + EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, ((str?: string) => { | ||
| 136 | + let type: NetworkType | null = null | ||
| 137 | + if (str) { | ||
| 138 | + type = JSON.parse(str) as NetworkType | ||
| 139 | + } | ||
| 140 | + Logger.info('network connected: ' + type?.toString()) | ||
| 141 | + })) | ||
| 142 | + // 注册监听网络断开 | ||
| 143 | + EmitterUtils.receiveEvent(EmitterEventId.NETWORK_DISCONNECTED, (() => { | ||
| 144 | + Logger.info('network disconnected') | ||
| 145 | + })) | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + private initCheckDeviceId() { | ||
| 149 | + DeviceUtil.clientId() | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + private initAuthLogin() { | ||
| 153 | + Logger.debug(TAG, "App 登录模块 初始化") | ||
| 154 | + LoginModule.startup() | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + private initThirdPlatformSDK() { | ||
| 158 | + | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + private initOthers() { | ||
| 162 | + | ||
| 163 | + } | ||
| 164 | +} |
-
Please register or login to post a comment