Bladeren bron

PreferencesUtil.putSync() 方法将数据存储到本地缓存,但有时会报错 The type of value must be less then 16*1024*1024 bytes

onecold 10 maanden geleden
bovenliggende
commit
3e62637de8

+ 2 - 0
entry/src/main/ets/common/util/MediaTable.ets

@@ -1,6 +1,7 @@
 import relationalStore from '@ohos.data.relationalStore';
 import { LogUtil, StrUtil } from '@pura/harmony-utils';
 import { VideoItem } from '../../viewmodel/VideoItem';
+import { CommonConstants } from '../constants/CommonConstants';
 import Logger from './Logger';
 import RdbUtils from './RdbUtils';
 import { AudioQuality, Utility } from './Utility';
@@ -526,6 +527,7 @@ export default class MediaTable {
       // 添加筛选条件,确保lastPlayedStr不为空
       predicates.isNotNull('lastPlayedStr');
       predicates.notEqualTo('lastPlayedStr',  ''); // 排除空字符串
+      predicates.notEqualTo('mtype', CommonConstants.TYPE_LOCK);
       // 使用 orderByDesc 方法进行降序排序
       predicates.orderByDesc('lastPlayedStr');
       // 使用 limit 方法限制返回的记录数量

+ 5 - 5
entry/src/main/ets/pages/NewIndex.ets

@@ -509,11 +509,11 @@ struct NewIndex {
 
     Column() {
       this.userInfoView()
-      Column({ space: 20 }) {
-        SegmentButton({ options: this.tabOptions, selectedIndexes: $tabSelectedIndexes })
-      }
-      .padding({ bottom:10 })
-      .width('80%')
+      // Column({ space: 20 }) {
+      //   SegmentButton({ options: this.tabOptions, selectedIndexes: $tabSelectedIndexes })
+      // }
+      // .padding({ bottom:10 })
+      // .width('80%')
     }
 
   }

+ 4 - 3
entry/src/main/ets/pages/ScanFilePage.ets

@@ -529,6 +529,10 @@ async function  scanDirectoryTask(context: Context, dirPath: string,
         if (fPath.endsWith('.lrc')  || fPath.endsWith('.srt'))  return;
         // console.info('onecold scanDirectoryTask fPath2 = ' + fPath)
         if (Utility.isMeidaByExtension(fPath))  {
+
+          const mediaItem = await Utility.uriGetMusicAssetsFromFile(
+            context, fPath, CommonConstants.TYPE_LOCAL, autoParseMusicName
+          );
           insertCount++
           try {
             // console.info('onecold scanDirectoryTask fPath = ' + fPath)
@@ -538,9 +542,6 @@ async function  scanDirectoryTask(context: Context, dirPath: string,
             let err = error as BusinessError;
             console.warn( `onecold sendData failed, code=${err.code}, message=${err.message}`);
           }
-          const mediaItem = await Utility.uriGetMusicAssetsFromFile(
-            context, fPath, CommonConstants.TYPE_LOCAL, autoParseMusicName
-          );
 
           table.insert(mediaItem,  (id: number) => {
 

+ 2 - 2
entry/src/main/ets/view/FixMessyView.ets

@@ -20,7 +20,7 @@ export struct FixMessyView {
   onFixResult = (_result: boolean) => {
   }
 
-  @Link isShowDrawer: boolean;
+  @Link isFixMessy: boolean;
   @State bundleName: string = ''
   @State dataSource: LazyDataSource<VideoItem> = new LazyDataSource([])
   @Prop selectedFiles: Array<VideoItem>
@@ -308,7 +308,7 @@ export struct FixMessyView {
             .onClick(() => {
               this.getUIContext().animateTo({ duration: 666 }, () => {
                 // 动画闭包内控制Image组件的出现和消失
-                this.isShowDrawer = !this.isShowDrawer
+                this.isFixMessy = !this.isFixMessy
               })
             })
           Blank().flexGrow(1)

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

@@ -869,8 +869,13 @@ export struct LocalMusic {
           } else {
             PreferencesUtil.putSync('artistList',  JSON.stringify(this.artistList));
           }
-          const mapArray = Array.from(this.artistMap.entries());
-          PreferencesUtil.putSync('artistMap',  JSON.stringify(mapArray));
+          // 处理并缓存前80条艺术家数据
+          const sortedEntries = Array.from(this.artistMap.entries())
+            .sort((a, b) => b[1].length - a[1].length)
+            .slice(0, 80);
+
+          PreferencesUtil.putSync('artistMap',  JSON.stringify(sortedEntries));
+
           break;
 
         case 104: //收到查询专辑列表
@@ -893,7 +898,9 @@ export struct LocalMusic {
           } else {
             PreferencesUtil.putSync('albumList',  JSON.stringify(this.albumList));
           }
-          const mapArrayAlbum = Array.from(this.albumMap.entries());
+          const mapArrayAlbum = Array.from(this.albumMap.entries())
+            .sort((a, b) => b[1].length - a[1].length)
+            .slice(0, 80);
           PreferencesUtil.putSync('albumMap',  JSON.stringify(mapArrayAlbum));
           break;
 
@@ -2404,7 +2411,7 @@ export struct LocalMusic {
         TagsContentCover(
           {
             selectedFiles:this.selectedFiles,
-            isShowDrawer:this.isOneKeyTags,
+            isOneKeyTags:this.isOneKeyTags,
             onTagsResult:(result: boolean)=>{
               this.isMultiSelect = false
               if(result){//如果嵌入成功,更新数据
@@ -2427,7 +2434,7 @@ export struct LocalMusic {
         FixMessyView(
           {
             selectedFiles:this.selectedFiles,
-            isShowDrawer:this.isFixMessy,
+            isFixMessy:this.isFixMessy,
             onFixResult:(result: boolean)=>{
               this.isMultiSelect = false
               if(result){//如果嵌入成功,更新数据

+ 2 - 2
entry/src/main/ets/view/TagsContentCover.ets

@@ -20,7 +20,7 @@ export struct TagsContentCover {
   }
   @State isLyric:boolean = true
   @State isCover:boolean = true
-  @Link isShowDrawer: boolean;
+  @Link isOneKeyTags: boolean;
   @State bundleName: string = ''
   @State dataSource: LazyDataSource<VideoItem> = new LazyDataSource([])
   @Prop selectedFiles: Array<VideoItem>
@@ -484,7 +484,7 @@ export struct TagsContentCover {
             .onClick(() => {
               this.getUIContext().animateTo({ duration: 666 }, () => {
                 // 动画闭包内控制Image组件的出现和消失
-                this.isShowDrawer = !this.isShowDrawer
+                this.isOneKeyTags = !this.isOneKeyTags
               })
             })
           Blank().flexGrow(1)

+ 0 - 28
lib/src/main/ets/view/LyricView2.ets

@@ -298,35 +298,7 @@ export struct LyricView2 {
                 :Visibility.Visible)
             .width(this.alignMode == 'center' ? '100%' : '76%')
     }
-    // 逐字歌词渲染
-    @Builder
-    WordByWordLyric2(item: LyricLine, index: number) {
-        Column() {
-            // 英文逐字歌词
-            Row({ space: 0 }) {
-                ForEach(item.words,  (word: LyricWord, wordIndex: number) => {
-                    Text(word.word)
-                        .fontSize(index == this.currentIndex  ?
-                            this.textSize*this.controller.getHighlightScale()  : this.textSize)
-                        .fontColor(this.currentMediaPosition  >= word.startTime  ?
-                            index == this.currentIndex  ? this.textHighlightColor  : this.textColor  : this.textColor)
-                        .margin({ right: 2 })
-                })
-            }
-            .justifyContent(this.alignMode  === 'center' ? FlexAlign.Center : FlexAlign.Start)
 
-            // 中文翻译(整行显示)
-            if (item.translation)  {
-                Text(item.translation)
-                    .fontSize(this.textSize)
-                    .fontColor(index == this.currentIndex  ?
-                    this.textHighlightColor  : this.textColor)
-                    .margin({ top: 4 })
-            }
-        }
-        .width(this.alignMode  == 'center' ? '100%' : '95%')
-        .opacity(this.calculateOpacityFactor(index,  this.currentIndex))
-    }
     @Builder
     WordByWordLyric(item: LyricLine, index: number) {
         Column() {