Explorar o código

针对hicar的分辨率做了处理

onecold hai 1 ano
pai
achega
f085f4663e

+ 10 - 0
entry/src/main/ets/entryability/EntryAbility.ets

@@ -55,6 +55,11 @@ export default class EntryAbility extends UIAbility {
         // 记录尺寸变化日志
         LogUtil.info('pura onWindowSizeChange currentHeightBreakpoint= '+heightBp);
         LogUtil.info( 'pura onWindowSizeChange currentWidthBreakpoint= '+widthBp);
+        AppStorage.setOrCreate('windowWidth', windowSize.width);
+        AppStorage.setOrCreate('windowHeight', windowSize.height);
+
+        LogUtil.info('hicar onWindowSizeChange width= '+windowSize.width);
+        LogUtil.info( 'hicar onWindowSizeChange height= '+windowSize.height);
 
     };
 
@@ -208,6 +213,11 @@ export default class EntryAbility extends UIAbility {
                 LogUtil.info( 'getMainWindow currentHeightBreakpoint= '+heightBp);
                 LogUtil.info( 'getMainWindow currentWidthBreakpoint= '+widthBp);
                 data.on('windowSizeChange', this.onWindowSizeChange);
+
+                AppStorage.setOrCreate('windowWidth', data.getWindowProperties().windowRect.width);
+                AppStorage.setOrCreate('windowHeight', data.getWindowProperties().windowRect.height);
+                LogUtil.info('hicar getMainWindow width= '+data.getWindowProperties().windowRect.width);
+                LogUtil.info( 'hicar getMainWindow height= '+data.getWindowProperties().windowRect.height);
             }).catch((err: BusinessError) => {
                 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
             });

+ 26 - 1
entry/src/main/ets/view/LocalMusic.ets

@@ -193,6 +193,9 @@ export struct LocalMusic {
   private playListScroller: Scroller = new Scroller()
   @StorageProp('isLandscape') isLandscape: boolean = false;
   @StorageProp('topRectHeight') topRectHeight: number = px2vp(AppUtil.getStatusBarHeight());
+  @StorageProp('windowWidth') windowWidth: number = 0;
+  @StorageProp('windowHeight') windowHeight: number = 0;
+
   private listArea: Area = {
     width: 0,
     height: 0,
@@ -260,7 +263,7 @@ export struct LocalMusic {
   @StorageLink('currentSong') currentSong: VideoItem | undefined = undefined;
   // @StorageLink('isPlay') isPlay: boolean = false;
   @StorageLink('isShowPlay') isShowPlay: boolean = false;
-  @StorageProp('windowHeight') windowHeight: number = 0;
+
   @StorageLink('songList') songList: Array<VideoItem> = [];
   @State translateY: number = 0;
   @State isShowSheet: boolean = false;
@@ -5509,6 +5512,12 @@ export struct LocalMusic {
   isPhoneLan() {
     // LogUtil.info('twocold this.currentHeightBreakpoint = '+this.currentHeightBreakpoint)
     // LogUtil.info('twocold this.currentWidthBreakpoint = '+this.currentWidthBreakpoint)
+    LogUtil.info('hicar isPhoneLan width= '+this.windowWidth);
+    LogUtil.info( 'hicar isPhoneLan height= '+this.windowHeight);
+    if(this.isHiCar()){
+      return false
+    }
+
     if(DeviceUtil.getDeviceType() === resourceManager.DeviceType.DEVICE_TYPE_PHONE
       &&this.currentHeightBreakpoint == HeightBreakpoint.HEIGHT_SM
       &&this.currentWidthBreakpoint==WidthBreakpoint.WIDTH_MD){//如果是手机横屏,返回true
@@ -5526,6 +5535,22 @@ export struct LocalMusic {
     return false
   }
 
+  isHiCar() {
+    if(this.windowWidth==800&&this.windowHeight==480)
+      return true
+    if(this.windowWidth==762&&this.windowHeight==752)
+      return true
+    if(this.windowWidth==968&&this.windowHeight==1280)
+      return true
+    if(this.windowWidth==1200&&this.windowHeight==1200)
+      return true
+    if(this.windowWidth==1280&&this.windowHeight==72)
+      return true
+    if(this.windowWidth==1920&&this.windowHeight==1080)
+      return true
+    return false
+  }
+
   //是不是正常的手机竖屏
   isPhonePortrait() {
     LogUtil.info('twocold this.currentHeightBreakpoint = '+this.currentHeightBreakpoint)