Showing
1 changed file
with
23 additions
and
8 deletions
| @@ -3,12 +3,12 @@ import { BreakpointConstants } from 'wdConstant'; | @@ -3,12 +3,12 @@ import { BreakpointConstants } from 'wdConstant'; | ||
| 3 | 3 | ||
| 4 | import { HWLocationUtils, WDPushNotificationManager } from 'wdHwAbility/Index'; | 4 | import { HWLocationUtils, WDPushNotificationManager } from 'wdHwAbility/Index'; |
| 5 | import { common } from '@kit.AbilityKit'; | 5 | import { common } from '@kit.AbilityKit'; |
| 6 | -import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeCheck } from 'wdKit'; | ||
| 7 | -import router from '@ohos.router'; | ||
| 8 | -import { promptAction } from '@kit.ArkUI'; | 6 | +import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeCheck, WindowModel } from 'wdKit'; |
| 7 | +import { promptAction, window } from '@kit.ArkUI'; | ||
| 9 | import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" | 8 | import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" |
| 10 | import { ProcessUtils } from 'wdRouter/Index'; | 9 | import { ProcessUtils } from 'wdRouter/Index'; |
| 11 | import { StartupManager } from '../startupmanager/StartupManager'; | 10 | import { StartupManager } from '../startupmanager/StartupManager'; |
| 11 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 12 | 12 | ||
| 13 | const TAG = 'MainPage'; | 13 | const TAG = 'MainPage'; |
| 14 | 14 | ||
| @@ -18,7 +18,8 @@ struct MainPage { | @@ -18,7 +18,8 @@ struct MainPage { | ||
| 18 | @Provide pageShow: number = -1 | 18 | @Provide pageShow: number = -1 |
| 19 | @Provide pageHide: number = -1 | 19 | @Provide pageHide: number = -1 |
| 20 | private breakpointSystem: BreakpointSystem = new BreakpointSystem() | 20 | private breakpointSystem: BreakpointSystem = new BreakpointSystem() |
| 21 | - @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS; | 21 | + @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = |
| 22 | + BreakpointConstants.BREAKPOINT_XS; | ||
| 22 | @State isPermission: boolean = false | 23 | @State isPermission: boolean = false |
| 23 | upgradeDialogController?: CustomDialogController | 24 | upgradeDialogController?: CustomDialogController |
| 24 | 25 | ||
| @@ -47,7 +48,7 @@ struct MainPage { | @@ -47,7 +48,7 @@ struct MainPage { | ||
| 47 | LogoutViewModel.clearLoginInfo() | 48 | LogoutViewModel.clearLoginInfo() |
| 48 | }) | 49 | }) |
| 49 | EmitterUtils.receiveEvent(EmitterEventId.LOCATION, () => { | 50 | EmitterUtils.receiveEvent(EmitterEventId.LOCATION, () => { |
| 50 | - this.isPermission=true | 51 | + this.isPermission = true |
| 51 | }) | 52 | }) |
| 52 | } | 53 | } |
| 53 | 54 | ||
| @@ -81,7 +82,7 @@ struct MainPage { | @@ -81,7 +82,7 @@ struct MainPage { | ||
| 81 | 82 | ||
| 82 | this.upgradeDialogController = new CustomDialogController({ | 83 | this.upgradeDialogController = new CustomDialogController({ |
| 83 | builder: UpgradeTipDialog({ | 84 | builder: UpgradeTipDialog({ |
| 84 | - tipContent:data, | 85 | + tipContent: data, |
| 85 | confirm: () => { | 86 | confirm: () => { |
| 86 | ProcessUtils.jumpExternalWebPage(data.downloadUrl); | 87 | ProcessUtils.jumpExternalWebPage(data.downloadUrl); |
| 87 | } | 88 | } |
| @@ -104,12 +105,26 @@ struct MainPage { | @@ -104,12 +105,26 @@ struct MainPage { | ||
| 104 | 105 | ||
| 105 | onBackPress() { | 106 | onBackPress() { |
| 106 | Logger.info(TAG, 'onBackPress'); | 107 | Logger.info(TAG, 'onBackPress'); |
| 108 | + try { | ||
| 109 | + // 拦截返回键,切到后台 | ||
| 110 | + const windowClass = WindowModel.shared.getWindowClass() as window.Window | ||
| 111 | + windowClass.minimize().then(() => { | ||
| 112 | + Logger.debug(TAG, 'Succeeded in minimizing the window.'); | ||
| 113 | + }).catch((err: BusinessError) => { | ||
| 114 | + Logger.error(TAG, 'Failed to minimize the window. Cause: ' + JSON.stringify(err)); | ||
| 115 | + return false | ||
| 116 | + }); | ||
| 117 | + } catch (err) { | ||
| 118 | + Logger.error(TAG, 'Failed to minimize: ' + JSON.stringify(err)); | ||
| 119 | + return false | ||
| 120 | + } | ||
| 121 | + return true | ||
| 107 | } | 122 | } |
| 108 | 123 | ||
| 109 | build() { | 124 | build() { |
| 110 | - Stack({alignContent:Alignment.Top}) { | 125 | + Stack({ alignContent: Alignment.Top }) { |
| 111 | BottomNavigationComponent() | 126 | BottomNavigationComponent() |
| 112 | - if(this.isPermission){ | 127 | + if (this.isPermission) { |
| 113 | PermissionDesComponent() | 128 | PermissionDesComponent() |
| 114 | } | 129 | } |
| 115 | } | 130 | } |
-
Please register or login to post a comment