修复音乐名称和歌手信息格式化(#2733)
This commit is contained in:
@@ -148,3 +148,7 @@ export const clipFileNameLength = (name: string) => {
|
||||
return name.length > MAX_FILE_NAME_LENGTH ? name.substring(0, MAX_FILE_NAME_LENGTH) : name
|
||||
}
|
||||
|
||||
export const formatMusicName = (format: string, name: string, singer: string) => {
|
||||
// return format.replace(/歌名|歌手/g, match => match === '歌名' ? name : singer)
|
||||
return format.replace('歌手', singer).replace('歌名', name)
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ import {
|
||||
import { appSetting } from '@renderer/store/setting'
|
||||
import { togglePlay, playNext, playPrev } from '@renderer/core/player'
|
||||
import { LIST_IDS } from '@common/constants'
|
||||
import { formatMusicName } from '@renderer/utils'
|
||||
|
||||
export default {
|
||||
name: 'CorePlayBar',
|
||||
@@ -112,7 +113,7 @@ export default {
|
||||
|
||||
const title = computed(() => {
|
||||
return musicInfo.name
|
||||
? appSetting['download.fileName'].replace('歌名', musicInfo.name).replace('歌手', musicInfo.singer)
|
||||
? formatMusicName(appSetting['download.fileName'], musicInfo.name, musicInfo.singer)
|
||||
: ''
|
||||
})
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ import {
|
||||
import { appSetting } from '@renderer/store/setting'
|
||||
import { togglePlay, playNext, playPrev } from '@renderer/core/player'
|
||||
import { LIST_IDS } from '@common/constants'
|
||||
import { formatMusicName } from '@renderer/utils'
|
||||
|
||||
export default {
|
||||
name: 'CorePlayBar',
|
||||
@@ -112,7 +113,7 @@ export default {
|
||||
|
||||
const title = computed(() => {
|
||||
return musicInfo.name
|
||||
? appSetting['download.fileName'].replace('歌名', musicInfo.name).replace('歌手', musicInfo.singer)
|
||||
? formatMusicName(appSetting['download.fileName'], musicInfo.name, musicInfo.singer)
|
||||
: ''
|
||||
})
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ import {
|
||||
import { appSetting } from '@renderer/store/setting'
|
||||
import { togglePlay, playNext, playPrev } from '@renderer/core/player'
|
||||
import { LIST_IDS } from '@common/constants'
|
||||
import { formatMusicName } from '@renderer/utils'
|
||||
|
||||
export default {
|
||||
name: 'CorePlayBar',
|
||||
@@ -114,7 +115,7 @@ export default {
|
||||
|
||||
const title = computed(() => {
|
||||
return musicInfo.name
|
||||
? appSetting['download.fileName'].replace('歌名', musicInfo.name).replace('歌手', musicInfo.singer)
|
||||
? formatMusicName(appSetting['download.fileName'], musicInfo.name, musicInfo.singer)
|
||||
: ''
|
||||
})
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ import useTaskActions from './useTaskActions'
|
||||
import useMusicAdd from './useMusicAdd'
|
||||
import { downloadStatus } from '@renderer/store/download/state'
|
||||
import { appSetting } from '@renderer/store/setting'
|
||||
import { formatMusicName } from '@renderer/utils'
|
||||
|
||||
export default {
|
||||
name: 'Download',
|
||||
@@ -203,7 +204,7 @@ export default {
|
||||
}
|
||||
|
||||
const getName = (downloadInfo) => {
|
||||
return appSetting['download.fileName'].replace('歌名', downloadInfo.metadata.musicInfo.name).replace('歌手', downloadInfo.metadata.musicInfo.singer)
|
||||
return formatMusicName(appSetting['download.fileName'], downloadInfo.metadata.musicInfo.name, downloadInfo.metadata.musicInfo.singer)
|
||||
}
|
||||
const getTypeName = (quality) => {
|
||||
return quality == 'flac24bit' ? 'FLAC Hires' : quality?.toUpperCase()
|
||||
|
||||
@@ -5,7 +5,7 @@ import { dialog } from '@renderer/plugins/Dialog'
|
||||
import { useI18n } from '@renderer/plugins/i18n'
|
||||
import { removeListMusics } from '@renderer/store/list/action'
|
||||
import { appSetting } from '@renderer/store/setting'
|
||||
import { toOldMusicInfo } from '@renderer/utils/index'
|
||||
import { formatMusicName, toOldMusicInfo } from '@renderer/utils/index'
|
||||
import { addDislikeInfo, hasDislike } from '@renderer/core/dislikeList'
|
||||
import { playNext } from '@renderer/core/player'
|
||||
import { playMusicInfo } from '@renderer/store/player/state'
|
||||
@@ -34,7 +34,7 @@ export default ({ props, list, selectedList, removeAllSelect }) => {
|
||||
|
||||
const handleCopyName = index => {
|
||||
const minfo = list.value[index]
|
||||
clipboardWriteText(appSetting['download.fileName'].replace('歌名', minfo.name).replace('歌手', minfo.singer))
|
||||
clipboardWriteText(formatMusicName(appSetting['download.fileName'], minfo.name, minfo.singer))
|
||||
}
|
||||
|
||||
const handleDislikeMusic = async(index) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { DOWNLOAD_STATUS, QUALITYS } from '@common/constants'
|
||||
import { filterFileName } from '@common/utils/common'
|
||||
import { buildLyrics } from './lrcTool'
|
||||
import fs from 'fs'
|
||||
import { clipFileNameLength, clipNameLength } from '@common/utils/tools'
|
||||
import { clipFileNameLength, clipNameLength, formatMusicName } from '@common/utils/tools'
|
||||
|
||||
/**
|
||||
* 保存歌词文件
|
||||
@@ -91,9 +91,7 @@ export const createDownloadInfo = (musicInfo: LX.Music.MusicInfoOnline, type: LX
|
||||
ext,
|
||||
filePath: '',
|
||||
listId,
|
||||
fileName: filterFileName(`${clipFileNameLength(fileName
|
||||
.replace('歌名', musicInfo.name)
|
||||
.replace('歌手', clipNameLength(musicInfo.singer)))}.${ext}`),
|
||||
fileName: filterFileName(`${clipFileNameLength(formatMusicName(fileName, musicInfo.name, clipNameLength(musicInfo.singer)))}.${ext}`),
|
||||
},
|
||||
}
|
||||
// downloadInfo.metadata.filePath = joinPath(savePath, downloadInfo.metadata.fileName)
|
||||
|
||||
Reference in New Issue
Block a user