新增将播放与下载的歌词转换为繁体中文选项

This commit is contained in:
lyswhut
2021-12-06 16:07:12 +08:00
parent ec3a0e08c3
commit b350f133b0
8 changed files with 36 additions and 11 deletions
@@ -130,7 +130,7 @@ export default ({ setting }) => {
getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => {
if (targetSong.songmid !== musicInfo.songmid) return
return (
global.i18n.locale == 'zh-tw'
setting.value.player.isS2t
? Promise.all([
lyric ? langS2T(lyric) : Promise.resolve(''),
tlyric ? langS2T(tlyric) : Promise.resolve(''),
+23 -9
View File
@@ -177,7 +177,7 @@ const handleGetLyric = function(musicInfo, retryedSource = [], originMusic) {
})
}
const getLyric = function(musicInfo, isUseOtherSource) {
const getLyric = function(musicInfo, isUseOtherSource, isS2t) {
return getLyricFromStorage(musicInfo).then(lrcInfo => {
return (
lrcInfo.lyric
@@ -194,8 +194,7 @@ const getLyric = function(musicInfo, isUseOtherSource) {
return null
})
).then(lrcs => {
if (!lrcs) return lrcs
if (global.i18n.locale != 'zh-tw') return lrcs
if (!lrcs || !isS2t) return lrcs
return rendererInvoke(NAMES.mainWindow.lang_s2t, Buffer.from(lrcs.lyric).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString()).then(lyric => {
lrcs.lyric = lyric
return lrcs
@@ -213,7 +212,7 @@ const fixKgLyric = lrc => /\[00:\d\d:\d\d.\d+\]/.test(lrc) ? lrc.replace(/(?:\[0
* @param {*} filePath
* @param {*} isEmbedPic // 是否嵌入图片
*/
const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic, isEmbedLyric) {
const saveMeta = function({ downloadInfo, filePath, isUseOtherSource, isEmbedPic, isEmbedLyric, isS2t }) {
if (downloadInfo.metadata.type === 'ape') return
const tasks = [
isEmbedPic
@@ -229,7 +228,7 @@ const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic,
})
: Promise.resolve(),
isEmbedLyric
? getLyric.call(this, downloadInfo.metadata.musicInfo, isUseOtherSource)
? getLyric.call(this, downloadInfo.metadata.musicInfo, isUseOtherSource, isS2t)
: Promise.resolve(),
]
Promise.all(tasks).then(([imgUrl, lyrics = {}]) => {
@@ -249,8 +248,8 @@ const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic,
* @param {*} downloadInfo
* @param {*} filePath
*/
const downloadLyric = function(downloadInfo, isUseOtherSource, filePath, lrcFormat) {
getLyric.call(this, downloadInfo.metadata.musicInfo, isUseOtherSource).then(lrcs => {
const downloadLyric = function({ downloadInfo, isUseOtherSource, filePath, lrcFormat, isS2t }) {
getLyric.call(this, downloadInfo.metadata.musicInfo, isUseOtherSource, isS2t).then(lrcs => {
if (lrcs?.lyric) {
lrcs.lyric = fixKgLyric(lrcs.lyric)
saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric, lrcFormat)
@@ -408,8 +407,23 @@ const actions = {
commit('onCompleted', downloadInfo)
dispatch('startTask')
saveMeta.call(_this, downloadInfo, downloadInfo.metadata.filePath, rootState.setting.download.isUseOtherSource, rootState.setting.download.isEmbedPic, rootState.setting.download.isEmbedLyric)
if (rootState.setting.download.isDownloadLrc) downloadLyric.call(_this, downloadInfo, rootState.setting.download.isUseOtherSource, downloadInfo.metadata.filePath, rootState.setting.download.lrcFormat)
saveMeta.call(_this, {
downloadInfo,
filePath: downloadInfo.metadata.filePath,
isUseOtherSource: rootState.setting.download.isUseOtherSource,
isEmbedPic: rootState.setting.download.isEmbedPic,
isEmbedLyric: rootState.setting.download.isEmbedLyric,
isS2t: rootState.setting.player.isS2t,
})
if (rootState.setting.download.isDownloadLrc) {
downloadLyric.call(_this, {
downloadInfo,
isUseOtherSource: rootState.setting.download.isUseOtherSource,
filePath: downloadInfo.metadata.filePath,
lrcFormat: rootState.setting.download.lrcFormat,
isS2t: rootState.setting.player.isS2t,
})
}
console.log('on complate')
},
onError(err) {
@@ -5,6 +5,8 @@ dd
base-checkbox(id="setting_player_save_play_time" v-model="currentStting.player.isSavePlayTime" :label="$t('setting__play_save_play_time')")
.gap-top
base-checkbox(id="setting_player_lyric_transition" v-model="currentStting.player.isShowLyricTranslation" :label="$t('setting__play_lyric_transition')")
.gap-top
base-checkbox(id="setting_player_lyric_s2t" v-model="currentStting.player.isS2t" :label="$t('setting__play_lyric_s2t')")
.gap-top
base-checkbox(id="setting_player_lyric_play_lxlrc" v-model="currentStting.player.isPlayLxlrc" :label="$t('setting__play_lyric_lxlrc')")
.gap-top