分离歌词与歌曲列表信息的保存
parent
b8250b67c9
commit
4918db9cb1
|
@ -37,6 +37,7 @@ module.exports = {
|
|||
loader: 'eslint-loader',
|
||||
options: {
|
||||
formatter: require('eslint-formatter-friendly'),
|
||||
emitWarning: isDev,
|
||||
},
|
||||
},
|
||||
exclude: /node_modules/,
|
||||
|
|
|
@ -37,6 +37,7 @@ module.exports = {
|
|||
loader: 'eslint-loader',
|
||||
options: {
|
||||
formatter: require('eslint-formatter-friendly'),
|
||||
emitWarning: isDev,
|
||||
},
|
||||
},
|
||||
exclude: /node_modules/,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
- 程序启动时对数据文件做读取校验,数据出现损坏时自动备份损坏的数据,若出现数据读取错误的弹窗并出现我的列表丢失时可到GitHub或加群反馈
|
||||
- 当设置-代理启用,但主机地址为空的时,将不再使用代理配置进行网络连接,并且在离开设置界面时自动禁用代理
|
||||
- 优化歌曲自动换源匹配
|
||||
- 分离歌词与歌曲列表信息的保存,以减小列表列表文件损坏的几率
|
||||
|
||||
### 修复
|
||||
|
||||
|
|
|
@ -59,6 +59,10 @@ const names = {
|
|||
request_user_api_cancel: 'request_user_api_cancel',
|
||||
get_user_api_status: 'get_user_api_status',
|
||||
user_api_status: 'user_api_status',
|
||||
|
||||
get_lyric: 'get_lyric',
|
||||
save_lyric: 'save_lyric',
|
||||
clear_lyric: 'clear_lyric',
|
||||
},
|
||||
winLyric: {
|
||||
close: 'close',
|
||||
|
|
|
@ -17,6 +17,7 @@ require('./getDataPath')
|
|||
require('./showDialog')
|
||||
require('./playList')
|
||||
require('./data')
|
||||
require('./lyric')
|
||||
|
||||
require('./kw_decodeLyric')
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
const { mainOn, NAMES: { mainWindow: ipcMainWindowNames }, mainHandle } = require('../../common/ipc')
|
||||
const getStore = require('@common/store')
|
||||
|
||||
|
||||
mainHandle(ipcMainWindowNames.get_lyric, async(event, id) => getStore('lyrics').get(id) || {})
|
||||
|
||||
|
||||
mainOn(ipcMainWindowNames.save_lyric, (event, { id, lyrics }) => getStore('lyrics').set(id, lyrics))
|
||||
|
||||
mainOn(ipcMainWindowNames.clear_lyric, () => getStore('lyrics').clear())
|
|
@ -646,10 +646,10 @@ export default {
|
|||
}
|
||||
},
|
||||
setLrc(targetSong) {
|
||||
this.getLrc(targetSong).then(() => {
|
||||
this.musicInfo.lrc = targetSong.lrc
|
||||
this.musicInfo.tlrc = targetSong.tlrc
|
||||
this.musicInfo.lxlrc = targetSong.lxlrc
|
||||
this.getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => {
|
||||
this.musicInfo.lrc = lyric
|
||||
this.musicInfo.tlrc = tlyric
|
||||
this.musicInfo.lxlrc = lxlyric
|
||||
}).catch(() => {
|
||||
this.status = this.statusText = this.$t('core.player.lyric_error')
|
||||
}).finally(() => {
|
||||
|
|
|
@ -3,7 +3,7 @@ import fs from 'fs'
|
|||
import path from 'path'
|
||||
import music from '../../utils/music'
|
||||
import { getMusicType } from '../../utils/music/utils'
|
||||
import { setMeta, saveLrc } from '../../utils'
|
||||
import { setMeta, saveLrc, getLyric, setLyric } from '../../utils'
|
||||
|
||||
// state
|
||||
const state = {
|
||||
|
@ -179,12 +179,17 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
|
|||
})
|
||||
: Promise.resolve(),
|
||||
isEmbedLyric
|
||||
? downloadInfo.musicInfo.lrc
|
||||
? Promise.resolve({ lyric: downloadInfo.musicInfo.lrc, tlyric: downloadInfo.musicInfo.tlrc || '' })
|
||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise.catch(err => {
|
||||
console.log(err)
|
||||
return null
|
||||
})
|
||||
? getLyric(downloadInfo.musicInfo).then(lrcInfo => {
|
||||
return lrcInfo.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 }
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
return null
|
||||
})
|
||||
})
|
||||
: Promise.resolve(),
|
||||
]
|
||||
Promise.all(tasks).then(([imgUrl, lyrics = {}]) => {
|
||||
|
@ -205,9 +210,14 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
|
|||
* @param {*} filePath
|
||||
*/
|
||||
const downloadLyric = (downloadInfo, filePath) => {
|
||||
const promise = downloadInfo.musicInfo.lrc
|
||||
? Promise.resolve({ lyric: downloadInfo.musicInfo.lrc, tlyric: downloadInfo.musicInfo.tlrc || '' })
|
||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise
|
||||
const promise = getLyric(downloadInfo.musicInfo).then(lrcInfo => {
|
||||
return lrcInfo.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)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import musicSdk from '../../utils/music'
|
||||
import { clearLyric } from '../../utils'
|
||||
|
||||
let allList = {}
|
||||
window.allList = allList
|
||||
|
@ -207,9 +208,12 @@ const mutations = {
|
|||
if (item.typeUrl['320k']) delete item.typeUrl['320k']
|
||||
if (item.typeUrl.flac) delete item.typeUrl.flac
|
||||
if (item.typeUrl.wav) delete item.typeUrl.wav
|
||||
if (item.lxlrc) item.lxlrc = null
|
||||
if (item.lrc) item.lrc = null
|
||||
if (item.tlrc) item.tlrc = null
|
||||
clearLyric()
|
||||
|
||||
// v1.8.2以前的Lyric
|
||||
if (item.lxlrc) delete item.lxlrc
|
||||
if (item.lrc) delete item.lrc
|
||||
if (item.tlrc) delete item.tlrc
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import path from 'path'
|
||||
import music from '../../utils/music'
|
||||
import { getRandom, checkPath } from '../../utils'
|
||||
import { getRandom, checkPath, getLyric as getStoreLyric, setLyric } from '../../utils'
|
||||
|
||||
// state
|
||||
const state = {
|
||||
|
@ -182,26 +182,26 @@ const actions = {
|
|||
return Promise.reject(err)
|
||||
})
|
||||
},
|
||||
getLrc({ commit, state }, musicInfo) {
|
||||
async getLrc({ commit, state }, musicInfo) {
|
||||
const lrcInfo = await getStoreLyric(musicInfo)
|
||||
// if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp()
|
||||
if (musicInfo.lrc && musicInfo.tlrc != null) {
|
||||
if (musicInfo.lrc.startsWith('\ufeff[id:$00000000]')) {
|
||||
let str = musicInfo.lrc.replace('\ufeff[id:$00000000]\n', '')
|
||||
commit('setLrc', { musicInfo, lyric: str, tlyric: musicInfo.tlrc, lxlyric: musicInfo.tlrc })
|
||||
} else if (musicInfo.lrc.startsWith('[id:$00000000]')) {
|
||||
let str = musicInfo.lrc.replace('[id:$00000000]\n', '')
|
||||
commit('setLrc', { musicInfo, lyric: str, tlyric: musicInfo.tlrc, lxlyric: musicInfo.tlrc })
|
||||
}
|
||||
if (lrcInfo.lyric && lrcInfo.tlyric != null) {
|
||||
// if (musicInfo.lrc.startsWith('\ufeff[id:$00000000]')) {
|
||||
// let str = musicInfo.lrc.replace('\ufeff[id:$00000000]\n', '')
|
||||
// commit('setLrc', { musicInfo, lyric: str, tlyric: musicInfo.tlrc, lxlyric: musicInfo.tlrc })
|
||||
// } else if (musicInfo.lrc.startsWith('[id:$00000000]')) {
|
||||
// let str = musicInfo.lrc.replace('[id:$00000000]\n', '')
|
||||
// commit('setLrc', { musicInfo, lyric: str, tlyric: musicInfo.tlrc, lxlyric: musicInfo.tlrc })
|
||||
// }
|
||||
|
||||
if ((musicInfo.lxlrc == null && musicInfo.source != 'kg') || musicInfo.lxlrc != null) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
if ((lrcInfo.lxlyric == null && musicInfo.source != 'kg') || lrcInfo.lxlyric != null) return lrcInfo
|
||||
}
|
||||
|
||||
// lrcRequest = music[musicInfo.source].getLyric(musicInfo)
|
||||
return getLyric.call(this, musicInfo).then(({ lyric, tlyric, lxlyric }) => {
|
||||
// lrcRequest = null
|
||||
commit('setLrc', { musicInfo, lyric, tlyric, lxlyric })
|
||||
return { lyric, tlyric, lxlyric }
|
||||
}).catch(err => {
|
||||
// lrcRequest = null
|
||||
return Promise.reject(err)
|
||||
|
@ -338,6 +338,11 @@ const mutations = {
|
|||
datas.musicInfo.lrc = datas.lyric
|
||||
datas.musicInfo.tlrc = datas.tlyric
|
||||
datas.musicInfo.lxlrc = datas.lxlyric
|
||||
setLyric(datas.musicInfo, {
|
||||
lyric: datas.lyric,
|
||||
tlyric: datas.tlyric,
|
||||
lxlyric: datas.lxlyric,
|
||||
})
|
||||
},
|
||||
setList(state, { list, index }) {
|
||||
state.playMusicInfo = {
|
||||
|
|
|
@ -407,3 +407,10 @@ export const parseUrlParams = str => {
|
|||
}
|
||||
return params
|
||||
}
|
||||
|
||||
export const getLyric = musicInfo => rendererInvoke(NAMES.mainWindow.get_lyric, `${musicInfo.source}_${musicInfo.songmid}`)
|
||||
export const setLyric = (musicInfo, { lyric, tlyric, lxlyric }) => rendererSend(NAMES.mainWindow.save_lyric, {
|
||||
id: `${musicInfo.source}_${musicInfo.songmid}`,
|
||||
lyrics: { lyric, tlyric, lxlyric },
|
||||
})
|
||||
export const clearLyric = () => rendererSend(NAMES.mainWindow.clear_lyric)
|
||||
|
|
Loading…
Reference in New Issue