新增歌词简体中文转繁体中文,当软件语言被设置为繁体中文后,播放歌曲的歌词也将自动转成繁体中文显示
parent
271d9ac13e
commit
97fdcaac51
|
@ -1,5 +1,10 @@
|
||||||
|
### 新增
|
||||||
|
|
||||||
|
- 新增歌词简体中文转繁体中文,当软件语言被设置为繁体中文后,播放歌曲的歌词也将自动转成繁体中文显示
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复mg排行榜无法加载的问题
|
- 修复mg排行榜无法加载的问题
|
||||||
- 修复点击播放详情页的进度条跳进度时会出现偏移的问题
|
- 修复点击播放详情页的进度条跳进度时会出现偏移的问题
|
||||||
- 修复在有提示信息的地方长按鼠标按键时提示信息会闪烁的问题
|
- 修复在有提示信息的地方长按鼠标按键时提示信息会闪烁的问题
|
||||||
|
- 修复下载歌曲时的歌词下载不尝试获取缓存歌词的问题
|
||||||
|
|
|
@ -33,6 +33,8 @@ const names = {
|
||||||
|
|
||||||
restart_window: 'restart_window',
|
restart_window: 'restart_window',
|
||||||
|
|
||||||
|
lang_s2t: 'lang_s2t',
|
||||||
|
|
||||||
handle_kw_decode_lyric: 'handle_kw_decode_lyric',
|
handle_kw_decode_lyric: 'handle_kw_decode_lyric',
|
||||||
get_lyric_info: 'get_lyric_info',
|
get_lyric_info: 'get_lyric_info',
|
||||||
set_lyric_info: 'set_lyric_info',
|
set_lyric_info: 'set_lyric_info',
|
||||||
|
@ -74,6 +76,7 @@ const names = {
|
||||||
sync_generate_code: 'sync_generate_code',
|
sync_generate_code: 'sync_generate_code',
|
||||||
sync_action_list: 'sync_action_list',
|
sync_action_list: 'sync_action_list',
|
||||||
sync_list: 'sync_list',
|
sync_list: 'sync_list',
|
||||||
|
|
||||||
},
|
},
|
||||||
winLyric: {
|
winLyric: {
|
||||||
close: 'close',
|
close: 'close',
|
||||||
|
|
|
@ -25,3 +25,5 @@ require('./kw_decodeLyric')
|
||||||
|
|
||||||
require('./userApi')
|
require('./userApi')
|
||||||
require('./sync')
|
require('./sync')
|
||||||
|
require('./s2t')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
const { mainHandle, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../common/ipc')
|
||||||
|
const { tranditionalize } = require('../utils/simplify-chinese-main')
|
||||||
|
|
||||||
|
|
||||||
|
mainHandle(ipcMainWindowNames.lang_s2t, async(event, textBase64) => {
|
||||||
|
if (!global.modules.mainWindow) throw new Error('mainWindow is undefined')
|
||||||
|
const text = tranditionalize(Buffer.from(textBase64, 'base64').toString())
|
||||||
|
return Buffer.from(text).toString('base64')
|
||||||
|
})
|
|
@ -0,0 +1,18 @@
|
||||||
|
todo.md
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
|
yarn-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
package-lock.json
|
||||||
|
tsconfig.tsbuildinfo
|
||||||
|
report.*.json
|
||||||
|
|
||||||
|
.eslintcache
|
||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
.yarn
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2021 Shigma
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,10 @@
|
||||||
|
# simplify-chinese
|
||||||
|
|
||||||
|
Convert chinese characters between simplified form and tranditional form / 汉字简繁体转换工具。
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { simplify, tranditionalize } = require('simplify-chinese')
|
||||||
|
|
||||||
|
console.log(simplify('窩窩頭')) // 窝窝头
|
||||||
|
console.log(tranditionalize('窝窝头')) // 窩窩頭
|
||||||
|
```
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,2 @@
|
||||||
|
export function simplify(source: string): string
|
||||||
|
export function tranditionalize(source: string): string
|
|
@ -0,0 +1,30 @@
|
||||||
|
const { simplified, traditional } = require('./chinese')
|
||||||
|
|
||||||
|
const stMap = new Map()
|
||||||
|
const tsMap = new Map()
|
||||||
|
|
||||||
|
simplified.split('').forEach((char, index) => {
|
||||||
|
stMap.set(char, traditional[index])
|
||||||
|
tsMap.set(traditional[index], char)
|
||||||
|
})
|
||||||
|
|
||||||
|
function simplify(source) {
|
||||||
|
let result = []
|
||||||
|
for (const char of source) {
|
||||||
|
result.push(tsMap.get(char) || char)
|
||||||
|
}
|
||||||
|
return result.join('')
|
||||||
|
}
|
||||||
|
|
||||||
|
function tranditionalize(source) {
|
||||||
|
let result = []
|
||||||
|
for (const char of source) {
|
||||||
|
result.push(stMap.get(char) || char)
|
||||||
|
}
|
||||||
|
return result.join('')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
simplify,
|
||||||
|
tranditionalize,
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "simplify-chinese",
|
||||||
|
"description": "Convert chinese characters between simplified form and tranditional form 汉字简繁体转换工具",
|
||||||
|
"version": "1.1.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"typings": "index.d.ts",
|
||||||
|
"repository": "https://github.com/koishijs/simplify-chinese.git",
|
||||||
|
"author": "Shigma <1700011071@pku.edu.cn>",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
|
@ -87,7 +87,7 @@ div(:class="$style.player")
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Lyric from '@renderer/utils/lyric-font-player'
|
import Lyric from '@renderer/utils/lyric-font-player'
|
||||||
import { rendererSend, rendererOn, NAMES } from '../../../common/ipc'
|
import { rendererSend, rendererOn, NAMES, rendererInvoke } from '../../../common/ipc'
|
||||||
import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, debounce, throttle, assertApiSupport } from '../../utils'
|
import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, debounce, throttle, assertApiSupport } from '../../utils'
|
||||||
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
||||||
import { requestMsg } from '../../utils/message'
|
import { requestMsg } from '../../utils/message'
|
||||||
|
@ -655,10 +655,27 @@ export default {
|
||||||
setLrc(targetSong) {
|
setLrc(targetSong) {
|
||||||
this.getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => {
|
this.getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => {
|
||||||
if (targetSong.songmid !== this.musicInfo.songmid) return
|
if (targetSong.songmid !== this.musicInfo.songmid) return
|
||||||
this.musicInfo.lrc = lyric
|
return (
|
||||||
this.musicInfo.tlrc = tlyric
|
global.i18n.locale == 'zh-tw'
|
||||||
this.musicInfo.lxlrc = lxlyric
|
? Promise.all([
|
||||||
}).catch(() => {
|
lyric
|
||||||
|
? rendererInvoke(NAMES.mainWindow.lang_s2t, Buffer.from(lyric).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString())
|
||||||
|
: Promise.resolve(''),
|
||||||
|
tlyric
|
||||||
|
? rendererInvoke(NAMES.mainWindow.lang_s2t, Buffer.from(tlyric).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString())
|
||||||
|
: Promise.resolve(''),
|
||||||
|
lxlyric
|
||||||
|
? rendererInvoke(NAMES.mainWindow.lang_s2t, Buffer.from(lxlyric).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString())
|
||||||
|
: Promise.resolve(''),
|
||||||
|
])
|
||||||
|
: Promise.resolve([lyric, tlyric, lxlyric])
|
||||||
|
).then(([lyric, tlyric, lxlyric]) => {
|
||||||
|
this.musicInfo.lrc = lyric
|
||||||
|
this.musicInfo.tlrc = tlyric
|
||||||
|
this.musicInfo.lxlrc = lxlyric
|
||||||
|
})
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err)
|
||||||
this.status = this.statusText = this.$t('core.player.lyric_error')
|
this.status = this.statusText = this.$t('core.player.lyric_error')
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.handleUpdateWinLyricInfo('lyric', { lrc: this.musicInfo.lrc, tlrc: this.musicInfo.tlrc, lxlrc: this.musicInfo.lxlrc })
|
this.handleUpdateWinLyricInfo('lyric', { lrc: this.musicInfo.lrc, tlrc: this.musicInfo.tlrc, lxlrc: this.musicInfo.lxlrc })
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
setMusicUrl,
|
setMusicUrl,
|
||||||
assertApiSupport,
|
assertApiSupport,
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
|
import { NAMES, rendererInvoke } from '@common/ipc'
|
||||||
|
|
||||||
window.downloadList = []
|
window.downloadList = []
|
||||||
// state
|
// state
|
||||||
|
@ -224,7 +225,8 @@ const getPic = function(musicInfo, retryedSource = [], originMusic) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const getLyric = function(musicInfo, retryedSource = [], originMusic) {
|
|
||||||
|
const handleGetLyric = function(musicInfo, retryedSource = [], originMusic) {
|
||||||
if (!originMusic) originMusic = musicInfo
|
if (!originMusic) originMusic = musicInfo
|
||||||
let reqPromise
|
let reqPromise
|
||||||
try {
|
try {
|
||||||
|
@ -248,6 +250,33 @@ const getLyric = function(musicInfo, retryedSource = [], originMusic) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getLyric = function(musicInfo, isUseOtherSource) {
|
||||||
|
return getLyricFromStorage(musicInfo).then(lrcInfo => {
|
||||||
|
return (
|
||||||
|
lrcInfo.lyric
|
||||||
|
? Promise.resolve({ lyric: lrcInfo.lyric, tlyric: lrcInfo.tlyric || '' })
|
||||||
|
: (
|
||||||
|
isUseOtherSource
|
||||||
|
? handleGetLyric.call(this, musicInfo)
|
||||||
|
: music[musicInfo.source].getLyric(musicInfo).promise
|
||||||
|
).then(({ lyric, tlyric, lxlyric }) => {
|
||||||
|
setLyric(musicInfo, { lyric, tlyric, lxlyric })
|
||||||
|
return { lyric, tlyric, lxlyric }
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err)
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
).then(lrcs => {
|
||||||
|
if (!lrcs) return lrcs
|
||||||
|
if (global.i18n.locale != 'zh-tw') 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
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 修复 1.1.x版本 酷狗源歌词格式
|
// 修复 1.1.x版本 酷狗源歌词格式
|
||||||
const fixKgLyric = lrc => /\[00:\d\d:\d\d.\d+\]/.test(lrc) ? lrc.replace(/(?:\[00:(\d\d:\d\d.\d+\]))/gm, '[$1') : lrc
|
const fixKgLyric = lrc => /\[00:\d\d:\d\d.\d+\]/.test(lrc) ? lrc.replace(/(?:\[00:(\d\d:\d\d.\d+\]))/gm, '[$1') : lrc
|
||||||
|
|
||||||
|
@ -273,21 +302,7 @@ const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic,
|
||||||
})
|
})
|
||||||
: Promise.resolve(),
|
: Promise.resolve(),
|
||||||
isEmbedLyric
|
isEmbedLyric
|
||||||
? getLyricFromStorage(downloadInfo.musicInfo).then(lrcInfo => {
|
? getLyric.call(this, downloadInfo.musicInfo, isUseOtherSource)
|
||||||
return lrcInfo.lyric
|
|
||||||
? Promise.resolve({ lyric: lrcInfo.lyric, tlyric: lrcInfo.tlyric || '' })
|
|
||||||
: (
|
|
||||||
isUseOtherSource
|
|
||||||
? getLyric.call(this, downloadInfo.musicInfo)
|
|
||||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise
|
|
||||||
).then(({ lyric, tlyric, lxlyric }) => {
|
|
||||||
setLyric(downloadInfo.musicInfo, { lyric, tlyric, lxlyric })
|
|
||||||
return { lyric, tlyric, lxlyric }
|
|
||||||
}).catch(err => {
|
|
||||||
console.log(err)
|
|
||||||
return null
|
|
||||||
})
|
|
||||||
})
|
|
||||||
: Promise.resolve(),
|
: Promise.resolve(),
|
||||||
]
|
]
|
||||||
Promise.all(tasks).then(([imgUrl, lyrics = {}]) => {
|
Promise.all(tasks).then(([imgUrl, lyrics = {}]) => {
|
||||||
|
@ -307,17 +322,9 @@ const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic,
|
||||||
* @param {*} downloadInfo
|
* @param {*} downloadInfo
|
||||||
* @param {*} filePath
|
* @param {*} filePath
|
||||||
*/
|
*/
|
||||||
const downloadLyric = (downloadInfo, filePath, lrcFormat) => {
|
const downloadLyric = function(downloadInfo, isUseOtherSource, filePath, lrcFormat) {
|
||||||
const promise = getLyric(downloadInfo.musicInfo).then(lrcInfo => {
|
getLyric.call(this, downloadInfo.musicInfo, isUseOtherSource).then(lrcs => {
|
||||||
return lrcInfo.lyric
|
if (lrcs?.lyric) {
|
||||||
? Promise.resolve({ lyric: lrcInfo.lyric, tlyric: lrcInfo.tlyric || '' })
|
|
||||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise.then(({ lyric, tlyric, lxlyric }) => {
|
|
||||||
setLyric(downloadInfo.musicInfo, { lyric, tlyric, lxlyric })
|
|
||||||
return { lyric, tlyric, lxlyric }
|
|
||||||
})
|
|
||||||
})
|
|
||||||
promise.then(lrcs => {
|
|
||||||
if (lrcs.lyric) {
|
|
||||||
lrcs.lyric = fixKgLyric(lrcs.lyric)
|
lrcs.lyric = fixKgLyric(lrcs.lyric)
|
||||||
saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric, lrcFormat)
|
saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric, lrcFormat)
|
||||||
}
|
}
|
||||||
|
@ -436,7 +443,7 @@ const actions = {
|
||||||
dispatch('startTask')
|
dispatch('startTask')
|
||||||
|
|
||||||
saveMeta.call(_this, downloadInfo, downloadInfo.filePath, rootState.setting.download.isUseOtherSource, rootState.setting.download.isEmbedPic, rootState.setting.download.isEmbedLyric)
|
saveMeta.call(_this, downloadInfo, downloadInfo.filePath, rootState.setting.download.isUseOtherSource, rootState.setting.download.isEmbedPic, rootState.setting.download.isEmbedLyric)
|
||||||
if (rootState.setting.download.isDownloadLrc) downloadLyric(downloadInfo, downloadInfo.filePath, rootState.setting.download.lrcFormat)
|
if (rootState.setting.download.isDownloadLrc) downloadLyric.call(_this, downloadInfo, rootState.setting.download.isUseOtherSource, downloadInfo.filePath, rootState.setting.download.lrcFormat)
|
||||||
console.log('on complate')
|
console.log('on complate')
|
||||||
},
|
},
|
||||||
onError(err) {
|
onError(err) {
|
||||||
|
|
Loading…
Reference in New Issue