mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-07-08 02:17:30 +08:00
fix(download): 单独下载歌词的文件名跟随文件名格式设置
downloadLyric 改用 set.downloadNameFormat 模板拼接文件名,与歌曲下载行为 一致(此前硬编码'歌曲名 - 歌手');多歌手连接符与歌曲下载统一为'、'。 Closes #655
This commit is contained in:
@@ -147,10 +147,18 @@ export const useDownload = () => {
|
||||
lrcContent = mergeLrcWithTranslation(lyricData.lrc.lyric, lyricData.tlyric.lyric);
|
||||
}
|
||||
|
||||
const artistNames = (song.ar || song.song?.artists)
|
||||
?.map((a: { name: string }) => a.name)
|
||||
.join(',');
|
||||
const filename = `${song.name} - ${artistNames}`;
|
||||
// 与歌曲下载一致:使用设置中的文件名格式模板拼接歌词文件名(#655)
|
||||
const nameFormat =
|
||||
(ipcRenderer?.sendSync('get-store-value', 'set.downloadNameFormat') as string) ||
|
||||
'{songName} - {artistName}';
|
||||
const artistNames =
|
||||
(song.ar || song.song?.artists)?.map((a: { name: string }) => a.name).join('、') ||
|
||||
'未知艺术家';
|
||||
const albumName = song.al?.name || '未知专辑';
|
||||
const filename = nameFormat
|
||||
.replace(/\{songName\}/g, song.name || '')
|
||||
.replace(/\{artistName\}/g, artistNames)
|
||||
.replace(/\{albumName\}/g, albumName);
|
||||
|
||||
const result = await ipcRenderer?.invoke('save-lyric-file', { filename, lrcContent });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user