新增`显示歌词翻译`设置,默认开启
parent
c15895ab45
commit
669c1fe490
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
- 在歌单详情界面新增播放当前歌单按钮、收藏歌单按钮
|
- 在歌单详情界面新增播放当前歌单按钮、收藏歌单按钮
|
||||||
- 新增`不允许将歌词窗口拖出主屏幕之外`的设置项,默认开启,在连接多个屏幕时想要拖动到其他屏幕时可关闭此设置
|
- 新增`不允许将歌词窗口拖出主屏幕之外`的设置项,默认开启,在连接多个屏幕时想要拖动到其他屏幕时可关闭此设置
|
||||||
|
- 新增`显示歌词翻译`设置,默认开启,仅支持某些平台,注:无论该设置是否开启,嵌入或下载歌词时都不会带上翻译
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ const os = require('os')
|
||||||
const { isMac } = require('./utils')
|
const { isMac } = require('./utils')
|
||||||
|
|
||||||
const defaultSetting = {
|
const defaultSetting = {
|
||||||
version: '1.0.35',
|
version: '1.0.36',
|
||||||
player: {
|
player: {
|
||||||
togglePlayMethod: 'listLoop',
|
togglePlayMethod: 'listLoop',
|
||||||
highQuality: false,
|
highQuality: false,
|
||||||
|
@ -12,6 +12,7 @@ const defaultSetting = {
|
||||||
isMute: false,
|
isMute: false,
|
||||||
mediaDeviceId: 'default',
|
mediaDeviceId: 'default',
|
||||||
isMediaDeviceRemovedStopPlay: false,
|
isMediaDeviceRemovedStopPlay: false,
|
||||||
|
isShowLyricTransition: true,
|
||||||
},
|
},
|
||||||
desktopLyric: {
|
desktopLyric: {
|
||||||
enable: false,
|
enable: false,
|
||||||
|
|
|
@ -13,6 +13,7 @@ const setLrcConfig = () => {
|
||||||
mainSend(global.modules.lyricWindow, ipcWinLyricNames.set_lyric_config, {
|
mainSend(global.modules.lyricWindow, ipcWinLyricNames.set_lyric_config, {
|
||||||
config: desktopLyric,
|
config: desktopLyric,
|
||||||
languageId: global.appSetting.langId,
|
languageId: global.appSetting.langId,
|
||||||
|
isShowLyricTransition: global.appSetting.player.isShowLyricTransition,
|
||||||
})
|
})
|
||||||
if (isLock != desktopLyric.isLock) {
|
if (isLock != desktopLyric.isLock) {
|
||||||
isLock = desktopLyric.isLock
|
isLock = desktopLyric.isLock
|
||||||
|
|
|
@ -24,7 +24,7 @@ mainOn(ipcWinLyricNames.set_lyric_config, (event, config) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
mainHandle(ipcWinLyricNames.get_lyric_config, async() => {
|
mainHandle(ipcWinLyricNames.get_lyric_config, async() => {
|
||||||
return { config: global.appSetting.desktopLyric, languageId: global.appSetting.langId }
|
return { config: global.appSetting.desktopLyric, languageId: global.appSetting.langId, isShowLyricTransition: global.appSetting.player.isShowLyricTransition }
|
||||||
})
|
})
|
||||||
|
|
||||||
mainOn(ipcWinLyricNames.set_win_bounds, (event, options) => {
|
mainOn(ipcWinLyricNames.set_win_bounds, (event, options) => {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
transition(enter-active-class="animated-fast fadeIn" leave-active-class="animated-fast fadeOut")
|
transition(enter-active-class="animated-fast fadeIn" leave-active-class="animated-fast fadeOut")
|
||||||
.control-bar(v-show="!lrcConfig.isLock")
|
.control-bar(v-show="!lrcConfig.isLock")
|
||||||
core-control-bar(:lrcConfig="lrcConfig" :themes="themeList")
|
core-control-bar(:lrcConfig="lrcConfig" :themes="themeList")
|
||||||
core-lyric(:lrcConfig="lrcConfig")
|
core-lyric(:lrcConfig="lrcConfig" :isShowLyricTransition="isShowLyricTransition")
|
||||||
div.resize-left(@mousedown.self="handleMouseDown('left', $event)")
|
div.resize-left(@mousedown.self="handleMouseDown('left', $event)")
|
||||||
div.resize-top(@mousedown.self="handleMouseDown('top', $event)")
|
div.resize-top(@mousedown.self="handleMouseDown('top', $event)")
|
||||||
div.resize-right(@mousedown.self="handleMouseDown('right', $event)")
|
div.resize-right(@mousedown.self="handleMouseDown('right', $event)")
|
||||||
|
@ -44,6 +44,7 @@ export default {
|
||||||
isZoomActiveLrc: true,
|
isZoomActiveLrc: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
isShowLyricTransition: true,
|
||||||
themeList: [
|
themeList: [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
|
@ -117,8 +118,10 @@ export default {
|
||||||
document.removeEventListener('mouseup', this.handleMouseUp)
|
document.removeEventListener('mouseup', this.handleMouseUp)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleUpdateConfig({ config, languageId }) {
|
handleUpdateConfig({ config, languageId, isShowLyricTransition }) {
|
||||||
|
console.log(isShowLyricTransition)
|
||||||
this.lrcConfig = config
|
this.lrcConfig = config
|
||||||
|
this.isShowLyricTransition = isShowLyricTransition
|
||||||
if (this.$i18n.locale !== languageId && languageId != null) this.$i18n.locale = languageId
|
if (this.$i18n.locale !== languageId && languageId != null) this.$i18n.locale = languageId
|
||||||
},
|
},
|
||||||
handleMouseDown(origin, event) {
|
handleMouseDown(origin, event) {
|
||||||
|
|
|
@ -27,6 +27,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
isShowLyricTransition: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -58,6 +62,10 @@ export default {
|
||||||
lyricLines: [],
|
lyricLines: [],
|
||||||
isSetedLines: false,
|
isSetedLines: false,
|
||||||
isPlay: false,
|
isPlay: false,
|
||||||
|
lyrics: {
|
||||||
|
lyric: '',
|
||||||
|
tlyric: '',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -112,6 +120,11 @@ export default {
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
|
isShowLyricTransition(n) {
|
||||||
|
console.log(n)
|
||||||
|
this.setLyric()
|
||||||
|
rendererSend(NAMES.winLyric.get_lyric_info, 'status')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
rendererOn(NAMES.winLyric.set_lyric_info, (event, data) => this.handleSetInfo(data))
|
rendererOn(NAMES.winLyric.set_lyric_info, (event, data) => this.handleSetInfo(data))
|
||||||
|
@ -144,7 +157,9 @@ export default {
|
||||||
// console.log(type, data)
|
// console.log(type, data)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'lyric':
|
case 'lyric':
|
||||||
window.lrc.setLyric(data)
|
this.lyrics.lyric = data.lrc
|
||||||
|
this.lyrics.tlyric = data.tlrc
|
||||||
|
this.setLyric()
|
||||||
break
|
break
|
||||||
case 'play':
|
case 'play':
|
||||||
this.isPlay = true
|
this.isPlay = true
|
||||||
|
@ -156,7 +171,9 @@ export default {
|
||||||
break
|
break
|
||||||
case 'info':
|
case 'info':
|
||||||
// console.log('info', data)
|
// console.log('info', data)
|
||||||
window.lrc.setLyric(data.lyric)
|
this.lyrics.lyric = data.lyric
|
||||||
|
this.lyrics.tlyric = data.tlyric
|
||||||
|
this.setLyric()
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.lyric.line = data.line
|
this.lyric.line = data.line
|
||||||
rendererSend(NAMES.winLyric.get_lyric_info, 'status')
|
rendererSend(NAMES.winLyric.get_lyric_info, 'status')
|
||||||
|
@ -261,6 +278,9 @@ export default {
|
||||||
close() {
|
close() {
|
||||||
rendererSend(NAMES.winLyric.close)
|
rendererSend(NAMES.winLyric.close)
|
||||||
},
|
},
|
||||||
|
setLyric() {
|
||||||
|
window.lrc.setLyric((this.isShowLyricTransition && this.lyrics.tlyric ? this.lyrics.tlyric + '\n' : '') + this.lyrics.lyric)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -153,6 +153,7 @@ export default {
|
||||||
name: this.musicInfo.name,
|
name: this.musicInfo.name,
|
||||||
album: this.musicInfo.album,
|
album: this.musicInfo.album,
|
||||||
lyric: this.musicInfo.lrc,
|
lyric: this.musicInfo.lrc,
|
||||||
|
tlyric: this.musicInfo.tlrc,
|
||||||
isPlay: this.isPlay,
|
isPlay: this.isPlay,
|
||||||
line: this.lyric.line,
|
line: this.lyric.line,
|
||||||
played_time: audio.currentTime * 1000,
|
played_time: audio.currentTime * 1000,
|
||||||
|
@ -203,6 +204,9 @@ export default {
|
||||||
'setting.player.mediaDeviceId'(n) {
|
'setting.player.mediaDeviceId'(n) {
|
||||||
this.setMediaDevice()
|
this.setMediaDevice()
|
||||||
},
|
},
|
||||||
|
'setting.player.isShowLyricTransition'() {
|
||||||
|
this.setLyric()
|
||||||
|
},
|
||||||
async list(n, o) {
|
async list(n, o) {
|
||||||
if (n === o && this.musicInfo.songmid) {
|
if (n === o && this.musicInfo.songmid) {
|
||||||
let index = this.listId == 'download'
|
let index = this.listId == 'download'
|
||||||
|
@ -612,24 +616,22 @@ export default {
|
||||||
},
|
},
|
||||||
setLrc(targetSong) {
|
setLrc(targetSong) {
|
||||||
this.musicInfo.lrc = targetSong.lrc
|
this.musicInfo.lrc = targetSong.lrc
|
||||||
|
this.musicInfo.tlrc = targetSong.tlrc
|
||||||
|
|
||||||
let lrcP = this.musicInfo.lrc
|
let lrcP = this.musicInfo.lrc && this.musicInfo.tlrc != null
|
||||||
? Promise.resolve()
|
? Promise.resolve()
|
||||||
: this.getLrc(targetSong).then(() => {
|
: this.getLrc(targetSong).then(() => {
|
||||||
this.musicInfo.lrc = targetSong.lrc
|
this.musicInfo.lrc = targetSong.lrc
|
||||||
|
this.musicInfo.tlrc = targetSong.tlrc
|
||||||
})
|
})
|
||||||
|
|
||||||
lrcP
|
lrcP
|
||||||
.then(() => {
|
.then(() => {
|
||||||
window.lrc.setLyric(this.musicInfo.lrc)
|
this.setLyric()
|
||||||
this.handleUpdateWinLyricInfo('lyric', this.musicInfo.lrc)
|
this.handleUpdateWinLyricInfo('lyric', { lrc: this.musicInfo.lrc, tlrc: this.musicInfo.tlrc })
|
||||||
if (this.isPlay && (this.musicInfo.url || this.listId == 'download')) {
|
|
||||||
window.lrc.play(audio.currentTime * 1000)
|
|
||||||
this.handleUpdateWinLyricInfo('play', audio.currentTime * 1000)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.handleUpdateWinLyricInfo('lyric', this.musicInfo.lrc)
|
this.handleUpdateWinLyricInfo('lyric', { lrc: this.musicInfo.lrc, tlrc: this.musicInfo.tlrc })
|
||||||
this.status = this.statusText = this.$t('core.player.lyric_error')
|
this.status = this.statusText = this.$t('core.player.lyric_error')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -818,6 +820,13 @@ export default {
|
||||||
info,
|
info,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
setLyric() {
|
||||||
|
window.lrc.setLyric((this.setting.player.isShowLyricTransition && this.musicInfo.tlrc ? this.musicInfo.tlrc + '\n' : '') + this.musicInfo.lrc)
|
||||||
|
if (this.isPlay && (this.musicInfo.url || this.listId == 'download')) {
|
||||||
|
window.lrc.play(audio.currentTime * 1000)
|
||||||
|
this.handleUpdateWinLyricInfo('play', audio.currentTime * 1000)
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
"play_toggle_random": "Playlist shuffle",
|
"play_toggle_random": "Playlist shuffle",
|
||||||
"play_toggle_list": "Play in order",
|
"play_toggle_list": "Play in order",
|
||||||
"play_toggle_single_loop": "Single repeat",
|
"play_toggle_single_loop": "Single repeat",
|
||||||
|
"play_lyric_transition": "Show lyrics translation",
|
||||||
"play_quality_title": "The 320k quality is preferred for playing",
|
"play_quality_title": "The 320k quality is preferred for playing",
|
||||||
"play_quality": "Prefer High Quality 320k",
|
"play_quality": "Prefer High Quality 320k",
|
||||||
"play_task_bar_title": "Show playing progress on the taskbar",
|
"play_task_bar_title": "Show playing progress on the taskbar",
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
"play_toggle_random": "列表随机",
|
"play_toggle_random": "列表随机",
|
||||||
"play_toggle_list": "顺序播放",
|
"play_toggle_list": "顺序播放",
|
||||||
"play_toggle_single_loop": "单曲循环",
|
"play_toggle_single_loop": "单曲循环",
|
||||||
|
"play_lyric_transition": "显示歌词翻译",
|
||||||
"play_quality_title": "启用时将优先播放320K品质的歌曲",
|
"play_quality_title": "启用时将优先播放320K品质的歌曲",
|
||||||
"play_quality": "优先播放高品质音乐",
|
"play_quality": "优先播放高品质音乐",
|
||||||
"play_task_bar_title": "在任务栏上显示当前歌曲播放进度",
|
"play_task_bar_title": "在任务栏上显示当前歌曲播放进度",
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
"play_toggle_random": "列表隨機",
|
"play_toggle_random": "列表隨機",
|
||||||
"play_toggle_list": "順序播放",
|
"play_toggle_list": "順序播放",
|
||||||
"play_toggle_single_loop": "單曲循環",
|
"play_toggle_single_loop": "單曲循環",
|
||||||
|
"play_lyric_transition": "顯示歌詞翻譯",
|
||||||
"play_quality_title": "啟用時將優先播放320K品質的歌曲",
|
"play_quality_title": "啟用時將優先播放320K品質的歌曲",
|
||||||
"play_quality": "優先播放高品質音樂",
|
"play_quality": "優先播放高品質音樂",
|
||||||
"play_task_bar_title": "在任務欄上顯示當前歌曲播放進度",
|
"play_task_bar_title": "在任務欄上顯示當前歌曲播放進度",
|
||||||
|
|
|
@ -177,7 +177,7 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
|
||||||
: Promise.resolve(),
|
: Promise.resolve(),
|
||||||
isEmbedLyric
|
isEmbedLyric
|
||||||
? downloadInfo.musicInfo.lrc
|
? downloadInfo.musicInfo.lrc
|
||||||
? Promise.resolve(downloadInfo.musicInfo.lrc)
|
? Promise.resolve({ lyric: downloadInfo.musicInfo.lrc, tlyric: downloadInfo.musicInfo.tlrc || '' })
|
||||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise.catch(err => {
|
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise.catch(err => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
return null
|
return null
|
||||||
|
@ -190,7 +190,7 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
|
||||||
artist: downloadInfo.musicInfo.singer,
|
artist: downloadInfo.musicInfo.singer,
|
||||||
album: downloadInfo.musicInfo.albumName,
|
album: downloadInfo.musicInfo.albumName,
|
||||||
APIC: imgUrl,
|
APIC: imgUrl,
|
||||||
lyrics,
|
lyrics: lyrics.lyric,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -202,10 +202,10 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
|
||||||
*/
|
*/
|
||||||
const downloadLyric = (downloadInfo, filePath) => {
|
const downloadLyric = (downloadInfo, filePath) => {
|
||||||
const promise = downloadInfo.musicInfo.lrc
|
const promise = downloadInfo.musicInfo.lrc
|
||||||
? Promise.resolve(downloadInfo.musicInfo.lrc)
|
? Promise.resolve({ lyric: downloadInfo.musicInfo.lrc, tlyric: downloadInfo.musicInfo.tlrc || '' })
|
||||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise
|
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise
|
||||||
promise.then(lrc => {
|
promise.then(lrcs => {
|
||||||
if (lrc) saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrc)
|
if (lrcs.lyric) saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,9 @@ const actions = {
|
||||||
getLrc({ commit, state }, musicInfo) {
|
getLrc({ commit, state }, musicInfo) {
|
||||||
if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp()
|
if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp()
|
||||||
lrcRequest = music[musicInfo.source].getLyric(musicInfo)
|
lrcRequest = music[musicInfo.source].getLyric(musicInfo)
|
||||||
return lrcRequest.promise.then(lrc => {
|
return lrcRequest.promise.then(({ lyric, tlyric }) => {
|
||||||
lrcRequest = null
|
lrcRequest = null
|
||||||
commit('setLrc', { musicInfo, lrc })
|
commit('setLrc', { musicInfo, lyric, tlyric })
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
lrcRequest = null
|
lrcRequest = null
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
|
@ -80,7 +80,8 @@ const mutations = {
|
||||||
datas.musicInfo.img = datas.url
|
datas.musicInfo.img = datas.url
|
||||||
},
|
},
|
||||||
setLrc(state, datas) {
|
setLrc(state, datas) {
|
||||||
datas.musicInfo.lrc = datas.lrc
|
datas.musicInfo.lrc = datas.lyric
|
||||||
|
datas.musicInfo.tlrc = datas.tlyric
|
||||||
},
|
},
|
||||||
setList(state, { list, index }) {
|
setList(state, { list, index }) {
|
||||||
state.listInfo = list
|
state.listInfo = list
|
||||||
|
|
|
@ -21,7 +21,7 @@ const bd = {
|
||||||
},
|
},
|
||||||
getLyric(songInfo) {
|
getLyric(songInfo) {
|
||||||
const requestObj = this.getMusicInfo(songInfo)
|
const requestObj = this.getMusicInfo(songInfo)
|
||||||
requestObj.promise = requestObj.promise.then(info => httpFetch(info.lrclink).promise.then(resp => resp.body))
|
requestObj.promise = requestObj.promise.then(info => httpFetch(info.lrclink).promise.then(resp => ({ lyric: resp.body, tlyric: '' })))
|
||||||
return requestObj
|
return requestObj
|
||||||
},
|
},
|
||||||
// getLyric(songInfo) {
|
// getLyric(songInfo) {
|
||||||
|
|
|
@ -26,7 +26,10 @@ export default {
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
}
|
}
|
||||||
return body
|
return {
|
||||||
|
lyric: body,
|
||||||
|
tlyric: '',
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,7 +17,10 @@ export default {
|
||||||
return requestObj.promise.then(({ statusCode, body, raw }) => {
|
return requestObj.promise.then(({ statusCode, body, raw }) => {
|
||||||
if (statusCode != 200) return Promise.reject(new Error(JSON.stringify(body)))
|
if (statusCode != 200) return Promise.reject(new Error(JSON.stringify(body)))
|
||||||
return decodeLyric({ lrcBase64: raw.toString('base64'), isGetLyricx }).then(base64Data => {
|
return decodeLyric({ lrcBase64: raw.toString('base64'), isGetLyricx }).then(base64Data => {
|
||||||
return Buffer.from(base64Data, 'base64').toString()
|
return {
|
||||||
|
lyric: Buffer.from(base64Data, 'base64').toString(),
|
||||||
|
tlyric: '',
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,10 @@ export default {
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
}
|
}
|
||||||
return body
|
return {
|
||||||
|
lyric: body,
|
||||||
|
tlyric: '',
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,7 +31,10 @@ export default {
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
}
|
}
|
||||||
return body.lyric
|
return {
|
||||||
|
lyric: body.lyric,
|
||||||
|
tlyric: '',
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,17 @@ export default {
|
||||||
matchLrc: /.+"lyric":"([\w=+/]*)".+/,
|
matchLrc: /.+"lyric":"([\w=+/]*)".+/,
|
||||||
},
|
},
|
||||||
getLyric(songmid) {
|
getLyric(songmid) {
|
||||||
const requestObj = httpFetch(`https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?songmid=${songmid}&g_tk=2001461048&loginUin=0&hostUin=0&format=jsonp&inCharset=utf8&outCharset=utf-8&platform=yqq`, {
|
const requestObj = httpFetch(`https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?songmid=${songmid}&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8&platform=yqq`, {
|
||||||
headers: {
|
headers: {
|
||||||
Referer: 'https://y.qq.com/portal/player.html',
|
Referer: 'https://y.qq.com/portal/player.html',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||||
return decodeName(b64DecodeUnicode(body.replace(this.regexps.matchLrc, '$1')))
|
if (body.code != 0) return Promise.reject(new Error('获取歌词失败'))
|
||||||
|
return {
|
||||||
|
lyric: decodeName(b64DecodeUnicode(body.lyric)),
|
||||||
|
tlyric: decodeName(b64DecodeUnicode(body.trans)),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,20 +1,27 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { weapi } from './utils/crypto'
|
import { linuxapi } from './utils/crypto'
|
||||||
|
|
||||||
export default songmid => {
|
export default songmid => {
|
||||||
const requestObj = httpFetch('http://music.163.com/weapi/song/lyric?csrf_token=', {
|
const requestObj = httpFetch('https://music.163.com/api/linux/forward', {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
|
||||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
|
||||||
Referer: 'https://music.163.com/song?id=' + songmid,
|
form: linuxapi({
|
||||||
origin: 'https://music.163.com',
|
method: 'POST',
|
||||||
|
url: 'https://music.163.com/api/song/lyric',
|
||||||
|
params: {
|
||||||
|
id: songmid,
|
||||||
|
lv: -1,
|
||||||
|
kv: -1,
|
||||||
|
tv: -1,
|
||||||
},
|
},
|
||||||
form: weapi({ id: songmid, lv: -1, tv: -1, csrf_token: '' }),
|
}),
|
||||||
})
|
})
|
||||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||||
// console.log(body)
|
|
||||||
if (body.code !== 200) return Promise.reject('获取歌词失败')
|
if (body.code !== 200) return Promise.reject('获取歌词失败')
|
||||||
return body.lrc.lyric
|
return {
|
||||||
|
lyric: body.lrc.lyric,
|
||||||
|
tlyric: body.tlyric.lyric,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,23 @@
|
||||||
import { httpGet, httpFetch } from '../../request'
|
import { httpGet, httpFetch } from '../../request'
|
||||||
import { xmRequest } from './util'
|
import { xmRequest } from './util'
|
||||||
|
|
||||||
|
const parseLyric = str => {
|
||||||
|
str = str.replace(/(?:<\d+>|\r)/g, '')
|
||||||
|
let tlyric = []
|
||||||
|
let lyric = str.replace(/\[[\d:.]+\].*?\n\[x-trans\].*/g, s => {
|
||||||
|
// console.log(s)
|
||||||
|
let [lrc, tlrc] = s.split('\n')
|
||||||
|
tlrc = tlrc.replace('[x-trans]', lrc.replace(/^(\[[\d:.]+\]).*$/, '$1'))
|
||||||
|
tlyric.push(tlrc)
|
||||||
|
return lrc
|
||||||
|
})
|
||||||
|
tlyric = tlyric.join('\n')
|
||||||
|
return {
|
||||||
|
lyric,
|
||||||
|
tlyric,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
failTime: 0,
|
failTime: 0,
|
||||||
expireTime: 60 * 1000 * 1000,
|
expireTime: 60 * 1000 * 1000,
|
||||||
|
@ -13,7 +30,10 @@ export default {
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
}
|
}
|
||||||
return body
|
return url.endsWith('.xtrc') ? parseLyric(body) : {
|
||||||
|
lyric: body,
|
||||||
|
tlyric: '',
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
},
|
},
|
||||||
|
@ -27,7 +47,10 @@ export default {
|
||||||
},
|
},
|
||||||
}, function(err, resp, body) {
|
}, function(err, resp, body) {
|
||||||
if (err || resp.statusCode !== 200) return this.getLyricFile(url, ++retryNum).then(resolve).catch(reject)
|
if (err || resp.statusCode !== 200) return this.getLyricFile(url, ++retryNum).then(resolve).catch(reject)
|
||||||
return resolve(body)
|
return resolve(url.endsWith('.xtrc') ? parseLyric(body) : {
|
||||||
|
lyric: body,
|
||||||
|
tlyric: '',
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -47,8 +70,12 @@ export default {
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
}
|
}
|
||||||
if (!body.result.data.lyrics.length) return Promise.reject(new Error('未找到歌词'))
|
if (!body.result.data.lyrics.length) return Promise.reject(new Error('未找到歌词'))
|
||||||
let lrc = body.result.data.lyrics.find(lyric => /\.lrc$/.test(lyric.lyricUrl))
|
let lrc = body.result.data.lyrics.find(lyric => /\.(trc|lrc)$/.test(lyric.lyricUrl))
|
||||||
return lrc ? lrc.content : Promise.reject(new Error('未找到歌词'))
|
return lrc
|
||||||
|
? lrc.lyricUrl.endsWith('.trc')
|
||||||
|
? parseLyric(lrc.content)
|
||||||
|
: { lyric: lrc.content, tlyric: '' }
|
||||||
|
: Promise.reject(new Error('未找到歌词'))
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
},
|
},
|
||||||
|
@ -74,7 +101,7 @@ export default {
|
||||||
return requestObj
|
return requestObj
|
||||||
},
|
},
|
||||||
getLyric(songInfo) {
|
getLyric(songInfo) {
|
||||||
if (songInfo.lrcUrl && /\.lrc$/.test(songInfo.lrcUrl)) return this.getLyricFile_1(songInfo.lrcUrl)
|
if (songInfo.lrcUrl && /\.(xtrc|lrc)$/.test(songInfo.lrcUrl)) return this.getLyricFile_1(songInfo.lrcUrl)
|
||||||
return Date.now() - this.failTime > this.expireTime ? this.getLyricUrl_1(songInfo) : this.getLyricUrl_2(songInfo)
|
return Date.now() - this.failTime > this.expireTime ? this.getLyricUrl_1(songInfo) : this.getLyricUrl_2(songInfo)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,10 @@ div.scroll(:class="$style.setting")
|
||||||
div
|
div
|
||||||
material-checkbox(:id="`setting_player_togglePlay_${item.value}`" :class="$style.gapLeft" :value="item.value" :key="item.value"
|
material-checkbox(:id="`setting_player_togglePlay_${item.value}`" :class="$style.gapLeft" :value="item.value" :key="item.value"
|
||||||
v-model="current_setting.player.togglePlayMethod" v-for="item in togglePlayMethods" :label="item.name")
|
v-model="current_setting.player.togglePlayMethod" v-for="item in togglePlayMethods" :label="item.name")
|
||||||
|
dd
|
||||||
|
h3 {{$t('view.setting.play_lyric_transition')}}
|
||||||
|
div
|
||||||
|
material-checkbox(id="setting_player_lyric_transition" v-model="current_setting.player.isShowLyricTransition" :label="$t('view.setting.is_show')")
|
||||||
dd(:title="$t('view.setting.play_quality_title')")
|
dd(:title="$t('view.setting.play_quality_title')")
|
||||||
h3 {{$t('view.setting.play_quality')}}
|
h3 {{$t('view.setting.play_quality')}}
|
||||||
div
|
div
|
||||||
|
|
Loading…
Reference in New Issue