Kaynağa Gözat

双语歌词bug

onecold 7 ay önce
ebeveyn
işleme
3ec642eabf

+ 43 - 46
entry/src/main/ets/view/LocalMusic.ets

@@ -221,11 +221,11 @@ interface WorkerMessageEditResult {
 
 type LocalMusicWorkerMessage =
   WorkerMessageScanDone
-  | WorkerMessageMediaList
-  | WorkerMessageArtistList
-  | WorkerMessageAlbumList
-  | WorkerMessageMetadata
-  | WorkerMessageEditResult;
+    | WorkerMessageMediaList
+    | WorkerMessageArtistList
+    | WorkerMessageAlbumList
+    | WorkerMessageMetadata
+    | WorkerMessageEditResult;
 
 /**
  * 歌单播放事件数据
@@ -442,7 +442,7 @@ export struct LocalMusic {
   private playListScroller: Scroller = new Scroller()
   @State isOneKeyTags:boolean = false
   @State isFixMessy:boolean = false
-  
+
   // 分页相关状态
   @State private currentPage: number = 0          // 当前页码
   @State private pageSize: number = 50            // 每页数量
@@ -535,12 +535,12 @@ export struct LocalMusic {
   async onModeChange(): Promise<void> {
     this.isFavMusic = false
     this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
-    
+
     Logger.info('heanup LocalMusic', `onModeChange: 切换模式 modeType=${this.modeType}`);
-    
+
     // 模式切换时重置分页状态并加载第一页
     await this.resetAndLoadFirstPage();
-    
+
     switch (this.modeType) {
       case 0:
         // 首页模式已在 resetAndLoadFirstPage 中处理
@@ -1236,7 +1236,7 @@ export struct LocalMusic {
 
           // 保存前100条艺术家列表
           PreferencesUtil.putSync('artistList',  JSON.stringify(this.artistList));
-          
+
           // 保存前60条艺术家的歌曲Map
           const sortedEntries = Array.from(this.artistMap.entries());
           PreferencesUtil.putSync('artistMap',  JSON.stringify(sortedEntries));
@@ -1255,12 +1255,12 @@ export struct LocalMusic {
           });
           this.albumSongCountMap = nextAlbumCountMap;
           Logger.info(`heanup 查询专辑列表 缓存数=${this.albumList.length}, 总数=${albumTotalCount}`)
-          
+
           // 专辑模式下重新加载第一页(分页查询)
           if (this.modeType === 3) {
             this.resetAndLoadFirstPage();
           }
-          
+
           //查询完毕在启动是否自动播放
           if (this.isStartAutoPlay&&this.isCanAuto) {
             this.isCanAuto = false
@@ -1270,7 +1270,7 @@ export struct LocalMusic {
           PreferencesUtil.putSync('albumCount', albumTotalCount)
           // 保存前100条专辑列表(Worker已经只发送了100条)
           PreferencesUtil.putSync('albumList',  JSON.stringify(this.albumList));
-          
+
           // 保存前60条专辑Map(Worker已经只发送了60条)
           const mapArrayAlbum = Array.from(this.albumMap.entries());
           PreferencesUtil.putSync('albumMap',  JSON.stringify(mapArrayAlbum));
@@ -1991,7 +1991,7 @@ export struct LocalMusic {
   }
   updateListData(mList: Array<VideoItem>, noSort?: boolean) {
     this.isShowTitleBar = true
-    animateTo({ duration: 666 }, () => {
+    this.getUIContext().animateTo({ duration: 666 }, () => {
       this.opacityItem = 0.5;
     });
     setTimeout(() => {
@@ -2003,7 +2003,7 @@ export struct LocalMusic {
         }
       }
       this.dataSource.pushArrayData(this.videoLocalList)
-      animateTo({ duration: 666 }, () => {
+      this.getUIContext().animateTo({ duration: 666 }, () => {
         this.opacityItem = 1;
       });
       this.setButtonStatus()
@@ -2221,10 +2221,10 @@ export struct LocalMusic {
 
   async doSortType(index: number): Promise<void> {
     Logger.info('heanup LocalMusic', `doSortType: 切换排序方式 sortType=${index}, mode=${this.modeType}`);
-    
+
     this.sortType = index;
     PreferencesUtil.putSync(SettingPage.SORT_TYPE, index);
-    
+
     // 分页模式下,排序需要重新从数据库查询
     await this.resetAndLoadFirstPage();
   }
@@ -2986,9 +2986,6 @@ export struct LocalMusic {
                   this.asyncCurrentPathOnlyFile()
                 })
                 .position({ top: 200 })
-                .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 })
-                  .animation({ duration: 500 }),
-                  TransitionEffect.scale({ x: 0, y: 0 })))
                 .justifyContent(FlexAlign.Center)
                 .opacity(this.isZero ? 1 : 0)
                 .visibility(this.isZero && !this.isFavMusic && !this.isHistory
@@ -3081,7 +3078,7 @@ export struct LocalMusic {
               })
               .onClick(() => {
                 // if(ArrayUtil.isNotEmpty(this.selectedFiles)&&Utility.isMerge(this.selectedFiles,this.packName)){
-                  this.isOneKeyTags = !this.isOneKeyTags
+                this.isOneKeyTags = !this.isOneKeyTags
                 // }else{
                 //   ToastUtil.showToast('选中的文件包含了不是本应用的DownLoad文件下,其他路径音频无权限批量内嵌标签,导入的时候请勾选复制一份。')
                 // }
@@ -3328,7 +3325,7 @@ export struct LocalMusic {
 
   async setAlphaBet(){
     if(!this.showZMIndex){
-        return
+      return
     }
     return new Promise<void>((resolve,reject) => {
       try {
@@ -4895,9 +4892,9 @@ export struct LocalMusic {
   // 实时搜索逻辑(带防抖)
   private async onSearchInput(value: string): Promise<void> {
     this.searchText = value.trim();
-    
+
     Logger.info('heanup LocalMusic', `onSearchInput: keyword="${this.searchText}", mode=${this.modeType}`);
-    
+
     // 新增条件判断:空输入时退出搜索模式
     if (this.searchText === '') {
       this.isSearchMode = false;
@@ -4905,12 +4902,12 @@ export struct LocalMusic {
       await this.resetAndLoadFirstPage();
       return;
     }
-    
+
     // 进入搜索模式
     if (!this.isSearchMode) {
       this.isSearchMode = true;
     }
-    
+
     // 使用数据库分页查询(带搜索条件)
     await this.resetAndLoadFirstPage();
   }
@@ -5493,7 +5490,7 @@ export struct LocalMusic {
 
       return { offsetRemain: offset };
     })
-    
+
 
   }
   @State targetFile: string = '';
@@ -6957,7 +6954,7 @@ export struct LocalMusic {
 
       this.isLoadingPage = true;
       Logger.info('heanup LocalMusic', `loadPage: 开始加载 page=${pageIndex}, size=${this.pageSize}, mode=${this.modeType}`);
-      
+
       // 2. 构造查询参数
       const options: PageQueryOptions = {
         pageIndex: pageIndex,
@@ -7020,9 +7017,9 @@ export struct LocalMusic {
       } else if (this.modeType === 3 && result.countMap) {
         this.mergeAlbumCountMap(result.countMap);
       }
-      
+
       Logger.info('heanup LocalMusic', `loadPage: 查询完成 items=${result.items.length}, total=${result.totalCount}, hasMore=${result.hasMore}`);
-      
+
       // 缓存管理 - 只保留最近3页
       this.pageCache.set(pageIndex, result.items);
       this.cleanOldCache(pageIndex);
@@ -7033,7 +7030,7 @@ export struct LocalMusic {
       } else {
         this.videoLocalList = result.items;
       }
-      
+
       this.dataSource.pushArrayData(this.videoLocalList);
       this.setButtonStatus();
       this.setAlphaBet();
@@ -7054,15 +7051,15 @@ export struct LocalMusic {
   private cleanOldCache(currentPage: number): void {
     const pagesToKeep = new Set([currentPage - 1, currentPage, currentPage + 1]);
     const keysToDelete: number[] = [];
-    
+
     this.pageCache.forEach((_, page) => {
       if (!pagesToKeep.has(page)) {
         keysToDelete.push(page);
       }
     });
-    
+
     keysToDelete.forEach(page => this.pageCache.delete(page));
-    
+
     if (keysToDelete.length > 0) {
       Logger.info('heanup LocalMusic', `cleanOldCache: 清理了 ${keysToDelete.length} 页缓存`);
     }
@@ -7140,7 +7137,7 @@ export struct LocalMusic {
   private async loadDirectories(curPath: string): Promise<VideoItem[]> {
     try {
       Logger.info('heanup LocalMusic', `loadDirectories: 开始加载文件夹 path=${curPath}`);
-      
+
       // 检查缓存
       const cacheKey = curPath + "_dirList";
       const cachedDirList = this.findCache(cacheKey);
@@ -7148,20 +7145,20 @@ export struct LocalMusic {
         Logger.info('heanup LocalMusic', `loadDirectories: 从缓存加载 count=${cachedDirList.length}`);
         return cachedDirList as VideoItem[];
       }
-      
+
       // 从文件系统读取
       const fileList = FileUtil.listFileSync(curPath);
       const directories: VideoItem[] = [];
-      
+
       for (let i = 0; i < fileList.length; i++) {
         const path = curPath + '/' + fileList[i];
         if (FileUtil.isDirectory(path)) {
           const item: VideoItem = new VideoItem(
-            fileList[i].toString(), 
-            fileList[i].toString(), 
-            path, 
-            CommonConstants.TYPE_IS_DIR, 
-            0, 
+            fileList[i].toString(),
+            fileList[i].toString(),
+            path,
+            CommonConstants.TYPE_IS_DIR,
+            0,
             ''
           );
           if (this.isShowDir(item.name)) {
@@ -7169,16 +7166,16 @@ export struct LocalMusic {
           }
         }
       }
-      
+
       // 排序
       Utility.doSortListAscending(directories);
-      
+
       // 缓存文件夹列表
       if (curPath === this.rootPath) {
         this.dirList = directories;
         this.addCache(cacheKey, directories);
       }
-      
+
       Logger.info('heanup LocalMusic', `loadDirectories: 加载完成 count=${directories.length}`);
       return directories;
     } catch (err) {
@@ -13861,7 +13858,7 @@ export struct LocalMusic {
         } else {
           if (StrUtil.isNotEmpty(this.videoUrl) &&
             !this.videoUrl.startsWith('http') &&
-            this.currentSong &&this.currentSong.type==CommonConstants.TYPE_LOCAL&&
+          this.currentSong &&this.currentSong.type==CommonConstants.TYPE_LOCAL&&
             !FileUtil.accessSync(this.videoUrl)) {
             console.info('heanup 播放.文件不存在');
             ToastUtil.showToast(Utility.resourceToString(this.context, $r('app.string.file_not_exist')))

+ 18 - 18
lib/src/main/ets/view/LyricView2.ets

@@ -316,24 +316,24 @@ export struct LyricView2 {
 
             // 中文翻译(整行显示)
             if (item.translation)  {
-                Row({ space: 0 }) {
-                    Text(item.translation)
-                        .fontSize(index == this.currentIndex ?this.textSize*this.controller.getHighlightScale():this.textSize)
-                        .fontColor(this.currentMediaPosition >= item.beginTime ?
-                            index == this.currentIndex ? this.textHighlightColor : this.textColor : this.textColor)
-                        .fontWeight(index == this.currentIndex && this.isHighlightBold ? FontWeight.Bold : this.textWeight)
-                        .padding({ bottom:5 })
-                        .animation({
-                            duration: 150,
-                            curve: Curve.Linear
-                        })
-                        .blendMode(
-                            index == this.currentIndex ? BlendMode.DST_IN : undefined,
-                            index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
-                        )
-                }
-                .justifyContent(this.alignMode === 'center' ? FlexAlign.Center : FlexAlign.Start)
-                .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '85%')
+
+            Text(item.translation)
+                .fontSize(index == this.currentIndex ?this.textSize*this.controller.getHighlightScale():this.textSize)
+                .fontColor(this.currentMediaPosition >= item.beginTime ?
+                    index == this.currentIndex ? this.textHighlightColor : this.textColor : this.textColor)
+                .fontWeight(index == this.currentIndex && this.isHighlightBold ? FontWeight.Bold : this.textWeight)
+                .padding({ bottom:5 })
+                .textAlign(this.alignMode == 'center' ? TextAlign.Center : TextAlign.Start)
+                .animation({
+                    duration: 150,
+                    curve: Curve.Linear
+                })
+                .blendMode(
+                    index == this.currentIndex ? BlendMode.DST_IN : undefined,
+                    index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
+                )
+                .width(this.alignMode == 'center' ? '95%' : '85%')
+
             }
         }
         // 在 Row 上应用渐变