新增“下载的歌词文件编码格式”设置
parent
72df1a35a0
commit
fe35081e03
|
@ -4,6 +4,7 @@
|
|||
### 新增
|
||||
|
||||
- 歌曲搜索框新增清理按钮,点击此按钮可以清理搜索框并返回初始搜索界面
|
||||
- 新增“下载的歌词文件编码格式”设置,默认下载的歌词编码仍是`UTF-8`,对于某些在设备(如车机)上出现歌词中文乱码的用户可以尝试选择以`GBK`编码格式保存歌词文件
|
||||
|
||||
### 优化
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ const path = require('path')
|
|||
const os = require('os')
|
||||
|
||||
const defaultSetting = {
|
||||
version: '1.0.43',
|
||||
version: '1.0.44',
|
||||
player: {
|
||||
togglePlayMethod: 'listLoop',
|
||||
highQuality: false,
|
||||
|
@ -44,6 +44,7 @@ const defaultSetting = {
|
|||
fileName: '歌名 - 歌手',
|
||||
maxDownloadNum: 3,
|
||||
isDownloadLrc: false,
|
||||
lrcFormat: 'utf8',
|
||||
isEmbedPic: true,
|
||||
isEmbedLyric: false,
|
||||
isUseOtherSource: false,
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
"download_embed_pic": "Embedding cover",
|
||||
"download_enable": "Whether to enable download function",
|
||||
"download_lyric": "Lyrics download",
|
||||
"download_lyric_format": "Downloaded lyrics file encoding format",
|
||||
"download_lyric_format_gbk": "GBK (Try to select this format when Chinese garbled characters appear on some devices)",
|
||||
"download_lyric_format_utf8": "UTF-8",
|
||||
"download_lyric_title": "Select whether to download the lyrics file",
|
||||
"download_name": "Music file naming",
|
||||
"download_name1": "Title - Artist",
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
"download_embed_pic": "封面嵌入",
|
||||
"download_enable": "是否启用下载功能",
|
||||
"download_lyric": "歌词下载",
|
||||
"download_lyric_format": "下载的歌词文件编码格式",
|
||||
"download_lyric_format_gbk": "GBK(在某些设备上出现中文乱码时可尝试选择此格式)",
|
||||
"download_lyric_format_utf8": "UTF-8",
|
||||
"download_lyric_title": "是否同时下载歌词文件",
|
||||
"download_name": "文件命名方式",
|
||||
"download_name1": "歌名 - 歌手",
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
"download_embed_pic": "封面嵌入",
|
||||
"download_enable": "是否啟用下載功能",
|
||||
"download_lyric": "歌詞下載",
|
||||
"download_lyric_format": "下載的歌詞文件編碼格式",
|
||||
"download_lyric_format_gbk": "GBK(在某些設備上出現中文亂碼時可嘗試選擇此格式)",
|
||||
"download_lyric_format_utf8": "UTF-8",
|
||||
"download_lyric_title": "是否同時下載歌詞文件",
|
||||
"download_name": "文件命名方式",
|
||||
"download_name1": "歌名 - 歌手",
|
||||
|
|
|
@ -307,7 +307,7 @@ const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic,
|
|||
* @param {*} downloadInfo
|
||||
* @param {*} filePath
|
||||
*/
|
||||
const downloadLyric = (downloadInfo, filePath) => {
|
||||
const downloadLyric = (downloadInfo, filePath, lrcFormat) => {
|
||||
const promise = getLyric(downloadInfo.musicInfo).then(lrcInfo => {
|
||||
return lrcInfo.lyric
|
||||
? Promise.resolve({ lyric: lrcInfo.lyric, tlyric: lrcInfo.tlyric || '' })
|
||||
|
@ -319,7 +319,7 @@ const downloadLyric = (downloadInfo, filePath) => {
|
|||
promise.then(lrcs => {
|
||||
if (lrcs.lyric) {
|
||||
lrcs.lyric = fixKgLyric(lrcs.lyric)
|
||||
saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric)
|
||||
saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric, lrcFormat)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ const actions = {
|
|||
dispatch('startTask')
|
||||
|
||||
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)
|
||||
if (rootState.setting.download.isDownloadLrc) downloadLyric(downloadInfo, downloadInfo.filePath, rootState.setting.download.lrcFormat)
|
||||
console.log('on complate')
|
||||
},
|
||||
onError(err) {
|
||||
|
|
|
@ -3,6 +3,7 @@ import path from 'path'
|
|||
import { shell, clipboard } from 'electron'
|
||||
import crypto from 'crypto'
|
||||
import { rendererSend, rendererInvoke, NAMES } from '../../common/ipc'
|
||||
import iconv from 'iconv-lite'
|
||||
|
||||
/**
|
||||
* 获取两个数之间的随机整数,大于等于min,小于max
|
||||
|
@ -276,11 +277,22 @@ export const setMeta = (filePath, meta) => {
|
|||
* 保存歌词文件
|
||||
* @param {*} filePath
|
||||
* @param {*} lrc
|
||||
* @param {*} format
|
||||
*/
|
||||
export const saveLrc = (filePath, lrc) => {
|
||||
fs.writeFile(filePath, lrc, 'utf8', err => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
export const saveLrc = (filePath, lrc, format) => {
|
||||
switch (format) {
|
||||
case 'gbk':
|
||||
fs.writeFile(filePath, iconv.encode(lrc, 'gbk', { addBOM: true }), err => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
break
|
||||
case 'utf8':
|
||||
default:
|
||||
fs.writeFile(filePath, lrc, 'utf8', err => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -149,6 +149,11 @@ div(:class="$style.main")
|
|||
h3#download_lyric {{$t('view.setting.download_lyric')}}
|
||||
div
|
||||
material-checkbox(id="setting_download_isDownloadLrc" v-model="current_setting.download.isDownloadLrc" :label="$t('view.setting.is_enable')")
|
||||
dd
|
||||
h3#download_lyric {{$t('view.setting.download_lyric_format')}}
|
||||
div
|
||||
material-checkbox(v-for="item in lrcFormatList" :key="item.id" :class="$style.gapLeft" :id="`setting_download_lrcFormat_${item.id}`"
|
||||
name="setting_basic_control_btn_position" need v-model="current_setting.download.lrcFormat" :value="item.id" :label="item.name")
|
||||
|
||||
dt#sync {{$t('view.setting.sync')}}
|
||||
dd
|
||||
|
@ -424,6 +429,18 @@ export default {
|
|||
},
|
||||
]
|
||||
},
|
||||
lrcFormatList() {
|
||||
return [
|
||||
{
|
||||
name: this.$t('view.setting.download_lyric_format_utf8'),
|
||||
id: 'utf8',
|
||||
},
|
||||
{
|
||||
name: this.$t('view.setting.download_lyric_format_gbk'),
|
||||
id: 'gbk',
|
||||
},
|
||||
]
|
||||
},
|
||||
trayThemeList() {
|
||||
return [
|
||||
{
|
||||
|
@ -494,6 +511,7 @@ export default {
|
|||
savePath: '',
|
||||
fileName: '歌名 - 歌手',
|
||||
isDownloadLrc: false,
|
||||
lrcFormat: 'utf8',
|
||||
isEmbedPic: true,
|
||||
isEmbedLyric: true,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue