From e05eb5034671b4cb4de02373d63199676a3c1d9b Mon Sep 17 00:00:00 2001 From: lon9 <815882449@qq.com> Date: Wed, 14 May 2025 17:23:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8C=E6=BA=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 17 +++++++++-------- entry/src/main/ets/utils/CameraUtil.ets | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 38971b3..f37da75 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -26,7 +26,8 @@ import { WindowUtil } from '../utils/WindowUtil'; struct Index { @StorageLink('widthBp') widthBp: WidthBreakpoint = WidthBreakpoint.WIDTH_SM; @StorageLink('heightBp') heightBp: HeightBreakpoint = HeightBreakpoint.HEIGHT_SM; - @StorageLink('displayOrientation') displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; + @StorageLink('displayOrientation') displayOrientation: display.Orientation = + display.getDefaultDisplaySync().orientation; @StorageLink('photoUri') photoUri: string | Resource | PixelMap = ''; @StorageLink('surfaceId') surfaceId: string = ''; @StorageLink('rotation') rotation: number = 0; @@ -66,14 +67,14 @@ struct Index { this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); } } - }; + } // [End FoldStatusChange] aboutToAppear(): void { display.on('foldStatusChange', this.onFoldStatusChange); // Apply to the user for permission to access the camera and gallery. abilityAccessCtrl.createAtManager().requestPermissionsFromUser(this.context, this.permissions).then(() => { - setTimeout(async () => { + setTimeout(() => { // After obtaining permission, load the camera preview stream and ensure it is consistent with the aspect ratio of the surface. this.cameraUtil?.setSurfaceProfile(this.xComponentController, this.getUIContext()); this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_BACK); @@ -98,7 +99,7 @@ struct Index { controller: this.xComponentController }) {} // [StartExclude CameraPage] - .onLoad(async () => { + .onLoad(() => { // [StartExclude SetSurfaceRotation] this.surfaceId = this.xComponentController.getXComponentSurfaceId(); // [EndExclude SetSurfaceRotation] @@ -220,14 +221,14 @@ struct Index { .padding({ top: this.heightBp === HeightBreakpoint.HEIGHT_MD ? 72 : 60 }) // [EndExclude CameraPage] } - .width(this.widthBp === WidthBreakpoint.WIDTH_MD ? 144 : 152 ) + .width(this.widthBp === WidthBreakpoint.WIDTH_MD ? 144 : 152) .height('100%') .justifyContent(FlexAlign.Start) .padding({ left: this.heightBp === HeightBreakpoint.HEIGHT_MD ? 24 : 32 }) .position({ x: 0, y: 0 }) .alignItems(HorizontalAlign.Start) .visibility(this.widthBp === WidthBreakpoint.WIDTH_MD || this.widthBp === WidthBreakpoint.WIDTH_LG ? - Visibility.Visible : Visibility.None) + Visibility.Visible : Visibility.None) // Shooting button for md/lg. Column() { @@ -240,7 +241,7 @@ struct Index { .justifyContent(FlexAlign.Center) .padding({ right: this.widthBp === WidthBreakpoint.WIDTH_LG && deviceInfo.productSeries === 'GRL' ? 56 : 16 }) .visibility(this.widthBp === WidthBreakpoint.WIDTH_MD || this.widthBp === WidthBreakpoint.WIDTH_LG ? - Visibility.Visible : Visibility.None) + Visibility.Visible : Visibility.None) } .height('100%') .width('100%') @@ -327,7 +328,7 @@ struct Index { .height('100%') .width('100%') .alignContent(this.widthBp === WidthBreakpoint.WIDTH_MD ? (this.isHalfFolded ? Alignment.Top : Alignment.Start) : - Alignment.Center) + Alignment.Center) // [End CameraPage] } .height('100%') diff --git a/entry/src/main/ets/utils/CameraUtil.ets b/entry/src/main/ets/utils/CameraUtil.ets index 61b439a..dc33886 100644 --- a/entry/src/main/ets/utils/CameraUtil.ets +++ b/entry/src/main/ets/utils/CameraUtil.ets @@ -225,7 +225,7 @@ export class CameraUtil { } // [End Capture] - async releaseCamera(): Promise { + releaseCamera(): void { if (this.photoSession) { this.photoSession.stop(); } @@ -243,7 +243,7 @@ export class CameraUtil { } } - async fromBack(): Promise { + fromBack(): void { let isFront: boolean | undefined = AppStorage.get('isFront'); if (isFront) { this.cameraShooting(this.surfaceId, this.currentContext!, camera.CameraPosition.CAMERA_POSITION_FRONT); -- Gitee