Browse Source

保存瀑布流最后的列数

onecold 11 months ago
parent
commit
814d34301f
1 changed files with 5 additions and 13 deletions
  1. 5 13
      entry/src/main/ets/view/LocalMusic.ets

+ 5 - 13
entry/src/main/ets/view/LocalMusic.ets

@@ -227,16 +227,11 @@ export struct LocalMusic {
 
 
   //瀑布流的列数横竖屏动态切换
   //瀑布流的列数横竖屏动态切换
   onIsLandscapeChange() {
   onIsLandscapeChange() {
-   if(this.isLandscape){
-     this.columns = 4
-   }else{
-     let lastCount = AppStorage.get<number>('columnsCount');
-     if (typeof lastCount != 'undefined') {
-       this.columns = lastCount;
+     if(this.isLandscape){
+       this.columns = 4
      }else{
      }else{
-       this.columns = 2;
+       this.columns = PreferencesUtil.getNumberSync('lastColumns', 2);
      }
      }
-   }
   }
   }
 
 
   onColorModeChange() {
   onColorModeChange() {
@@ -474,10 +469,7 @@ export struct LocalMusic {
   // 组件生命周期
   // 组件生命周期
   aboutToAppear() {
   aboutToAppear() {
     this.sonTwoFingerType = PreferencesUtil.getNumberSync('sonTwoFingerType', 3);
     this.sonTwoFingerType = PreferencesUtil.getNumberSync('sonTwoFingerType', 3);
-    let lastCount = AppStorage.get<number>('columnsCount');
-    if (typeof lastCount != 'undefined') {
-      this.columns = lastCount;
-    }
+    this.columns = PreferencesUtil.getNumberSync('lastColumns', 2);
     if(PreferencesUtil.getBooleanSync('isFirstTiped',true)){
     if(PreferencesUtil.getBooleanSync('isFirstTiped',true)){
       this.tipPopup = !this.tipPopup
       this.tipPopup = !this.tipPopup
       PreferencesUtil.putSync('isFirstTiped',false)
       PreferencesUtil.putSync('isFirstTiped',false)
@@ -3545,7 +3537,7 @@ export struct LocalMusic {
               })
               })
 
 
               // 持久化保存当前列数:下次启动时恢复
               // 持久化保存当前列数:下次启动时恢复
-              AppStorage.setOrCreate<number>('columnsCount', this.columns);
+              PreferencesUtil.putSync('lastColumns', this.columns);
             })
             })
         )
         )