From 7879de3154cb01866fe7ce2e9b63dd3c91ab9bdd Mon Sep 17 00:00:00 2001 From: lon9 <815882449@qq.com> Date: Wed, 27 Aug 2025 17:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=9A=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E5=90=8C=E6=BA=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/entryability/EntryAbility.ets | 17 ++++------------- entry/src/main/ets/pages/Index.ets | 6 ++++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index a6992d8..949a08e 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -29,16 +29,11 @@ export default class EntryAbility extends UIAbility { uiContext?: UIContext; cameraUtil?: CameraUtil; windowUtil?: WindowUtil; - isFirstCreated: boolean = true; - isFirstTime: boolean = true; // [EndExclude WindowSizeChange] + isFirstTime: boolean = true; // [Start Bp2] - // [Start SelectCamera2] - // [Start SelectCamera4] onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { - // [StartExclude SelectCamera4] // [StartExclude WindowSizeChange] - // [StartExclude SelectCamera2] this.setOrientation(this.uiContext!.px2vp(windowSize.width), this.uiContext!.px2vp(windowSize.height)); // [StartExclude Bp2] AppStorage.setOrCreate('windowSize', windowSize); @@ -49,18 +44,14 @@ export default class EntryAbility extends UIAbility { let displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; AppStorage.setOrCreate('displayOrientation', displayOrientation); // [EndExclude WindowSizeChange] - // [EndExclude SelectCamera2] if (!this.isFirstTime) { this.cameraUtil!.setXComponentRect(this.windowUtil!.getWindowSize()); } else { this.isFirstTime = false; } - // [EndExclude SelectCamera4] // [EndExclude Bp2] } - // [End SelectCamera2] // [StartExclude WindowSizeChange] - // [End SelectCamera4] setOrientation(width: number, height: number): void { // When the minimum value of window width and height is greater than the md breakpoint threshold, rotation is supported. @@ -127,12 +118,12 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate('heightBp', heightBp); let displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; AppStorage.setOrCreate('displayOrientation', displayOrientation); + AppStorage.setOrCreate('isBackground', false); + // [EndExclude Bp2] // [EndExclude WindowSizeChange] // Monitor window size changes and update breakpoints. - windowStage.getMainWindowSync().on('windowSizeChange', this.onWindowSizeChange); + data.on('windowSizeChange', this.onWindowSizeChange); // [StartExclude WindowSizeChange] - AppStorage.setOrCreate('isBackground', false); - // [EndExclude Bp2] let rect: window.Rect = data.getWindowProperties().windowRect; this.setOrientation(this.uiContext.px2vp(rect.width), this.uiContext.px2vp(rect.height)); // [EndExclude WindowSizeChange] diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 5eee6ad..9867354 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -46,6 +46,7 @@ struct Index { ]; // [Start Preview2] // [Start FoldStatusChange] + // [Start SelectCamera2] onFoldStatusChange: (foldStatus: display.FoldStatus) => void = (foldStatus: display.FoldStatus) => { if (foldStatus === display.FoldStatus.FOLD_STATUS_HALF_FOLDED) { let orientation: display.Orientation = display.getDefaultDisplaySync().orientation; @@ -69,10 +70,12 @@ struct Index { return; } // [StartExclude Preview2] + // [StartExclude SelectCamera2] if (this.widthBp !== WidthBreakpoint.WIDTH_SM) { this.windowUtil.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); } // [EndExclude Preview2] + // [EndExclude SelectCamera2] // Exit the half folded status page. if (this.isHalfFolded) { this.cameraUtil.setXComponentRect(this.windowUtil.getWindowSize()); @@ -89,8 +92,10 @@ struct Index { } } } + // [StartExclude SelectCamera2] this.isHalfFolded = false; this.oldFoldStatus = foldStatus; + // [EndExclude SelectCamera2] } // [End FoldStatusChange] // [End Preview2] @@ -98,6 +103,7 @@ struct Index { aboutToAppear(): void { display.on('foldStatusChange', this.onFoldStatusChange); } + // [End SelectCamera2] // [Start SelectCamera1] onPageShow(): void { -- Gitee