diff --git a/README.en.md b/README.en.md index 128bc19e7f12506393edf27ed5fd946821690b18..6f90868c818011fe7e2b186180a149e0fa6e2d4a 100644 --- a/README.en.md +++ b/README.en.md @@ -45,8 +45,7 @@ You can view the page effect in the Previewer of DevEco Studio or on the device. │ │ ├──Index.ets // Home page │ │ └──TableAdaptiveExtensionIndex.ets // Implementation of tables that extend and adapt based on the screen size. │ └──utils -│ ├──BreakpointType.ets // Breakpoint types -│ └──Logger.ets // Logging utility +│ └──BreakpointType.ets // Breakpoint types └──entry/src/main/resources // Resources of the app ``` diff --git a/README.md b/README.md index 9994d1dec291645b3ae9cc851fa774ab65e2b5cd..08cfc50db2bb7149d4c81970f37b703b1d368895 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,8 @@ │ │ ├──DoubleTabAdaptiveCenteringIndex.ets // 双tab自适应居中页 │ │ ├──Index.ets // 首页 │ │ └──TableAdaptiveExtensionIndex.ets // 表格自适应延伸页 -│ └──utils -│ ├──BreakpointType.ets // 断点类型 -│ └──Logger.ets // 日志 +│ └──utils +│ └──BreakpointType.ets // 断点类型 └──entry/src/main/resources // 应用资源目录 ``` diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 205d431770e7ef52aa4817f2d6495cb644996839..24f1044ae3f6e2f9ff438580a65252f7e8ff3aa3 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -25,7 +25,11 @@ export default class EntryAbility extends UIAbility { onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); AppStorage.setOrCreate('systemColorMode', this.context.config.colorMode); - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(0x0000, 'testTag', '%{public}s', 'setColorMode fail. error code: ' + err.code); + } } onDestroy(): void { @@ -37,31 +41,37 @@ export default class EntryAbility extends UIAbility { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); windowStage.getMainWindow().then((data: window.Window) => { let type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; - let avoidArea = data.getWindowAvoidArea(type); - let bottomRectHeight = avoidArea.bottomRect.height; - AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); - type = window.AvoidAreaType.TYPE_SYSTEM; - avoidArea = data.getWindowAvoidArea(type); - let topRectHeight = avoidArea.topRect.height; - AppStorage.setOrCreate('topRectHeight', topRectHeight); - this.windowObj = data; - this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width); - this.windowObj.on('windowSizeChange', (windowSize: window.Size) => { - this.updateBreakpoint(windowSize.width); - }); - }) + try { + let avoidArea = data.getWindowAvoidArea(type); + let bottomRectHeight = avoidArea.bottomRect.height; + AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); + type = window.AvoidAreaType.TYPE_SYSTEM; + avoidArea = data.getWindowAvoidArea(type); + let topRectHeight = avoidArea.topRect.height; + AppStorage.setOrCreate('topRectHeight', topRectHeight); + this.windowObj = data; + this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width); + this.windowObj.on('windowSizeChange', (windowSize: window.Size) => { + this.updateBreakpoint(windowSize.width); + }); + } catch (err) { + hilog.error(0x0000, 'testTag', '%{public}s', 'config main window fail. Cause: ' + err.message); + } + }); windowStage.loadContent('pages/Index', (err) => { if (err.code) { - hilog.error(0x0000, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err.code) ?? ''); + hilog.error(0x0000, 'testTag', '%{public}s', 'Failed to load the content. Cause: ' + err.code); return; } - let windowClass: window.Window = windowStage.getMainWindowSync(); - let isLayoutFullScreen = true; - windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { - hilog.info(0x0000, 'testTag', 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((err: BusinessError) => { - hilog.error(0x0000, 'Failed to set the window layout to full-screen mode.', JSON.stringify(err.code)); - }); + try { + let windowClass: window.Window = windowStage.getMainWindowSync(); + let isLayoutFullScreen = true; + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { + hilog.info(0x0000, 'testTag', '%{public}s', 'Succeeded in setting the window layout to full-screen mode.'); + }); + } catch (err) { + hilog.error(0x0000, 'testTag', '%{public}s', 'Failed to set the window layout to full-screen mode. ' + err.code); + } }); } @@ -78,7 +88,7 @@ export default class EntryAbility extends UIAbility { } AppStorage.setOrCreate('breakPoint', curBp); } catch (exception) { - hilog.error(0x0000, 'testTag', `UpdateBreakpoint fail, error code: ${(exception as BusinessError).code}`); + hilog.error(0x0000, 'testTag', '%{public}s', `UpdateBreakpoint fail, error code: ${(exception as BusinessError).code}`); } }