Browse Source

分类导航开关如果不显示,左边抽屉就显示分类导航的菜单

onecold 1 năm trước cách đây
mục cha
commit
9fbf8787a3

+ 2 - 2
AppScope/app.json5

@@ -2,8 +2,8 @@
   "app": {
     "bundleName": "com.xgplayer.ttmusic.hm",
     "vendor": "example",
-    "versionCode": 20250718,
-    "versionName": "1.4.7",
+    "versionCode": 20250721,
+    "versionName": "1.4.8",
     "icon": "$media:app_icon",
     "label": "$string:app_name",
     "multiAppMode": {

+ 2 - 2
build-profile.json5

@@ -30,11 +30,11 @@
         "material": {
           "certpath": "C:\\Users\\xjy08\\.ohos\\config\\default_com.xgplayer.ttmusic.hm4_li00v0NJ2KHEZXa_MEhSBo4Q7SMa2KHpzKM8lnBZT1Y=.cer",
           "keyAlias": "debugKey",
-          "keyPassword": "0000001BD7E2F4E219049C47BEB1C5DF12A84283327CAF6F062BF09C2DAD9BE662F2E0C6EF1B32269C0327",
+          "keyPassword": "0000001A08FD214B84C7771F6C7B29721FE92EFBF765BC89D5A5F9E476EE3FD960B46CF8E2AF0A2751D3",
           "profile": "C:\\Users\\xjy08\\.ohos\\config\\default_com.xgplayer.ttmusic.hm4_li00v0NJ2KHEZXa_MEhSBo4Q7SMa2KHpzKM8lnBZT1Y=.p7b",
           "signAlg": "SHA256withECDSA",
           "storeFile": "C:\\Users\\xjy08\\.ohos\\config\\default_com.xgplayer.ttmusic.hm4_li00v0NJ2KHEZXa_MEhSBo4Q7SMa2KHpzKM8lnBZT1Y=.p12",
-          "storePassword": "0000001B4A054D932A09F7166962992C88D0496184DEDEC08203B3BADBBC1BA9FC6C3F656C9AA5123B3F89"
+          "storePassword": "0000001AB99C2667C882F9C3DD3A427E7C96F52A436EAD6BFE209D1FEC0F300FA79CC4AD3CD910C57613"
         }
       }
     ]

+ 49 - 4
entry/src/main/ets/pages/NewIndex.ets

