From 40631c2168a5c266fded29bc3b5696d7814cfff4 Mon Sep 17 00:00:00 2001 From: "1362134550@qq.com" <1362134550@qq.com> Date: Tue, 9 Sep 2025 14:33:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/oh-package-lock.json5 | 3 +- .../main/ets/entryability/EntryAbility.ets | 58 ++++++++++++------- entry/src/main/ets/pages/Index.ets | 2 + .../main/ets/view/longlist/WaterFlowView.ets | 28 +++++---- entry/src/main/ets/view/video/ExitVideo.ets | 31 +++++++--- .../ets/view/video/VideoPageComponent.ets | 39 ++++++++----- .../main/ets/view/web/WebPageComponent.ets | 20 +++++-- .../ets/viewmodel/video/AvPlayManager.ets | 6 +- 8 files changed, 127 insertions(+), 60 deletions(-) diff --git a/entry/oh-package-lock.json5 b/entry/oh-package-lock.json5 index 22f9d34..2857b55 100644 --- a/entry/oh-package-lock.json5 +++ b/entry/oh-package-lock.json5 @@ -1,6 +1,7 @@ { "meta": { - "stableOrder": true + "stableOrder": true, + "enableUnifiedLockfile": false }, "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 49b5887..fd09daa 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -35,7 +35,11 @@ export default class EntryAbility extends UIAbility { GlobalContext.getContext().setObject('currentTime', want.parameters.currentTime); } } - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (e) { + hilog.error(0x000, 'progress', `setColorMode error ${JSON.stringify(e)}`); + } if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { if (want.parameters) { this.continueRestore(want); @@ -54,7 +58,11 @@ export default class EntryAbility extends UIAbility { GlobalContext.getContext().setObject('currentTime', want.parameters.currentTime); } } - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (e) { + hilog.error(0x000, 'progress', `setColorMode error ${JSON.stringify(e)}`); + } if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { if (want.parameters) { this.continueRestore(want); @@ -86,7 +94,11 @@ export default class EntryAbility extends UIAbility { want.parameters.scrollDistance && AppStorage.setOrCreate('scrollDistance', want.parameters.scrollDistance); want.parameters.breakpoint && AppStorage.setOrCreate('continueBreakpoint', want.parameters.breakpoint); - this.context.restoreWindowStage(new LocalStorage()); + try { + this.context.restoreWindowStage(new LocalStorage()); + } catch (e) { + hilog.error(0x000, 'progress', `restoreWindowStage error ${JSON.stringify(e)}`); + } } // [End continue_restore] @@ -182,25 +194,29 @@ export default class EntryAbility extends UIAbility { if (!this.uiContext) { return } - let mainWindow: window.WindowProperties = this.mainWindowClass!.getWindowProperties(); - let windowWidth: number = mainWindow.windowRect.width; - let windowWidthVp = this.uiContext.px2vp(windowWidth); - let widthBp: string = ''; - if (windowWidthVp < 320) { - widthBp = 'xs'; - } else if (windowWidthVp >= 320 && windowWidthVp < 600) { - widthBp = 'sm'; - } else if (windowWidthVp >= 600 && windowWidthVp < 840) { - widthBp = 'md'; - } else if (windowWidthVp >= 840 && windowWidthVp < 1440) { - widthBp = 'lg'; - } else { - widthBp = 'xl'; + try { + let mainWindow: window.WindowProperties = this.mainWindowClass!.getWindowProperties(); + let windowWidth: number = mainWindow.windowRect.width; + let windowWidthVp = this.uiContext.px2vp(windowWidth); + let widthBp: string = ''; + if (windowWidthVp < 320) { + widthBp = 'xs'; + } else if (windowWidthVp >= 320 && windowWidthVp < 600) { + widthBp = 'sm'; + } else if (windowWidthVp >= 600 && windowWidthVp < 840) { + widthBp = 'md'; + } else if (windowWidthVp >= 840 && windowWidthVp < 1440) { + widthBp = 'lg'; + } else { + widthBp = 'xl'; + } + AppStorage.setOrCreate(BreakpointConstants.BREAKPOINT_NAME, widthBp); + AppStorage.setOrCreate('windowWidth', windowWidth); + let windowHeight: number = mainWindow.windowRect.height; + AppStorage.setOrCreate('windowHeight', windowHeight); + } catch (e) { + hilog.error(0x000, 'progress', `getWindowProperties error ${JSON.stringify(e)}`); } - AppStorage.setOrCreate(BreakpointConstants.BREAKPOINT_NAME, widthBp); - AppStorage.setOrCreate('windowWidth', windowWidth); - let windowHeight: number = mainWindow.windowRect.height; - AppStorage.setOrCreate('windowHeight', windowHeight); } onWindowStageDestroy(): void { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 1889698..1b759dd 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -42,6 +42,8 @@ struct Index { let bottomHeight = bottomArea.bottomRect.height; let vpBottomHeight = this.getUIContext().px2vp(bottomHeight); AppStorage.setOrCreate('bottomHeight', vpBottomHeight); + }).catch((error: BusinessError) => { + hilog.error(0x000, 'progress', `getLastWindow error ${JSON.stringify(error)}`); }); let envCallback: EnvironmentCallback = { onConfigurationUpdated(config) { diff --git a/entry/src/main/ets/view/longlist/WaterFlowView.ets b/entry/src/main/ets/view/longlist/WaterFlowView.ets index de3fe6c..ef9b605 100644 --- a/entry/src/main/ets/view/longlist/WaterFlowView.ets +++ b/entry/src/main/ets/view/longlist/WaterFlowView.ets @@ -84,15 +84,19 @@ export struct WaterFlowView { } updateWaterFlowItemWidth() { - let windowWidth: number = this.getUIContext().px2vp(display.getDefaultDisplaySync().width); - let columns = windowWidth > CommonConstants.CRITICAL_VALUE ? CommonConstants.WATER_FLOW_THREE_COLUMNS : - CommonConstants.WATER_FLOW_TWO_COLUMNS; - let marginLeft = windowWidth > CommonConstants.CRITICAL_VALUE ? - BreakpointConstants.SEARCHBAR_AND_WATER_FLOW_MARGIN_LEFT_MD : - BreakpointConstants.SEARCHBAR_AND_WATER_FLOW_MARGIN_LEFT_SM; - this.waterFlowItemWidth = - (this.getUIContext().px2vp(display.getDefaultDisplaySync().width) - marginLeft * 2 - - (columns - 1) * CommonConstants.WATER_FLOW_COLUMN_GAP) / columns; + try { + let windowWidth: number = this.getUIContext().px2vp(display.getDefaultDisplaySync().width); + let columns = windowWidth > CommonConstants.CRITICAL_VALUE ? CommonConstants.WATER_FLOW_THREE_COLUMNS : + CommonConstants.WATER_FLOW_TWO_COLUMNS; + let marginLeft = windowWidth > CommonConstants.CRITICAL_VALUE ? + BreakpointConstants.SEARCHBAR_AND_WATER_FLOW_MARGIN_LEFT_MD : + BreakpointConstants.SEARCHBAR_AND_WATER_FLOW_MARGIN_LEFT_SM; + this.waterFlowItemWidth = + (this.getUIContext().px2vp(display.getDefaultDisplaySync().width) - marginLeft * 2 - + (columns - 1) * CommonConstants.WATER_FLOW_COLUMN_GAP) / columns; + } catch (e) { + hilog.error(0x000, 'progress', `updateWaterFlowItemWidth error ${JSON.stringify(e)}`); + } } getTitleHeight(title: string) { @@ -113,7 +117,11 @@ export struct WaterFlowView { this.scroller.scrollTo({ xOffset: 0, yOffset: 0 }); this.waterFlowScroller.scrollToIndex(0); }; - display.on('foldDisplayModeChange', callback); + try { + display.on('foldDisplayModeChange', callback); + } catch (e) { + hilog.error(0x000, 'progress', `display.on error ${JSON.stringify(e)}`); + } } build() { diff --git a/entry/src/main/ets/view/video/ExitVideo.ets b/entry/src/main/ets/view/video/ExitVideo.ets index d8cc668..199c779 100644 --- a/entry/src/main/ets/view/video/ExitVideo.ets +++ b/entry/src/main/ets/view/video/ExitVideo.ets @@ -29,18 +29,27 @@ export struct ExitVideo { private videoList: Resource[] = [$r('app.string.video_res_1'), $r('app.string.video_res_2')]; async isInternet(): Promise { - if (connection.getAllNetsSync().length <= 0) { - this.toast(); + try { + if (connection.getAllNetsSync().length <= 0) { + this.toast(); + return false; + } + } catch (e) { + hilog.error(0x000, 'progress', `getAllNetsSync error ${JSON.stringify(e)}`); return false; } return true; } async toast() { - this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.video_warn'), - duration: 2000, - }); + try { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.video_warn'), + duration: 2000, + }); + } catch (e) { + hilog.error(0x000, 'progress', `showToast error ${JSON.stringify(e)}`); + } } @Builder @@ -103,9 +112,13 @@ export struct ExitVideo { AppStorage.setOrCreate('speedIndex', 0); AppStorage.setOrCreate('currentTime', 0); this.show = false; - let str: string = await (GlobalContext.getContext().getObject('context') as (common.UIAbilityContext)) - .resourceManager.getStringValue(this.videoList[this.videoSelect]); - this.avPlayManage.videoChoose(str); + try { + let str: string = await (GlobalContext.getContext().getObject('context') as (common.UIAbilityContext)) + .resourceManager.getStringValue(this.videoList[this.videoSelect].id); + this.avPlayManage.videoChoose(str); + } catch (e) { + hilog.error(0x000, 'progress', `getStringValue error ${JSON.stringify(e)}`); + } }) }, (index: number) => JSON.stringify(index)) } diff --git a/entry/src/main/ets/view/video/VideoPageComponent.ets b/entry/src/main/ets/view/video/VideoPageComponent.ets index af7d40e..3c97869 100644 --- a/entry/src/main/ets/view/video/VideoPageComponent.ets +++ b/entry/src/main/ets/view/video/VideoPageComponent.ets @@ -107,12 +107,16 @@ struct VideoPageComponent { } aboutToAppear() { - this.windowWidth = display.getDefaultDisplaySync().width; - this.windowHeight = display.getDefaultDisplaySync().height; - this.surfaceW = (GlobalContext.getContext().getObject('windowWidth') as number) * SURFACEW; - this.surfaceH = this.surfaceW / SURFACEH; - this.flag = true; - AppStorage.setOrCreate('avPlayManage', this.avPlayManage); + try { + this.windowWidth = display.getDefaultDisplaySync().width; + this.windowHeight = display.getDefaultDisplaySync().height; + this.surfaceW = (GlobalContext.getContext().getObject('windowWidth') as number) * SURFACEW; + this.surfaceH = this.surfaceW / SURFACEH; + this.flag = true; + AppStorage.setOrCreate('avPlayManage', this.avPlayManage); + } catch (e) { + hilog.error(0x000, 'progress', `getDefaultDisplaySync error ${JSON.stringify(e)}`); + } } aboutToDisappear() { @@ -131,18 +135,27 @@ struct VideoPageComponent { } async isInternet(): Promise { - if (connection.getAllNetsSync().length <= 0) { - this.toast(); - return false + try { + if (connection.getAllNetsSync().length <= 0) { + this.toast(); + return false; + } + } catch (e) { + hilog.error(0x000, 'progress', `getAllNetsSync error ${JSON.stringify(e)}`); + return false; } return true; } async toast() { - this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.video_warn'), - duration: 2000, - }); + try { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.video_warn'), + duration: 2000, + }); + } catch (e) { + hilog.error(0x000, 'progress', `showToast error ${JSON.stringify(e)}`); + } } @Builder diff --git a/entry/src/main/ets/view/web/WebPageComponent.ets b/entry/src/main/ets/view/web/WebPageComponent.ets index 4a9df56..6192355 100644 --- a/entry/src/main/ets/view/web/WebPageComponent.ets +++ b/entry/src/main/ets/view/web/WebPageComponent.ets @@ -51,9 +51,13 @@ struct WebPageComponent { }; watchPageUrl() { - if (this.continueRestore) { - this.controller.loadUrl(this.pageUrl); - this.continueRestore = false; + try { + if (this.continueRestore) { + this.controller.loadUrl(this.pageUrl); + this.continueRestore = false; + } + } catch (e) { + hilog.error(0x000, 'progress', `loadUrl error ${JSON.stringify(e)}`); } } @@ -61,6 +65,8 @@ struct WebPageComponent { this.getUIContext().getRouter().pushUrl({ url: 'pages/OrderConfirmPage', params: { statusBarHeight: this.statusBarHeight, sliderBarHeight: this.sliderBarHeight, detailStr } + }).catch((error: BusinessError) => { + hilog.error(0x000, 'progress', `pushUrl error ${JSON.stringify(error)}`); }); } @@ -70,13 +76,17 @@ struct WebPageComponent { md: 'javascript:document.getElementById("productList").style["column-count"] = 2', lg: 'javascript:document.getElementById("productList").style["column-count"] = 3' }).getValue(this.currentBreakpoint); - this.controller.runJavaScript(column); + this.controller.runJavaScript(column).catch((error: BusinessError) => { + hilog.error(0x000, 'progress', `runJavaScript error ${JSON.stringify(error)}`); + }); let columnGap = new BreakpointType({ sm: 'javascript:document.getElementById("productList").style["column-gap"] = 0px', md: 'javascript:document.getElementById("productList").style["column-gap"] = 20px', lg: 'javascript:document.getElementById("productList").style["column-gap"] = 40px' }).getValue(this.currentBreakpoint); - this.controller.runJavaScript(columnGap); + this.controller.runJavaScript(columnGap).catch((error: BusinessError) => { + hilog.error(0x000, 'progress', `runJavaScript error ${JSON.stringify(error)}`); + }); } build() { diff --git a/entry/src/main/ets/viewmodel/video/AvPlayManager.ets b/entry/src/main/ets/viewmodel/video/AvPlayManager.ets index ba8b74a..ef4b54c 100644 --- a/entry/src/main/ets/viewmodel/video/AvPlayManager.ets +++ b/entry/src/main/ets/viewmodel/video/AvPlayManager.ets @@ -277,7 +277,11 @@ export default class AvPlayManage { if (this.avPlayer === null) { return; } - this.avPlayer.reset(); + try { + this.avPlayer.reset(); + } catch (e) { + hilog.error(0x000, 'progress', `reset error ${JSON.stringify(e)}`); + } } async videoRelease(): Promise { -- Gitee From 6977cec99a2863df4569c1c17c068ae142a206e1 Mon Sep 17 00:00:00 2001 From: "1362134550@qq.com" <1362134550@qq.com> Date: Tue, 9 Sep 2025 15:30:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 1 + 1 file changed, 1 insertion(+) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 1b759dd..63189da 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -14,6 +14,7 @@ */ import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; import { EnvironmentCallback } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { i18n } from '@kit.LocalizationKit'; -- Gitee From f59d1f9b1d325edd080834c50d2735091fa790c8 Mon Sep 17 00:00:00 2001 From: "1362134550@qq.com" <1362134550@qq.com> Date: Tue, 9 Sep 2025 15:35:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/view/video/ExitVideo.ets | 1 + 1 file changed, 1 insertion(+) diff --git a/entry/src/main/ets/view/video/ExitVideo.ets b/entry/src/main/ets/view/video/ExitVideo.ets index 199c779..3bcb19a 100644 --- a/entry/src/main/ets/view/video/ExitVideo.ets +++ b/entry/src/main/ets/view/video/ExitVideo.ets @@ -16,6 +16,7 @@ import { common, Want } from '@kit.AbilityKit'; import { connection } from '@kit.NetworkKit'; import { promptAction } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; import avPlayManage from '../../viewmodel/video/AvPlayManager'; import { GlobalContext } from '../../utils/GlobalContext'; -- Gitee From eb9cab2603941cf3f111b71175622a2413b80700 Mon Sep 17 00:00:00 2001 From: "1362134550@qq.com" <1362134550@qq.com> Date: Tue, 9 Sep 2025 15:38:40 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/oh-package-lock.json5 | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 entry/oh-package-lock.json5 diff --git a/entry/oh-package-lock.json5 b/entry/oh-package-lock.json5 deleted file mode 100644 index 2857b55..0000000 --- a/entry/oh-package-lock.json5 +++ /dev/null @@ -1,10 +0,0 @@ -{ - "meta": { - "stableOrder": true, - "enableUnifiedLockfile": false - }, - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": {}, - "packages": {} -} \ No newline at end of file -- Gitee