Kaynağa Gözat

hicar模式下一些参数的修改

onecold 1 yıl önce
ebeveyn
işleme
68ee6103c9

+ 20 - 17
entry/src/main/ets/pages/NewIndex.ets

@@ -83,6 +83,7 @@ struct NewIndex {
   @StorageProp('windowWidth') windowWidth: number = 0;
   @StorageProp('windowHeight') windowHeight: number = 0;
   @StorageProp('isHiCarStatus') isHiCarStatus: boolean = false;
+  @StorageProp('curDisplayIsHiCar') curDisplayIsHiCar: boolean = false;
   @State isShowUpdateDialog: boolean = false //是否显示更新日志开关
   /** 标题栏配置模型 */
   @State titleBarModel: TitleBar.Model = new TitleBar.Model()
@@ -340,23 +341,25 @@ struct NewIndex {
 
   //是不是hicar的屏幕分辨率
   isHiCar() {
-    const hiCarAspectRatios: HiCarAspectRatio[] = [
-      { ratio: 800 / 480, name: "800x480" },
-      { ratio: 762 / 752, name: "762x752" },
-      { ratio: 968 / 1280, name: "968x1280" },
-      { ratio: 1200 / 1200, name: "1200x1200" },
-      { ratio: 1280 / 720, name: "1280x720" },
-      { ratio: 1920 / 1080, name: "1920x1080" }
-    ];
-    const currentRatio: number = this.windowWidth / this.windowHeight;
-    const RATIO_TOLERANCE: number = 0.1; // 宽高比容差
-
-    for (const hiCarRatio of hiCarAspectRatios) {
-      if (Math.abs(currentRatio - hiCarRatio.ratio) <= RATIO_TOLERANCE) {
-        LogUtil.info(`HiCar detected: ${hiCarRatio.name}, actual: ${this.windowWidth}x${this.windowHeight}`);
-        return true;
-      }
-    }
+
+    return this.isHiCarStatus&&this.curDisplayIsHiCar;
+    // const hiCarAspectRatios: HiCarAspectRatio[] = [
+    //   { ratio: 800 / 480, name: "800x480" },
+    //   { ratio: 762 / 752, name: "762x752" },
+    //   { ratio: 968 / 1280, name: "968x1280" },
+    //   { ratio: 1200 / 1200, name: "1200x1200" },
+    //   { ratio: 1280 / 720, name: "1280x720" },
+    //   { ratio: 1920 / 1080, name: "1920x1080" }
+    // ];
+    // const currentRatio: number = this.windowWidth / this.windowHeight;
+    // const RATIO_TOLERANCE: number = 0.1; // 宽高比容差
+    //
+    // for (const hiCarRatio of hiCarAspectRatios) {
+    //   if (Math.abs(currentRatio - hiCarRatio.ratio) <= RATIO_TOLERANCE) {
+    //     LogUtil.info(`HiCar detected: ${hiCarRatio.name}, actual: ${this.windowWidth}x${this.windowHeight}`);
+    //     return true;
+    //   }
+    // }
 
     return false;
   }

+ 9 - 107
entry/src/main/ets/view/LocalMusic.ets

@@ -3448,11 +3448,11 @@ export struct LocalMusic {
             preview: MenuPreviewMode.IMAGE,
             previewAnimationOptions: { scale: [0.8, 1.0] },
           })
-        .bindContextMenu(this.MenuBuilder(item, index, item.filePath), ResponseType.RightClick,
-          {
-            preview: MenuPreviewMode.IMAGE,
-            previewAnimationOptions: { scale: [0.8, 1.0] },
-          })
+        // .bindContextMenu(this.MenuBuilder(item, index, item.filePath), ResponseType.RightClick,
+        //   {
+        //     preview: MenuPreviewMode.IMAGE,
+        //     previewAnimationOptions: { scale: [0.8, 1.0] },
+        //   })
         .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 0.8, y: 0.8 }).animation({ duration: 500 }),
           TransitionEffect.scale({ x: 0, y: 0 })))
         .clickEffect({ level: ClickEffectLevel.LIGHT })
