Эх сурвалжийг харах

修复内嵌标签还是报错的问题

onecold 9 сар өмнө
parent
commit
1404b40993

+ 34 - 6
entry/src/main/ets/view/LocalMusic.ets

@@ -6776,8 +6776,7 @@ export struct LocalMusic {
       }else if (this.modeType === 1){
         workerInstance.postMessage({ code: 2, data: this.context,data2:this.packName });
       }
-
-    }, 999)
+    }, 500)
   }
 
   doAllUpdateData() {
@@ -6904,21 +6903,25 @@ export struct LocalMusic {
           }
 
           this.syncListsAfterEdit(item.filePath)
-          this.doUpdateData()
+          this.doUpateEditedFields(item)
+          //this.doUpdateData()
         } else {
           // ToastUtil.showToast('保存失败' + error?.toString())
           console.error(" onecold  编辑信息数据库失败 ");
         }
 
+
+
+
       }).catch((error: Error) => {
+        // 关闭进度条
+        DialogHelper.closeLoading();
         console.error('onecold Subtitle sync failed:', error);
       });
 
 
       console.log(' onecold 元数据标签更新成功,');
 
-      // 关闭进度条
-      DialogHelper.closeLoading();
     } else {
       // 关闭进度条
       DialogHelper.closeLoading();
@@ -6934,8 +6937,33 @@ export struct LocalMusic {
 
   }
 
-  updateLyricToDB() {
+  // 内嵌标签更新当前内嵌的Item
+  async doUpateEditedFields(item: VideoItem) {
+    // 找到当前项在 videoLocalList 中的索引
+    const index = this.videoLocalList.findIndex(video => video.filePath === item.filePath);
 
+    if (index !== -1) {
+      // 使用已初始化的MediaTable实例从数据库查询歌曲信息
+      const updatedItem = await this.table.queryVideoByFilePath(item.filePath)
+
+      // 只有当查询结果不为 null 时才更新列表
+      if (updatedItem !== null) {
+        // 更新 videoLocalList 中的项(通过创建新数组触发响应式更新)
+        this.videoLocalList = [
+          ...this.videoLocalList.slice(0, index),
+          updatedItem,
+          ...this.videoLocalList.slice(index + 1)
+        ];
+
+        // 同步更新 LazyDataSource
+        this.dataSource.pushArrayData(this.videoLocalList)
+
+      } else {
+        ToastUtil.showToast('未找到更新的数据');
+      }
+
+    }
+    DialogHelper.closeLoading();
   }
 
   @Builder