diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index e596ee96be20dff93f0359ad3c030063b3e4f4ef..b4aea0ff885ed3a0a4504aef8caaaeb7c2528c88 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -24,21 +24,26 @@ export default class EntryAbility extends UIAbility { private color: string = '#F5F5F5'; private updateBreakpoint(windowWidth: number): void { - let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; - let newBp: string = ''; - if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_SM) { - newBp = 'xs'; - } else if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_MD) { - newBp = 'sm' - } else if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_LG) { - newBp = 'md' - } else { - newBp = 'lg' - } - if (this.curBp !== newBp) { - this.curBp = newBp; - AppStorage.setOrCreate('currentBreakpoint', this.curBp); + try { + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let newBp: string = ''; + if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_SM) { + newBp = 'xs'; + } else if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_MD) { + newBp = 'sm'; + } else if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_LG) { + newBp = 'md'; + } else { + newBp = 'lg'; + } + if (this.curBp !== newBp) { + this.curBp = newBp; + AppStorage.setOrCreate('currentBreakpoint', this.curBp); + } + } catch (error) { + hilog.error(0x0000, 'EntryAbility', `getDefaultDisplaySync failed. code=${error.code}, message=${error.message}`); } + } onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { diff --git a/entry/src/main/ets/pages/AuthorizedDialog.ets b/entry/src/main/ets/pages/AuthorizedDialog.ets index d706e340800feec20e6768fe43dfbfb2934a545e..1b249c0be92706c193e76b2cd2c613fa1446d54d 100644 --- a/entry/src/main/ets/pages/AuthorizedDialog.ets +++ b/entry/src/main/ets/pages/AuthorizedDialog.ets @@ -13,7 +13,8 @@ * limitations under the License. */ -import { promptAction, router } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; import { NetJudge } from '../util/JudgeHasNet'; import { CommonConstants } from '../common/CommonConstants'; @@ -40,21 +41,36 @@ export struct AuthorizedDialog { loginVerification() { if (!this.inputContent || !this.password) { - this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.input_phone_number_or_password'), - duration: 2000 - }); + try { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.input_phone_number_or_password'), + duration: 2000 + }); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `showToast failed. code=${err.code}, message=${err.message}`); + } } else if (this.inputContent && this.password && !this.allowClick) { - this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.incorrect_mobile_number_format'), - duration: 2000 - }); - } else { - if (!this.isHasNetwork) { + try { this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.network_error'), + message: $r('app.string.incorrect_mobile_number_format'), duration: 2000 }); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `showToast failed. code=${err.code}, message=${err.message}`); + } + } else { + if (!this.isHasNetwork) { + try { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.network_error'), + duration: 2000 + }); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `showToast failed. code=${err.code}, message=${err.message}`); + } } else { if (!this.isChecked) { this.getUIContext().getPromptAction().openCustomDialog({ @@ -76,11 +92,15 @@ export struct AuthorizedDialog { backgroundColor: Color.White }).then((dialogId: number) => { this.customDialogComponentId = dialogId; + }).catch((error: BusinessError)=>{ + hilog.error(0x0000, 'AuthorizedDialog', `openCustomDialog failed. code=${error.code}, message=${error.message}`); }) } else { AppStorage.setOrCreate('isLogin', true); this.getUIContext().getRouter().pushUrl({ url: 'pages/Index' + }).catch((error: BusinessError) => { + hilog.error(0x0000, 'AuthorizedDialog', `pushUrl failed. code=${error.code}, message=${error.message}`); }); } } @@ -127,7 +147,12 @@ export struct AuthorizedDialog { .height($r('app.float.customDialog_bottom_row_height')) .lineHeight($r('app.float.line_height')) .onClick(() => { - this.getUIContext().getPromptAction().closeCustomDialog(this.customDialogComponentId) + try { + this.getUIContext().getPromptAction().closeCustomDialog(this.customDialogComponentId) + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `closeCustomDialog failed. code=${err.code}, message=${err.message}`); + } }) Text($r('app.string.confirm_login')) @@ -142,8 +167,15 @@ export struct AuthorizedDialog { AppStorage.setOrCreate('isLogin', true); this.getUIContext().getRouter().pushUrl({ url: 'pages/Index' + }).catch((error: BusinessError) => { + hilog.error(0x0000, 'AuthorizedDialog', `pushUrl failed. code=${error.code}, message=${error.message}`); }); - this.getUIContext().getPromptAction().closeCustomDialog(this.customDialogComponentId); + try { + this.getUIContext().getPromptAction().closeCustomDialog(this.customDialogComponentId); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `closeCustomDialog failed. code=${err.code}, message=${err.message}`); + } }) } .height($r('app.float.customDialog_bottom_row_height')) diff --git a/login/src/main/ets/loginAbility/LoginAbility.ets b/login/src/main/ets/loginAbility/LoginAbility.ets index a7320e014c5b94138ce4a98d372a8dcd1d9fed3a..955d2af083efd0319266c593d3a658983f2280fc 100644 --- a/login/src/main/ets/loginAbility/LoginAbility.ets +++ b/login/src/main/ets/loginAbility/LoginAbility.ets @@ -24,20 +24,24 @@ export default class LoginAbility extends UIAbility { private color: string = '#F5F5F5'; private updateBreakpoint(windowWidth: number): void { - let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; - let newBp: string = ''; - if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_SM) { - newBp = 'xs'; - } else if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_MD) { - newBp = 'sm'; - } else if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_LG) { - newBp = 'md'; - } else { - newBp = 'lg'; - } - if (this.curBp !== newBp) { - this.curBp = newBp; - AppStorage.setOrCreate('currentBreakpoint', this.curBp); + try { + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let newBp: string = ''; + if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_SM) { + newBp = 'xs'; + } else if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_MD) { + newBp = 'sm'; + } else if (windowWidthVp < CommonConstants.WINDOW_WIDTH_VP_LG) { + newBp = 'md'; + } else { + newBp = 'lg'; + } + if (this.curBp !== newBp) { + this.curBp = newBp; + AppStorage.setOrCreate('currentBreakpoint', this.curBp); + } + } catch (error) { + hilog.error(0x0000, 'LoginAbility', `getDefaultDisplaySync failed. code=${error.code}, message=${error.message}`); } } diff --git a/login/src/main/ets/pages/AuthorizedDialog.ets b/login/src/main/ets/pages/AuthorizedDialog.ets index 6d16c52b4ec19d7fa6f847f1ca968509be1507f0..f302ba4b93e24802795c17795a2129d605d19d26 100644 --- a/login/src/main/ets/pages/AuthorizedDialog.ets +++ b/login/src/main/ets/pages/AuthorizedDialog.ets @@ -14,7 +14,8 @@ */ import { CommonConstants } from '../common/CommonConstants'; -import { promptAction } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; import { NetJudge } from '../util/JudgeHasNet'; @Component @@ -40,21 +41,36 @@ export struct AuthorizedDialog { loginVerification() { if (!this.inputContent || !this.password) { - this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.input_phone_number_or_password'), - duration: 2000 - }); + try { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.input_phone_number_or_password'), + duration: 2000 + }); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `showToast failed. code=${err.code}, message=${err.message}`); + } } else if (this.inputContent && this.password && !this.allowClick) { - this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.incorrect_mobile_number_format'), - duration: 2000 - }); - } else { - if (!this.isHasNetwork) { + try { this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.network_error'), + message: $r('app.string.incorrect_mobile_number_format'), duration: 2000 }); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `showToast failed. code=${err.code}, message=${err.message}`); + } + } else { + if (!this.isHasNetwork) { + try { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.network_error'), + duration: 2000 + }); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `showToast failed. code=${err.code}, message=${err.message}`); + } } else { if (!this.isChecked) { this.getUIContext().getPromptAction().openCustomDialog({ @@ -76,11 +92,15 @@ export struct AuthorizedDialog { backgroundColor: Color.White }).then((dialogId: number) => { this.customDialogComponentId = dialogId; + }).catch((error: BusinessError)=>{ + hilog.error(0x0000, 'AuthorizedDialog', `openCustomDialog failed. code=${error.code}, message=${error.message}`); }) } else { AppStorage.setOrCreate('isModalLogin', true); this.getUIContext().getRouter().pushUrl({ url: 'pages/Index' + }).catch((error: BusinessError) => { + hilog.error(0x0000, 'AuthorizedDialog', `pushUrl failed. code=${error.code}, message=${error.message}`); }); } } @@ -127,7 +147,12 @@ export struct AuthorizedDialog { .height($r('app.float.customDialog_bottom_row_height')) .lineHeight($r('app.float.line_height')) .onClick(() => { - this.getUIContext().getPromptAction().closeCustomDialog(this.customDialogComponentId) + try { + this.getUIContext().getPromptAction().closeCustomDialog(this.customDialogComponentId) + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `closeCustomDialog failed. code=${err.code}, message=${err.message}`); + } }) Text($r('app.string.confirm_login')) @@ -142,8 +167,15 @@ export struct AuthorizedDialog { AppStorage.setOrCreate('isModalLogin', true); this.getUIContext().getRouter().pushUrl({ url: 'pages/Index' + }).catch((error: BusinessError) => { + hilog.error(0x0000, 'AuthorizedDialog', `pushUrl failed. code=${error.code}, message=${error.message}`); }); - this.getUIContext().getPromptAction().closeCustomDialog(this.customDialogComponentId); + try { + this.getUIContext().getPromptAction().closeCustomDialog(this.customDialogComponentId); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'AuthorizedDialog', `closeCustomDialog failed. code=${err.code}, message=${err.message}`); + } this.isLoginShowSheet = false; }) }