@@ -71,9 +71,12 @@ struct NewIndex {
   context = getContext(this);
   /** 音乐是否为零状态(预留) */
   @Provide('isMusicZero') isMusicZero: boolean = false;
+  @State isShowTitleBar: boolean = true //是否显示分类导航条
   /** 本地音乐列表,持久化存储 */
   @StorageLink('musicLocalList') musicLocalList: Array<VideoItem> = []
   @Provide isFavMusic: boolean = false
+  @StorageProp('windowWidth') windowWidth: number = 0;
+  @StorageProp('windowHeight') windowHeight: number = 0;
   /** 标题栏配置模型 */
   @State titleBarModel: TitleBar.Model = new TitleBar.Model()
     .setTitleTextStyle(FontStyle.Normal)
@@ -175,6 +178,10 @@ struct NewIndex {
    */
 
   async aboutToAppear() {
+    this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
+    if(this.isHiCar()){
+      this.isShowTitleBar = false
+    }
     Utility.enableFullScreen()
     this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
     Utility.getAppName(getContext(this)).then((appName: string) => {
@@ -210,6 +217,13 @@ struct NewIndex {
       this.refreshUserInfoState();
     });
 
+    let eventSetting: emitter.InnerEvent = { eventId: 333 }
+    // 监听广播事件(通用设置配置更新)
+    emitter.on(eventSetting, (eventData: emitter.EventData) => {
+      this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
+
+    });
+
   }
 
   /**
@@ -229,8 +243,6 @@ struct NewIndex {
         this.getLeftView()
       }
 
-      // .backgroundColor(Color.Transparent)
-
       Column() {
         Stack() {
           // 本地音乐内容区
@@ -264,7 +276,7 @@ struct NewIndex {
     }
     .showControlButton(false)
     .minContentWidth(0)
-    .sideBarWidth(this.isBigScreen() ? 300 : 270)
+    .sideBarWidth(260)
     .autoHide(true)
     .showSideBar($$this.isShowDrawer)
     .onChange((value: boolean) => {
@@ -273,6 +285,29 @@ 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 false;
+  }
+
   //是不是正常的手机竖屏
   isPhonePortrait() {
     LogUtil.info('twocold this.currentHeightBreakpoint = '+this.currentHeightBreakpoint)
@@ -482,7 +517,7 @@ struct NewIndex {
   @Builder
   getDrawerView() {
     List({ space: 0, scroller: this.scroller }) {
-      ForEach(mainViewModel.getDrawerData2(), (item: ItemData, index: number) => {
+      ForEach(this.isHiCar()||!this.isShowTitleBar?mainViewModel.getDrawerData():mainViewModel.getDrawerData2(), (item: ItemData, index: number) => {
         ListItem() {
           Button({ type: ButtonType.Capsule, stateEffect: true }) {
             Row() {
@@ -525,6 +560,7 @@ struct NewIndex {
             switch (item.id) {
               case MainViewModel.MENU_MUSIC:
                 this.mType = 0
+                this.modeType = 0
                 if (!this.isBigScreen()) {
                   this.getUIContext()?.animateTo({ duration: 555 }, () => {
                     this.isShowDrawer = false
@@ -548,18 +584,21 @@ struct NewIndex {
             //   break
               case MainViewModel.MENU_MIEDIA_KU:
                 this.modeType = 1
+                this.mType = 0
                 this.getUIContext()?.animateTo({ duration: 555 }, () => {
                   this.isShowDrawer = false
                 })
                 break
               case MainViewModel.MENU_MIEDIA_ARTIST:
                 this.modeType = 2
+                this.mType = 0
                 this.getUIContext()?.animateTo({ duration: 555 }, () => {
                   this.isShowDrawer = false
                 })
                 break
               case MainViewModel.MENU_MIEDIA_ALBUM:
                 this.modeType = 3
+                this.mType = 0
                 this.getUIContext()?.animateTo({ duration: 555 }, () => {
                   this.isShowDrawer = false
                 })
@@ -877,4 +916,10 @@ function themeColorWithAlpha(themeColor: string, alpha: number, isDarkMode: bool
   const g = parseInt(color.substring(2, 4), 16);
   const b = parseInt(color.substring(4, 6), 16);
   return `rgba(${r},${g},${b},${alpha})`;
+}
+
+// 定义接口
+interface HiCarAspectRatio {
+  ratio: number;
+  name: string;
 }

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

@@ -3399,9 +3399,10 @@ export struct LocalMusic {
     })
     .onScrollFrameBegin((offset: number) => {
       //滚动小屏幕 比如puraX外屏和手机横屏可以隐藏bottomBarHeight topBarHeight
-      if (this.isPhoneLan()) {
-        this.setBarHeightHide(offset)
-      } else if (this.currentWidthBreakpoint !== WidthBreakpoint.WIDTH_SM ||
+      // if (this.isPhoneLan()) {
+      //   this.setBarHeightHide(offset)
+      // } else
+        if (this.currentWidthBreakpoint !== WidthBreakpoint.WIDTH_SM ||
         (this.currentHeightBreakpoint !== HeightBreakpoint.HEIGHT_MD &&
           this.currentHeightBreakpoint !== HeightBreakpoint.HEIGHT_SM)) {
         if (this.isScrollHide) {
@@ -4006,9 +4007,10 @@ export struct LocalMusic {
     .onScrollFrameBegin((offset: number) => {
 
       //滚动小屏幕 比如puraX外屏和手机横屏可以隐藏bottomBarHeight topBarHeight
-      if (this.isPhoneLan()) {
-        this.setBarHeightHide(offset)
-      } else if (this.currentWidthBreakpoint !== WidthBreakpoint.WIDTH_SM ||
+      // if (this.isPhoneLan()) {
+      //   this.setBarHeightHide(offset)
+      // } else
+        if (this.currentWidthBreakpoint !== WidthBreakpoint.WIDTH_SM ||
         (this.currentHeightBreakpoint !== HeightBreakpoint.HEIGHT_MD &&
           this.currentHeightBreakpoint !== HeightBreakpoint.HEIGHT_SM)) {
         if (this.isScrollHide) {
@@ -5659,6 +5661,7 @@ export struct LocalMusic {
     return false
   }
 
+  //是不是hicar的屏幕分辨率
   isHiCar() {
     const hiCarAspectRatios: HiCarAspectRatio[] = [
       { ratio: 800 / 480, name: "800x480" },

+ 3 - 3
entry/src/main/ets/viewmodel/MainViewModel.ets

@@ -48,9 +48,9 @@ export  class  MainViewModel{
     let drawerGridData: ItemData[] = [
 
       new ItemData($r('app.string.local_music'), { type: 'symbol', value: $r('sys.symbol.music') }, MainViewModel.MENU_MUSIC, false),
-      // new ItemData($r('app.string.media_ku'), $r('app.media.hm_playlist'),MainViewModel.MENU_MIEDIA_KU,false),
-      // new ItemData($r('app.string.artist'), $r('app.media.kp_music'),MainViewModel.MENU_MIEDIA_ARTIST,false),
-      // new ItemData($r('app.string.album'), $r('app.media.llq'),MainViewModel.MENU_MIEDIA_ALBUM,false),
+      new ItemData($r('app.string.media_ku'), $r('app.media.hm_playlist'),MainViewModel.MENU_MIEDIA_KU,false),
+      new ItemData($r('app.string.artist'), $r('app.media.kp_music'),MainViewModel.MENU_MIEDIA_ARTIST,false),
+      new ItemData($r('app.string.album'), $r('app.media.llq'),MainViewModel.MENU_MIEDIA_ALBUM,false),
 
       new ItemData($r('app.string.file_scan'), { type: 'symbol', value: $r('sys.symbol.doc_text_badge_magnifyingglass') },MainViewModel.MENU_FILE_SCAN,false),
       new ItemData($r('app.string.haoping'), { type: 'symbol', value: $r('sys.symbol.flower') },MainViewModel.MENU_HAOPING,false),

+ 0 - 1
entry/src/main/module.json5

@@ -108,7 +108,6 @@
         "usedScene": {
           "abilities": [
             "EntryAbility",
-            "ShareUIAbility"
           ],
           "when": "always"
         }