|
|
@@ -645,9 +645,11 @@ export struct UploadMusicPage {
|
|
|
|
|
|
// 将选中的项目添加到已选列表
|
|
|
const selectedItems: LocalFileItem[] = [];
|
|
|
+ const selectedSet = new Set<string>();
|
|
|
this.selectedBrowserItems.forEach((path) => {
|
|
|
const found = this.browserFiles.find((f) => f.path === path);
|
|
|
- if (found) {
|
|
|
+ if (found && !selectedSet.has(found.path)) {
|
|
|
+ selectedSet.add(found.path);
|
|
|
selectedItems.push(found);
|
|
|
}
|
|
|
});
|
|
|
@@ -1013,8 +1015,9 @@ export struct UploadMusicPage {
|
|
|
|
|
|
// 添加到上传队列,传递用户选择的上传路径
|
|
|
Logger.info(TAG, `使用上传路径: ${this.uploadPath}`);
|
|
|
- this.webdavManager.addToUploadQueue(songs, this.selectedAccount, this.uploadPath);
|
|
|
- this.totalUploadCount = songs.length;
|
|
|
+ const uniqueSongs = this.deduplicateSongs(songs);
|
|
|
+ this.webdavManager.addToUploadQueue(uniqueSongs, this.selectedAccount, this.uploadPath);
|
|
|
+ this.totalUploadCount = uniqueSongs.length;
|
|
|
this.uploadedCount = 0;
|
|
|
|
|
|
// 开始处理上传队列
|
|
|
@@ -1024,6 +1027,10 @@ export struct UploadMusicPage {
|
|
|
this.selectedFiles = [];
|
|
|
this.selectedFileNames = [];
|
|
|
this.selectedFileTypes = [];
|
|
|
+ this.pendingCount = this.webdavManager.uploadQueue.length;
|
|
|
+ this.selectedFiles = [];
|
|
|
+ this.selectedFileNames = [];
|
|
|
+ this.selectedFileTypes = [];
|
|
|
} catch (error) {
|
|
|
const err = error as Error;
|
|
|
Logger.error(TAG, `启动上传失败: ${err.message}`);
|
|
|
@@ -1034,6 +1041,25 @@ export struct UploadMusicPage {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private deduplicateSongs(songs: VideoItem[]): VideoItem[] {
|
|
|
+ const unique: VideoItem[] = [];
|
|
|
+ const seen = new Set<string>();
|
|
|
+ for (let i = 0; i < songs.length; i++) {
|
|
|
+ const song = songs[i];
|
|
|
+ const key = song.filePath || song.name;
|
|
|
+ if (!key) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (seen.has(key)) {
|
|
|
+ Logger.warn(TAG, `跳过重复文件: ${song.name}`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ seen.add(key);
|
|
|
+ unique.push(song);
|
|
|
+ }
|
|
|
+ return unique;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 暂停上传
|
|
|
*/
|
|
|
@@ -1907,7 +1933,7 @@ export struct UploadMusicPage {
|
|
|
Row({ space: 6 }) {
|
|
|
Text('📁')
|
|
|
.fontSize(16)
|
|
|
- Text('浏览选择')
|
|
|
+ Text('浏览选择')
|
|
|
.fontSize(14)
|
|
|
.fontWeight(FontWeight.Medium)
|
|
|
}
|