Преглед на файлове

删除刷新问题,发布新版本

onecold преди 9 месеца
родител
ревизия
eaef6a1286

+ 2 - 2
AppScope/app.json5

@@ -2,8 +2,8 @@
   "app": {
     "bundleName": "com.xgplayer.ttmusic.hm",
     "vendor": "example",
-    "versionCode": 20251023,
-    "versionName": "1.6.6",
+    "versionCode": 20251101,
+    "versionName": "1.6.7",
     "icon": "$media:app_icon",
     "label": "$string:app_name",
     "multiAppMode": {

+ 1 - 0
entry/src/main/ets/common/util/MusicTagUtils.ets

@@ -564,6 +564,7 @@ export async function syncLyricToDB(context:Context,filePath: string,lyric:strin
         err ? reject(err) : resolve();
       });
     });
+
     table.updateMediaInfo(filePath, '', '', '',lyric,
       '','','','','', '','','',
       (success: boolean, error?: string) => {

+ 14 - 7
entry/src/main/ets/view/DeleteComptent.ets

@@ -1,7 +1,7 @@
 import { common } from '@kit.AbilityKit';
 import { CommonConstants } from '../common/constants/CommonConstants';
 import { VideoItem } from '../viewmodel/VideoItem';
-import { ArrayUtil, FileUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
+import { AppUtil, ArrayUtil, FileUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
 import MediaTable from '../common/util/MediaTable';
 import PlaylistTable from '../common/util/PlaylistTable';
 import { EventConstants } from '../common/constants/EventConstants';
@@ -15,6 +15,7 @@ export struct DeleteComptent {
   @State isDeleteYuan: boolean = true
   @State isDeletePicture: boolean = true
   @State isDeleteLrc: boolean = true
+  @State packName: string = ''
   onDeleteResult = (_result: boolean) => {
   }
   onCancel = () => {
@@ -25,6 +26,7 @@ export struct DeleteComptent {
 
 
   async aboutToAppear() {
+    this.packName = AppUtil.getBundleName()
     this.isDeleteYuan = PreferencesUtil.getBooleanSync('isDeleteYuan', true);
     this.isDeletePicture = PreferencesUtil.getBooleanSync('isDeletePicture', true);
     this.isDeleteLrc = PreferencesUtil.getBooleanSync('isDeleteLrc', true)
@@ -165,11 +167,14 @@ export struct DeleteComptent {
     const task = new taskpool.Task(
       deleteMultipleFiles,
       JSON.stringify(this.selectedFiles),
-      this.isDeleteYuan,this.isDeletePicture,this.isDeleteLrc,this.context
+      this.isDeleteYuan,this.isDeletePicture,this.isDeleteLrc,this.context,this.packName
     );
     taskpool.execute(task, taskpool.Priority.HIGH).then((result) => {
       if(result){
-        this.onDeleteResult(true)
+        setTimeout(() => {
+          this.onDeleteResult(true)
+        },500)
+
       }else {
         this.onDeleteResult(false)
       }
@@ -189,7 +194,8 @@ async function deleteMultipleFiles(
   isDeleteYuan:boolean,
   isDeletePicture:boolean,
   isDeleteLrc:boolean,
-  context:Context
+  context:Context,
+  packName:string
 ) {
 
   const selectedFiles: VideoItem[] = JSON.parse(selectedFilesStr)
@@ -223,8 +229,9 @@ async function deleteMultipleFiles(
 
         table.deleteData(item, async () => {
           if(isDeleteYuan){
-            await PermissionUtil.activatePermission(item.filePath)
-            await FileUtil.unlink(item.filePath)
+            if(item.filePath.toLowerCase().includes(packName)){
+              await FileUtil.unlink(item.filePath)
+            }
 
           }
           console.info(`onecold 封面文件=: ${item.pixelMapPath}`);
@@ -239,7 +246,7 @@ async function deleteMultipleFiles(
           console.info(`onecold 歌词文件=: ${lyricPath}`);
           if(isDeleteLrc) {
 
-            if (lyricPath && FileUtil.accessSync(lyricPath)) {
+            if (lyricPath&&item.filePath.toLowerCase().includes(packName) && FileUtil.accessSync(lyricPath)) {
               await FileUtil.unlink(lyricPath);
               console.info( `onecold 歌词文件已删除: ${lyricPath}`);
             }

+ 8 - 1
entry/src/main/ets/view/LocalMusic.ets

@@ -1103,6 +1103,7 @@ export struct LocalMusic {
     const documentViewPicker = new picker.DocumentViewPicker()
     let documentSaveResult = await documentViewPicker.save({ pickerMode: picker.DocumentPickerMode.DOWNLOAD })
     this.rootPath = new fileUri.FileUri(documentSaveResult[0]).path
+    PreferencesUtil.putSync('download_path', this.rootPath+'/')
     this.currentPath = this.rootPath
     this.lockPath = this.rootPath + '/' + LocalMusic.STR_LOCK_VIDEO
     this.favPath = this.rootPath + '/' + LocalMusic.STR_FAC_VIDEO
@@ -1246,6 +1247,7 @@ export struct LocalMusic {
       if (this.currentPath != this.rootPath) { //第一个封面赋值给currentTitleCover
         this.currentTitleCover = Utility.getFirstCoverFromList(cachedValue)
       }
+      this.isRefreshing = false
       this.updateListData(cachedValue)
     }
 
@@ -2521,7 +2523,12 @@ export struct LocalMusic {
                 transition: TransitionEffect.translate({ x: 500 }).animation({ curve: curves.springMotion(0.6, 0.8) })
               })
               .onClick(() => {
-                this.isOneKeyTags = !this.isOneKeyTags
+                if(ArrayUtil.isNotEmpty(this.selectedFiles)&&Utility.isMerge(this.selectedFiles,this.packName)){
+                  this.isOneKeyTags = !this.isOneKeyTags
+                }else{
+                  ToastUtil.showToast('选中的文件包含了不是本应用的DownLoad文件下,其他路径音频无权限批量内嵌')
+                }
+
               })
 
             Button('合并', { type: ButtonType.Circle, stateEffect: true })

+ 34 - 8
entry/src/main/ets/view/TagsContentCover.ets

@@ -10,7 +10,7 @@ import { changeMusicCover, findLocalCoverImage, getApiLyric, repairAudioMetadata
 import { util } from '@kit.ArkTS';
 import { FFMpegTags, Utility } from '../common/util/Utility';
 import { DialogHelper } from '@pura/harmony-dialog';
-
+import PermissionUtil from '../common/util/PermissionUtil'
 //批量编辑标签
 // 批量编辑标签
 @Component
@@ -20,8 +20,9 @@ export struct TagsContentCover {
   }
   @State isLyric:boolean = true
   @State isCover:boolean = true
+  @State download_path:string = ''
   @Link isOneKeyTags: boolean;
-  @State bundleName: string = ''
+  @State packName: string = ''
   @State dataSource: LazyDataSource<VideoItem> = new LazyDataSource([])
   @Prop selectedFiles: Array<VideoItem>
   @StorageProp('topRectHeight') topRectHeight: number = 0;
@@ -48,7 +49,9 @@ export struct TagsContentCover {
   }
 
   async aboutToAppear() {
-    this.bundleName = AppUtil.getBundleName()
+    this.download_path = PreferencesUtil.getStringSync('download_path')
+    console.info('onecold download_path:', this.download_path)
+    this.packName = AppUtil.getBundleName()
     // 确保 selectedFiles 有默认值后再初始化 dataSource
     if (this.selectedFiles && this.selectedFiles.length > 0) {
       this.dataSource = new LazyDataSource(this.selectedFiles)
@@ -262,7 +265,7 @@ export struct TagsContentCover {
           .margin({ left: 6 })
           .onClick(() => {
             DialogHelper.closeDialog('vip');
-            Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.bundleName)
+            Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.packName)
             setTimeout(()=>{
               PreferencesUtil.putSync('IS_HAO_PING',true)
             },15000)
@@ -321,7 +324,7 @@ export struct TagsContentCover {
 
 
         let success = true;
-
+        let tempOutPath = ''
         // 1. 处理封面 (如果启用且需要处理)
         if(this.isCover){
           let  defaultCover = ''
@@ -345,11 +348,19 @@ export struct TagsContentCover {
           if (StrUtil.isNotEmpty(defaultCover)) {
             // 确保 filePath 存在
             if (item.filePath) {
+              await PermissionUtil.activatePermission(item.filePath)
+              // 如果不是 packName 包下的文件,则直接路径用this.download_path
+              if(!item.filePath.toLowerCase().includes(this.packName)){
+                tempOutPath  = item.parentPath+'/'+ item.fileName
+              }
+              console.info('onecold tempOutPath: ' + tempOutPath)
+
+
               const result = await changeMusicCover(
                 this.context,
                 item.filePath,
                 defaultCover,
-                true // 覆盖原文件
+                true, tempOutPath
               );
               if (!result) {
                 success = false;
@@ -404,16 +415,31 @@ export struct TagsContentCover {
           // 如果有歌词内容,嵌入到音频文件
           if (StrUtil.isNotEmpty(lyricContent) && item.filePath) {
             const metadata: FFMpegTags = {};
+            let newInput = item.filePath
+            //内嵌标签歌路径如果不是包含包名,输入newInput要赋值tempOutPath,然后tempOutPath为空
+            if(!item.filePath.toLowerCase().includes(this.packName)){
+              newInput = tempOutPath
+              tempOutPath  = ''
+            }
             // 修复错误2: 添加非空检查
             const result = await repairAudioMetadata(
-              item.filePath,
+              newInput,
               lyricContent,
               metadata,
-              true // 覆盖原文件
+              true ,
+              tempOutPath
             );
             if (!result) {
               success = false;
             }else{
+              // if(!item.filePath.includes(this.packName)){
+              //   //内嵌成功的歌路径如果不是包含包名,则要入库
+              //   let newItem: VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context, newInput,
+              //     CommonConstants.TYPE_LOCAL, true);
+              //   this.table.insert(newItem, (id: number) => {
+              //
+              //   });
+              // }
               //内嵌成功后同步歌词到数据库
               syncLyricToDB(this.context,item.filePath,lyricContent)
             }