diff --git a/entry/src/main/ets/constant/StackConstant.ets b/entry/src/main/ets/constant/StackConstant.ets index e64286fda6e64db051f4abcaad4444d8b69dbdf4..b4f6e5ebcdbaafc96393995b9f581de868867d20 100644 --- a/entry/src/main/ets/constant/StackConstant.ets +++ b/entry/src/main/ets/constant/StackConstant.ets @@ -54,11 +54,6 @@ export class StackConstant { */ public static readonly USED_SPACE: number = 110; - /** - * fonts setting transparency. - */ - public static readonly OPACITY: number = 0.6; - /** * Product list column margin. */ @@ -108,14 +103,4 @@ export class StackConstant { * Breakpoint sm. */ public static readonly BREAK_POINT_SM: string = 'sm'; - - /** - * Breakpoint md. - */ - public static readonly BREAK_POINT_MD: string = 'md'; - - /** - * Breakpoint lg. - */ - public static readonly BREAK_POINT_LG: string = 'lg'; } \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index d75903d62c18a748e6938a039780d07a0c8c654a..6335521e2b5845a587af32e2f172e2bbbfda7737 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -18,8 +18,9 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { display, window } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; +const TAG = '[EntryAbility]'; + export default class EntryAbility extends UIAbility { - private windowObj?: window.Window; private curBp: string = ''; private updateBreakpoint(windowWidth: number): void { @@ -38,18 +39,19 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate('currentBreakpoint', this.curBp); } } catch (error) { - hilog.error(0x0000, 'EntryAbility', 'updateBreakpoint catch err:', JSON.stringify(error) ?? ''); - } + const err = error as BusinessError; + hilog.error(0x000, TAG, `updateBreakpoint catch err: code: ${err.code}, message: ${err.message}`); + }; } onCreate(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + hilog.info(0x0000, TAG, '%{public}s', 'Ability onCreate'); AppStorage.setOrCreate('systemColorMode', this.context.config.colorMode); this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + hilog.info(0x0000, TAG, '%{public}s', 'Ability onDestroy'); } onConfigurationUpdate(newConfig: Configuration): void { @@ -63,35 +65,39 @@ export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability. - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate'); windowStage.getMainWindow().then((windowObj: window.Window) => { - this.windowObj = windowObj; - this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); - windowObj.on('windowSizeChange', (windowSize) => { - this.updateBreakpoint(windowSize.width); - }) + try { + this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); + windowObj.on('windowSizeChange', (windowSize) => { + this.updateBreakpoint(windowSize.width); + }) + } catch (error) { + const err = error as BusinessError; + hilog.error(0x000, TAG, `onWindowStageCreate catch err, code: ${err.code}, message: ${err.message}`); + } }); windowStage.loadContent('pages/Index', (err) => { if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + hilog.error(0x0000, TAG, `Failed to load the content, err code: ${err.code}, message: ${err.message}`); return; } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + hilog.info(0x0000, TAG, 'Succeeded in loading the content.'); 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.'); + hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); }).catch((err: BusinessError) => { - hilog.error(0x0000, 'testTag', - 'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + hilog.error(0x0000, TAG, + `Failed to set the window layout to full-screen mode, err code: ${err.code}, message: ${err.message}`); }); }); let windowClass: window.Window | undefined = undefined; window.getLastWindow(this.context, (err: BusinessError, data) => { if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to obtain top window. Cause:' + JSON.stringify(err)); + hilog.error(0x0000, TAG, `Failed to obtain top window, err code: ${err.code}, message: ${err.message}`); return; } windowClass = data; @@ -105,8 +111,9 @@ export default class EntryAbility extends UIAbility { let avoidArea: window.AvoidArea = windowClass.getWindowAvoidArea(type); statusHeight = avoidArea.topRect.height; bottomHeight = avoidArea.bottomRect.height - } catch (exception) { - hilog.error(0x0000, 'testTag', 'Failed to obtain the area. Cause:' + JSON.stringify(exception)); + } catch (error) { + const err = error as BusinessError; + hilog.error(0x0000, TAG, `Failed to obtain the area, err code: ${err.code}, message: ${err.message}`); } AppStorage.setOrCreate('statusHeight', statusHeight); AppStorage.setOrCreate('bottomHeight', bottomHeight); @@ -116,10 +123,11 @@ export default class EntryAbility extends UIAbility { displayClass = display.getDefaultDisplaySync(); screenHeight = displayClass.height; } catch (exception) { - hilog.error(0x0000, 'testTag', - 'Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); + const e = exception as BusinessError; + hilog.error(0x0000, TAG, + `Failed to obtain the default display object, err code: ${e.code}, message: ${e.message}`); } - hilog.info(0x0000, 'testTag', + hilog.info(0x0000, TAG, 'Succeeded to obtain the default display object. Code: ' + JSON.stringify(displayClass)); AppStorage.setOrCreate('screenHeight', screenHeight); }); @@ -127,16 +135,16 @@ export default class EntryAbility extends UIAbility { onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageDestroy'); } onForeground(): void { // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + hilog.info(0x0000, TAG, '%{public}s', 'Ability onForeground'); } onBackground(): void { // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + hilog.info(0x0000, TAG, '%{public}s', 'Ability onBackground'); } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 05d8cb4e22d2674cf451bca4d1850f9939ef8f79..aab8950597c77fdc4e7a91530401be6a74f2ea19 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -152,7 +152,6 @@ struct Index { .width(StackConstant.FULL_PERCENT) .margin({ top: $r('app.integer.margin_search_view') }) } - //.padding({ left: $r('app.integer.scroll_padding'), right: $r('app.integer.scroll_padding') }) .width(StackConstant.FULL_PERCENT) .height(StackConstant.FULL_PERCENT) .scrollBar(BarState.Off) diff --git a/entry/src/main/ets/view/ProductList.ets b/entry/src/main/ets/view/ProductList.ets index a5618692430a32b70b761c0fd9e810104c08ce36..756107dafef0170528c7ec9fa8db67346f7ac694 100644 --- a/entry/src/main/ets/view/ProductList.ets +++ b/entry/src/main/ets/view/ProductList.ets @@ -18,6 +18,8 @@ import { ProductDataModel } from '../viewmodel/IconViewModel'; import { ProductDataSource } from '../viewmodel/DataSource'; import { StackConstant } from '../constant/StackConstant'; import { PRODUCT_DATA } from '../model/IconModel'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; @Component export struct ProductList { @@ -73,7 +75,12 @@ export struct ProductList { .backgroundColor($r('sys.color.comp_background_primary')) .borderRadius($r('app.integer.water_flow_column_border_radius')) .onClick(() => { - promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); + try { + promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); + } catch (error) { + const err = error as BusinessError; + hilog.error(0x000, 'ProductList', `showToast catch error, code: ${err.code}, message: ${err.message}`); + } }); }