@@ -3460,70 +3460,7 @@ export struct LocalMusic {
         .zIndex(this.dragItem === index ? 1 : 0)
         .translate(this.dragItem === index ? { x: this.offsetX, y: this.offsetY } : { x: 0, y: 0 })
         .hitTestBehavior(this.isDraggable(this.videoLocalList.indexOf(item)) ? HitTestMode.Default : HitTestMode.None)
-        //长按拖动代码
-        // .gesture(
-        //   GestureGroup(GestureMode.Sequence,
-        //     LongPressGesture({ repeat: true })
-        //       .onAction(() => {
-        //         this.getUIContext().animateTo({ curve: Curve.Friction, duration: 300 }, () => {
-        //           this.scaleItem = index;
-        //         })
-        //       })
-        //       .onActionEnd(() => {
-        //         this.getUIContext().animateTo({ curve: Curve.Friction, duration: 300 }, () => {
-        //           this.scaleItem = -1;
-        //         })
-        //       }),
-        //     PanGesture({ fingers: 1, direction: null, distance: 0 })
-        //       .onActionStart(() => {
-        //         this.dragItem = index;
-        //         this.dragRefOffSetX = 0;
-        //         this.dragRefOffSetY = 0;
-        //       })
-        //       .onActionUpdate((event: GestureEvent) => {
-        //         this.offsetX = event.offsetX - this.dragRefOffSetX;
-        //         this.offsetY = event.offsetY - this.dragRefOffSetY;
-        //         this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-        //           let index = this.videoLocalList.indexOf(item);
-        //           if (this.offsetY >= this.FIX_VP_Y / 2 && (this.offsetX <= 44 && this.offsetX >= -44)) {
-        //             this.down(index);
-        //           } else if (this.offsetY <= -this.FIX_VP_Y / 2 && (this.offsetX <= 44 && this.offsetX >= -44)) {
-        //             this.up(index);
-        //           } else if (this.offsetX >= this.FIX_VP_X / 2 && (this.offsetY <= 50 && this.offsetY >= -50)) {
-        //             this.right(index);
-        //           } else if (this.offsetX <= -this.FIX_VP_Y / 2 && (this.offsetY <= 50 && this.offsetY >= -50)) {
-        //             this.left(index);
-        //           }
-        //         })
-        //
-        //
-        //         // if (this.offsetY > this.FIX_VP_Y * 0.7) {
-        //         //   this.scroller.scrollToIndex(index + 10, true,ScrollAlign.CENTER);
-        //         // }
-        //
-        //
-        //       })
-        //       .onActionEnd(() => {
-        //         this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-        //           this.dragItem = -1;
-        //         })
-        //         this.getUIContext().animateTo({ curve: curves.interpolatingSpring(14, 1, 170, 17), delay: 150 }, () => {
-        //           this.scaleItem = -1;
-        //         })
-        //       })
-        //   )
-        //     .onCancel(() => {
-        //       this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-        //         this.dragItem = -1;
-        //       })
-        //       this.getUIContext().animateTo({ curve: curves.interpolatingSpring(14, 1, 170, 17), delay: 150 }, () => {
-        //         this.scaleItem = -1;
-        //       })
-        //     })
-        // )
-
-        // [End gesture_start]
-        // [EndExclude GridItem_start]
+
 
       }, (item: VideoItem) => item.filePath)
     }
@@ -3761,42 +3698,6 @@ export struct LocalMusic {
 
           }
 
-          // .bindPopup(this.longItemFilePath === item.filePath, {
-          //   builder: this.MenuBuilder(item, index, item.filePath),
-          //   placement: Placement.Top,
-          //   // autoCancel: true,
-          //   mask: { color: '#33000000' },
-          //   // popupColor: Color.Yellow,
-          //   enableArrow: false, //是否显示箭头
-          //   showInSubWindow: false,
-          //   onStateChange: (e) => {
-          //     if (!e.isVisible) {
-          //       this.longItemFilePath = ''
-          //       this.tempLyricContent = ''
-          //     }
-          //   }
-          // })
-          //
-          // .gesture(LongPressGesture()
-          //   .onAction(async () => {
-          //     //如果是专辑和艺术家的首页,不能长按
-          //     if ((this.modeType === 2 || this.modeType == 3) && !this.isCanBack) {
-          //       return
-          //     }
-          //     //如果是我的收藏 最近播放等也不能长按
-          //     if (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
-          //       item.name === LocalMusic.STR_HISTORY_MUSIC
-          //     ) {
-          //       return
-          //     }
-          //     this.longItemFilePath = item.filePath
-          //     this.tempLyricContent = await this.getLyricContent(item)
-          //     LogUtil.info('长按this.tempLyricContent = ' + this.tempLyricContent)
-          //   })
-          //   .onActionEnd((event: GestureEvent) => {
-          //
-          //   })
-          // )
           .height(this.twoFingerType == 3 ? 60 : this.twoFingerType == 2 ? 55 : 42)
           .width(this.getGridWight())
           .justifyContent(FlexAlign.Center)
@@ -6501,7 +6402,7 @@ export struct LocalMusic {
       { ratio: 1920 / 720, name: "1920x720" },
     ];
     const currentRatio: number = this.windowWidth / this.windowHeight;
-    const RATIO_TOLERANCE: number = 0.18; // 宽高比容差
+    const RATIO_TOLERANCE: number = 0.22; // 宽高比容差
     LogUtil.info('twocold isHiCarKuanBianPing currentRatio = ' + currentRatio)
 
     for (const hiCarRatio of hiCarAspectRatios) {
@@ -6528,9 +6429,10 @@ export struct LocalMusic {
     const hiCarAspectRatios: HiCarAspectRatio[] = [
       { ratio: 800 / 480, name: "800x480" },
       { ratio: 1280 / 720, name: "1280x720" },
+      { ratio: 1920 / 1080, name: "1920x1080" },
     ];
     const currentRatio: number = this.windowWidth / this.windowHeight;
-    const RATIO_TOLERANCE: number = 0.18; // 宽高比容差
+    const RATIO_TOLERANCE: number = 0.22; // 宽高比容差
     LogUtil.info('twocold isHiCarSmall currentRatio = ' + currentRatio)
 
     for (const hiCarRatio of hiCarAspectRatios) {