|
@@ -312,6 +312,7 @@ export struct LocalMusic {
|
|
|
@State dirList: Array<VideoItem> = []
|
|
@State dirList: Array<VideoItem> = []
|
|
|
@Consume videoLocalList:VideoItem[]
|
|
@Consume videoLocalList:VideoItem[]
|
|
|
@State dataSource: LazyDataSource<VideoItem> = new LazyDataSource(this.videoLocalList)
|
|
@State dataSource: LazyDataSource<VideoItem> = new LazyDataSource(this.videoLocalList)
|
|
|
|
|
+ @State listRefreshKey: number = 0
|
|
|
// @State mediaKuList: Array<VideoItem> = []; //媒体库文件
|
|
// @State mediaKuList: Array<VideoItem> = []; //媒体库文件
|
|
|
@StorageProp('mediaKuList') mediaKuList: Array<VideoItem> = []; //媒体库文件
|
|
@StorageProp('mediaKuList') mediaKuList: Array<VideoItem> = []; //媒体库文件
|
|
|
@State artistList: Array<VideoItem> = []; //艺术家文件
|
|
@State artistList: Array<VideoItem> = []; //艺术家文件
|
|
@@ -4311,7 +4312,7 @@ export struct LocalMusic {
|
|
|
})
|
|
})
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
- }, (item: VideoItem) => item.filePath)
|
|
|
|
|
|
|
+ }, (item: VideoItem) => item.filePath + '_' + this.listRefreshKey)
|
|
|
}
|
|
}
|
|
|
// .columnsTemplate('repeat(auto-fit, 160)')
|
|
// .columnsTemplate('repeat(auto-fit, 160)')
|
|
|
.id('waterflow') // 设置id用于截图
|
|
.id('waterflow') // 设置id用于截图
|
|
@@ -4749,7 +4750,7 @@ export struct LocalMusic {
|
|
|
.translate(this.dragItem === index ? { x: this.offsetX, y: this.offsetY } : { x: 0, y: 0 })
|
|
.translate(this.dragItem === index ? { x: this.offsetX, y: this.offsetY } : { x: 0, y: 0 })
|
|
|
|
|
|
|
|
|
|
|
|
|
- }, (item: VideoItem) => item.filePath)
|
|
|
|
|
|
|
+ }, (item: VideoItem) => item.filePath + '_' + this.listRefreshKey)
|
|
|
}
|
|
}
|
|
|
.width('94%')
|
|
.width('94%')
|
|
|
.height('100%')
|
|
.height('100%')
|
|
@@ -5120,7 +5121,7 @@ export struct LocalMusic {
|
|
|
.onClick(async () => {
|
|
.onClick(async () => {
|
|
|
this.longItemFilePath = ''
|
|
this.longItemFilePath = ''
|
|
|
await this.openAddToPlaylistDialog(item)
|
|
await this.openAddToPlaylistDialog(item)
|
|
|
- })
|
|
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
MenuItem({
|
|
MenuItem({
|
|
|
symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.square_and_pencil')),
|
|
symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.square_and_pencil')),
|
|
@@ -5135,8 +5136,11 @@ export struct LocalMusic {
|
|
|
})
|
|
})
|
|
|
.visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
|
|
.visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
|
|
|
.onClick(async() => {
|
|
.onClick(async() => {
|
|
|
- this.setEditStrEmpty()
|
|
|
|
|
|
|
+ this.initEditFields(item)
|
|
|
this.tempLyricContent = await this.getLyricContent(item);
|
|
this.tempLyricContent = await this.getLyricContent(item);
|
|
|
|
|
+ if (StrUtil.isNotEmpty(this.tempLyricContent)) {
|
|
|
|
|
+ this.lyricConStr = this.tempLyricContent
|
|
|
|
|
+ }
|
|
|
if(this.isGridMusic||this.twoFingerType==4){
|
|
if(this.isGridMusic||this.twoFingerType==4){
|
|
|
this.longItemFilePath = item.filePath
|
|
this.longItemFilePath = item.filePath
|
|
|
}else{
|
|
}else{
|
|
@@ -5542,7 +5546,7 @@ export struct LocalMusic {
|
|
|
})
|
|
})
|
|
|
) //拖动List关键代码结束
|
|
) //拖动List关键代码结束
|
|
|
|
|
|
|
|
- }, (item: VideoItem) => item.filePath)
|
|
|
|
|
|
|
+ }, (item: VideoItem) => item.filePath + '_' + this.listRefreshKey)
|
|
|
// }
|
|
// }
|
|
|
}
|
|
}
|
|
|
.scrollBar(BarState.Off)
|
|
.scrollBar(BarState.Off)
|
|
@@ -6509,6 +6513,7 @@ export struct LocalMusic {
|
|
|
ToastUtil.showToast('内嵌音乐标签成功')
|
|
ToastUtil.showToast('内嵌音乐标签成功')
|
|
|
this.isShowMoreView = false
|
|
this.isShowMoreView = false
|
|
|
this.name = this.titleStr
|
|
this.name = this.titleStr
|
|
|
|
|
+ this.syncEditedFields(item)
|
|
|
if (item.filePath == this.currentSong?.filePath) {
|
|
if (item.filePath == this.currentSong?.filePath) {
|
|
|
this.currentSong.name = this.titleStr
|
|
this.currentSong.name = this.titleStr
|
|
|
this.artist = this.artistStr
|
|
this.artist = this.artistStr
|
|
@@ -6526,6 +6531,7 @@ export struct LocalMusic {
|
|
|
this.currentSong.COMMENT = this.commentStr
|
|
this.currentSong.COMMENT = this.commentStr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ this.syncListsAfterEdit(item.filePath)
|
|
|
this.doUpdateData()
|
|
this.doUpdateData()
|
|
|
} else {
|
|
} else {
|
|
|
// ToastUtil.showToast('保存失败' + error?.toString())
|
|
// ToastUtil.showToast('保存失败' + error?.toString())
|
|
@@ -7118,6 +7124,91 @@ export struct LocalMusic {
|
|
|
this.discStr = ''
|
|
this.discStr = ''
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ initEditFields(item?: VideoItem) {
|
|
|
|
|
+ if (!item) {
|
|
|
|
|
+ this.setEditStrEmpty()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.imagePathStr = ''
|
|
|
|
|
+ this.titleStr = item.name ?? ''
|
|
|
|
|
+ this.artistStr = item.artist ?? ''
|
|
|
|
|
+ this.ablumStr = item.album ?? ''
|
|
|
|
|
+ this.genreStr = item.genre ?? ''
|
|
|
|
|
+ this.yearStr = item.year ?? ''
|
|
|
|
|
+ this.trackStr = item.track ?? ''
|
|
|
|
|
+ this.albumArtistStr = item.ALBUMARTIST ?? ''
|
|
|
|
|
+ this.composerStr = item.COMPOSER ?? ''
|
|
|
|
|
+ this.lyricistStr = item.LYRICIST ?? ''
|
|
|
|
|
+ this.commentStr = item.COMMENT ?? ''
|
|
|
|
|
+ this.discStr = item.disc ?? ''
|
|
|
|
|
+ this.lyricConStr = item.lyricContent ?? ''
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private syncEditedFields(target?: VideoItem) {
|
|
|
|
|
+ if (!target) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ target.name = this.titleStr
|
|
|
|
|
+ target.artist = this.artistStr
|
|
|
|
|
+ target.album = this.ablumStr
|
|
|
|
|
+ target.lyricContent = this.lyricConStr
|
|
|
|
|
+ target.year = this.yearStr
|
|
|
|
|
+ target.genre = this.genreStr
|
|
|
|
|
+ target.track = this.trackStr
|
|
|
|
|
+ target.ALBUMARTIST = this.albumArtistStr
|
|
|
|
|
+ target.COMPOSER = this.composerStr
|
|
|
|
|
+ target.LYRICIST = this.lyricistStr
|
|
|
|
|
+ target.COMMENT = this.commentStr
|
|
|
|
|
+ target.disc = this.discStr
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private replaceItemInList(list: Array<VideoItem> | undefined, filePath: string,
|
|
|
|
|
+ apply?: (next: Array<VideoItem>) => void) {
|
|
|
|
|
+ if (!list || ArrayUtil.isEmpty(list)) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const index = list.findIndex((video: VideoItem) => video.filePath === filePath)
|
|
|
|
|
+ if (index < 0) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const nextList = [...list]
|
|
|
|
|
+ this.syncEditedFields(nextList[index])
|
|
|
|
|
+ apply?.(nextList)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private syncListsAfterEdit(filePath: string) {
|
|
|
|
|
+ this.replaceItemInList(this.videoLocalList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.videoLocalList = next
|
|
|
|
|
+ this.dataSource.pushArrayData(next)
|
|
|
|
|
+ })
|
|
|
|
|
+ this.replaceItemInList(this.songList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.songList = next
|
|
|
|
|
+ this.sonDataSource.pushArrayData(next)
|
|
|
|
|
+ })
|
|
|
|
|
+ this.replaceItemInList(this.favList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.favList = next
|
|
|
|
|
+ })
|
|
|
|
|
+ this.replaceItemInList(this.historyList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.historyList = next
|
|
|
|
|
+ })
|
|
|
|
|
+ this.replaceItemInList(this.currentSongList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.currentSongList = next
|
|
|
|
|
+ })
|
|
|
|
|
+ this.replaceItemInList(this.mediaKuList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.mediaKuList = next
|
|
|
|
|
+ })
|
|
|
|
|
+ this.replaceItemInList(this.filteredList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.filteredList = next
|
|
|
|
|
+ })
|
|
|
|
|
+ this.replaceItemInList(this.artistList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.artistList = next
|
|
|
|
|
+ })
|
|
|
|
|
+ this.replaceItemInList(this.albumList, filePath, (next: Array<VideoItem>) => {
|
|
|
|
|
+ this.albumList = next
|
|
|
|
|
+ })
|
|
|
|
|
+ this.listRefreshKey++
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Builder
|
|
@Builder
|
|
|
detailSheet(item:VideoItem) {
|
|
detailSheet(item:VideoItem) {
|
|
|
Scroll() {
|
|
Scroll() {
|
|
@@ -7979,7 +8070,7 @@ export struct LocalMusic {
|
|
|
.onClick(() => {
|
|
.onClick(() => {
|
|
|
this.doPlay(item, index, true)
|
|
this.doPlay(item, index, true)
|
|
|
})
|
|
})
|
|
|
- }, (item: VideoItem) => item.filePath)
|
|
|
|
|
|
|
+ }, (item: VideoItem) => item.filePath + '_' + this.listRefreshKey)
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.height('100%')
|
|
.height('100%')
|
|
@@ -9520,8 +9611,11 @@ export struct LocalMusic {
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
.backgroundColor(Color.Transparent)
|
|
.backgroundColor(Color.Transparent)
|
|
|
.onClick(async () => {
|
|
.onClick(async () => {
|
|
|
- this.setEditStrEmpty()
|
|
|
|
|
|
|
+ this.initEditFields(this.currentSong)
|
|
|
this.tempLyricContent = this.lyricContent
|
|
this.tempLyricContent = this.lyricContent
|
|
|
|
|
+ if (StrUtil.isNotEmpty(this.tempLyricContent)) {
|
|
|
|
|
+ this.lyricConStr = this.tempLyricContent
|
|
|
|
|
+ }
|
|
|
this.isShowEdit = !this.isShowEdit;
|
|
this.isShowEdit = !this.isShowEdit;
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -11546,8 +11640,11 @@ export struct LocalMusic {
|
|
|
this.isShowMoreView = false
|
|
this.isShowMoreView = false
|
|
|
break;
|
|
break;
|
|
|
case 15: //编辑标签
|
|
case 15: //编辑标签
|
|
|
- this.setEditStrEmpty()
|
|
|
|
|
|
|
+ this.initEditFields(this.currentSong)
|
|
|
this.tempLyricContent = this.lyricContent
|
|
this.tempLyricContent = this.lyricContent
|
|
|
|
|
+ if (StrUtil.isNotEmpty(this.tempLyricContent)) {
|
|
|
|
|
+ this.lyricConStr = this.tempLyricContent
|
|
|
|
|
+ }
|
|
|
this.isShowEdit = !this.isShowEdit;
|
|
this.isShowEdit = !this.isShowEdit;
|
|
|
break;
|
|
break;
|
|
|
case 16: //悬浮歌词
|
|
case 16: //悬浮歌词
|
|
@@ -14324,13 +14421,16 @@ async function updateInfoDb(
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- return table.updateMediaInfo(filePath, titleStr, artistStr, albumStr, lyricConStr,
|
|
|
|
|
- yearStr, genreStr, trackStr, albumArtistStr, composerStr, lyricistStr, commentStr, discStr,
|
|
|
|
|
- (success: boolean, error?: string) => {
|
|
|
|
|
- if (success) {
|
|
|
|
|
- console.log("onecold 编辑信息成功,数据库已同步");
|
|
|
|
|
- } else {
|
|
|
|
|
- console.error("onecold 编辑信息数据库失败原因: " + error);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ return await new Promise<boolean>((resolve) => {
|
|
|
|
|
+ table.updateMediaInfo(filePath, titleStr, artistStr, albumStr, lyricConStr,
|
|
|
|
|
+ yearStr, genreStr, trackStr, albumArtistStr, composerStr, lyricistStr, commentStr, discStr,
|
|
|
|
|
+ (success: boolean, error?: string) => {
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ console.log("onecold 编辑信息成功,数据库已同步");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.error("onecold 编辑信息数据库失败原因: " + error);
|
|
|
|
|
+ }
|
|
|
|
|
+ resolve(success);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|