Просмотр исходного кода

设置增加首页默认什么页面功能

onecold 7 месяцев назад
Родитель
Сommit
eedd1809f4

+ 1 - 1
entry/src/main/ets/common/constants/CommonConstants.ets

@@ -98,7 +98,7 @@ export class CommonConstants {
 
   static readonly TWO_FINGER_TYPE = ["小", "中", "大"]
   static readonly DEFAULT_LAYOUT = [ "瀑布流模式","列表模式","网格模式"]
-
+  static readonly DEFAULT_HOME_TYPE = [ "本地音乐","媒体库","网盘" ,"艺术家","专辑"]
 
   //德本的接口调用微信支付下单接口返回的支付交易会话ID,该值有效期为2小时。
   static readonly WX_PAY_API: string = "https://pay.ss5.xyz/wechat/prepay"

+ 28 - 30
entry/src/main/ets/pages/NewIndex.ets

@@ -70,6 +70,7 @@ const TAG = 'NewIndex'; // 日志标签
 @Entry
 @Component
 struct NewIndex {
+  @State defalut_home_type:number = 0//首页默认类型 可支持首页 媒体库 歌单 网盘
   @State isDetailView: boolean = false; // 是否在艺术家/专辑详情视图
   @Provide isShowPlay: boolean = false;
   @Provide CONTROL_PlayStatus: number = PlayStatus.INIT;
@@ -117,36 +118,11 @@ struct NewIndex {
   @StorageProp('windowHeight') windowHeight: number = 0;
   @StorageProp('isHiCarStatus') isHiCarStatus: boolean = false;
   @StorageProp('curDisplayIsHiCar') curDisplayIsHiCar: boolean = false;
-  @State idDefaultMediaKu: boolean = false
   /**
    * 是否显示更新日志开关
    */
   @State isShowUpdateDialog: boolean = false
-  /** 标题栏配置模型 */
-  @State titleBarModel: TitleBar.Model = new TitleBar.Model()
-    .setTitleTextStyle(FontStyle.Normal)
-    .setTitleBarStyle(TitleBar.BarStyle.TRANSPARENT)
-    .setLeftIcon($r('app.media.menu'))
-    .setLeftIconWidth(28)
-    .setLeftIconHeight(28)
-    .setTitleBarMinHeight(64)
-    .setTitleName('首页')// .setRightIcon($r('app.media.add'))
-    .setTitleFontSize(19)
-    .setTitleFontColor(Color.White)
-    .setTitleBarBackground($r('app.color.title_bar_bg'))
-    .setLeftTitleBackground($r('app.color.title_bar_bg'))
-    .setOnLeftClickListener(() => {
-      // 打开菜单栏动画
-      this.getUIContext()?.animateTo({ duration: 555 }, () => {
-        this.isShowDrawer = true
-        this.offsetX = 0
-      })
-    })
-    .setRightTitleBackground($r('app.color.title_bar_bg'))
-  // .setOnRightClickListener(()=>{
-  //   // this.goSelectVideo()
-  //   this.showSheelDialog()
-  // })
+
 
   /** 应用版本号 */
   @State versionName: string = ''
@@ -276,12 +252,34 @@ struct NewIndex {
    */
 
   async aboutToAppear() {
+    this.defalut_home_type = PreferencesUtil.getNumberSync('defalut_home_type', 0)
     this.isShowPrecious = PreferencesUtil.getBooleanSync('isShowPrecious', false)
     ReqPermissionUtil.reqPermissionsFromUser(ReqPermissionUtil.permissions, this.context);
     this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, false)
-    this.idDefaultMediaKu = PreferencesUtil.getBooleanSync('idDefaultMediaKu', false)
-    if(this.idDefaultMediaKu){
+    if(this.defalut_home_type==0){
+      this.mType = 0
+    }else if(this.defalut_home_type==1){
+      this.mType = 0
       this.modeType = 1
+    }else if(this.defalut_home_type==2){
+      if(this.webDavAccounts.length>0){
+       if(this.webDavAccounts[0].webType===RemoteDriveType.Navidrome||
+         this.webDavAccounts[0].webType===RemoteDriveType.Jellyfin||
+         this.webDavAccounts[0].webType===RemoteDriveType.Emby){
+         this.mType = 7
+       }else{
+         this.mType = 6
+       }
+      }else{
+        this.mType = 6
+      }
+      this.tabSelectedIndexes[0]=2
+    }else if(this.defalut_home_type==3){
+      this.mType = 0
+      this.modeType = 2
+    }else if(this.defalut_home_type==4){
+      this.mType = 0
+      this.modeType = 3
     }
     Utility.enableFullScreen()
     this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
@@ -1612,14 +1610,14 @@ struct NewIndex {
           this.showRemoteDriveAccountDialog(false,undefined,RemoteDriveType.Navidrome)
         })
       MenuItem({
-        startIcon: $r('app.media.cloudDisk'),
+        startIcon: $r('app.media.jellyfin'),
         content: 'Jellyfin'
       })
         .onClick(async () => {
           this.showRemoteDriveAccountDialog(false, undefined, RemoteDriveType.Jellyfin)
         })
       MenuItem({
-        startIcon: $r('app.media.cloudDisk'),
+        startIcon: $r('app.media.emby'),
         content: $r('app.string.emby')
       })
         .onClick(async () => {

+ 25 - 15
entry/src/main/ets/pages/SettingPage.ets

@@ -99,7 +99,7 @@ export struct SettingPage {
   static readonly IS_AUTO_HIDE_PROGRESS: string = 'IS_AUTO_HIDE_PROGRESS';
   public static OPEN_SKIPSONG_ANIMATE: string = 'openSkipSongAnimate';
   @State autoParseMusicName: boolean = false
-  @State idDefaultMediaKu: boolean = false
+  @State defalut_home_type:number = 0
   private fastForwardSecond: FastForwardSecondInterface[] = [
     { label: '5秒', value: '5' },
     { label: '10秒', value: '10' },
@@ -256,6 +256,7 @@ export struct SettingPage {
 
   // 组件生命周期
   aboutToAppear() {
+    this.defalut_home_type = PreferencesUtil.getNumberSync('defalut_home_type', 0)
     this.showZMIndex = PreferencesUtil.getBooleanSync('showZMIndex', false)
     this.autoHideTitle = PreferencesUtil.getBooleanSync('autoHideTitle', true)
     this.isShowPrecious = PreferencesUtil.getBooleanSync('isShowPrecious', false)
@@ -295,7 +296,6 @@ export struct SettingPage {
     this.openSkipSongAnimate = PreferencesUtil.getBooleanSync(SettingPage.OPEN_SKIPSONG_ANIMATE, true)
     this.volumeSmall = PreferencesUtil.getBooleanSync('volumeSmall', false)
     this.autoParseMusicName = PreferencesUtil.getBooleanSync('autoParseMusicName', true)
-    this.idDefaultMediaKu = PreferencesUtil.getBooleanSync('idDefaultMediaKu', false)
     this.isShowFileName = PreferencesUtil.getBooleanSync('isShowFileName', false)
     this.isLongNameRoLL = PreferencesUtil.getBooleanSync('isLongNameRoLL', true)
     this.isShowBackFast  = PreferencesUtil.getBooleanSync('isShowBackFast', false)
@@ -1652,35 +1652,45 @@ export struct SettingPage {
             .height(55)
             .clickEffect({ level: ClickEffectLevel.HEAVY })
             Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
-            // 首页默认切换媒体库
+
+            // 首页默认
             Row() {
-              SymbolGlyph($r('sys.symbol.identify_song'))
+              SymbolGlyph($r('sys.symbol.home_button'))
                 .fontSize(20)
                 .fontColor([this.themeColor])
                 .alignSelf(ItemAlign.Center)
                 .margin({ left: 15 })
-              Text('首页默认媒体库')
+              Text('首页默认')
                 .margin({ left: 8 })
                 .fontSize(15)
                 .fontColor(Color.Gray)
                 .fontWeight(480)
                 .layoutWeight(1)
-              Toggle({ type: ToggleType.Switch, isOn: this.idDefaultMediaKu })
-                .selectedColor(this.themeColor)
-                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
-                .switchPointColor(Color.White)
+              Select([
+                { value: CommonConstants.DEFAULT_HOME_TYPE[0] },
+                { value: CommonConstants.DEFAULT_HOME_TYPE[1] },
+                { value: CommonConstants.DEFAULT_HOME_TYPE[2] },
+                { value: CommonConstants.DEFAULT_HOME_TYPE[3] },
+                { value: CommonConstants.DEFAULT_HOME_TYPE[4] }
+              ])
+                .font({ size: 15, weight: FontWeight.Medium })
+                .fontColor(Color.Gray)
                 .margin({ right: 18 })
-                .onChange((checked: boolean) => {
-                  this.idDefaultMediaKu = checked;
-                  PreferencesUtil.put('idDefaultMediaKu', this.idDefaultMediaKu)
+                .selected(this.defalut_home_type)
+                .value(CommonConstants.DEFAULT_HOME_TYPE[this.defalut_home_type])
+                .onSelect(async (_index: number, text?: string | undefined) => {
+                  this.defalut_home_type = _index
+                  PreferencesUtil.put('defalut_home_type', this.defalut_home_type)
+                  this.sendChangeEvent()
                 })
-                .width(50)
-                .height(30);
             }
             .height(55)
-            .clickEffect({ level: ClickEffectLevel.HEAVY })
+            .clickEffect({level:ClickEffectLevel.HEAVY})
+
             Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
 
+
+
             // 列表显示音乐文件名
             Row() {
               SymbolGlyph($r('sys.symbol.text_clipboard'))