整理配置逻辑
parent
b20942d254
commit
e29ca2e79c
|
@ -0,0 +1,24 @@
|
|||
export default [
|
||||
{
|
||||
id: 'test',
|
||||
name: '测试接口',
|
||||
disabled: false,
|
||||
supportQualitys: {
|
||||
kw: ['128k'],
|
||||
kg: ['128k'],
|
||||
tx: ['128k'],
|
||||
wy: ['128k'],
|
||||
mg: ['128k'],
|
||||
xm: ['128k'],
|
||||
bd: ['128k'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'temp',
|
||||
name: '临时接口',
|
||||
disabled: false,
|
||||
supportQualitys: {
|
||||
kw: ['128k'],
|
||||
},
|
||||
},
|
||||
]
|
|
@ -0,0 +1,84 @@
|
|||
import path from 'path'
|
||||
import os from 'os'
|
||||
|
||||
const defaultSetting = {
|
||||
version: '1.0.24',
|
||||
player: {
|
||||
togglePlayMethod: 'listLoop',
|
||||
highQuality: false,
|
||||
isShowTaskProgess: true,
|
||||
volume: 1,
|
||||
mediaDeviceId: 'default',
|
||||
isMediaDeviceRemovedStopPlay: false,
|
||||
},
|
||||
list: {
|
||||
isShowAlbumName: true,
|
||||
isShowSource: true,
|
||||
scroll: {
|
||||
enable: true,
|
||||
locations: {},
|
||||
},
|
||||
},
|
||||
download: {
|
||||
savePath: path.join(os.homedir(), 'Desktop'),
|
||||
fileName: '歌名 - 歌手',
|
||||
maxDownloadNum: 3,
|
||||
isDownloadLrc: false,
|
||||
isEmbedPic: true,
|
||||
},
|
||||
leaderboard: {
|
||||
source: 'kw',
|
||||
tabId: 'kwbiaosb',
|
||||
},
|
||||
songList: {
|
||||
source: 'kg',
|
||||
sortId: '5',
|
||||
tagInfo: {
|
||||
name: '默认',
|
||||
id: null,
|
||||
},
|
||||
},
|
||||
odc: {
|
||||
isAutoClearSearchInput: false,
|
||||
isAutoClearSearchList: false,
|
||||
},
|
||||
search: {
|
||||
searchSource: 'kw',
|
||||
tempSearchSource: 'kw',
|
||||
isShowHotSearch: false,
|
||||
isShowHistorySearch: false,
|
||||
isFocusSearchBox: false,
|
||||
},
|
||||
network: {
|
||||
proxy: {
|
||||
enable: false,
|
||||
host: '',
|
||||
port: '',
|
||||
username: '',
|
||||
password: '',
|
||||
},
|
||||
},
|
||||
tray: {
|
||||
isShow: false,
|
||||
isToTray: false,
|
||||
},
|
||||
windowSizeId: 2,
|
||||
themeId: 0,
|
||||
langId: 'cns',
|
||||
sourceId: 'kw',
|
||||
apiSource: 'temp',
|
||||
sourceNameType: 'alias',
|
||||
randomAnimate: true,
|
||||
ignoreVersion: null,
|
||||
isAgreePact: false,
|
||||
}
|
||||
|
||||
const overwriteSetting = {
|
||||
|
||||
}
|
||||
|
||||
// 使用新年皮肤
|
||||
if (new Date().getMonth() < 2) defaultSetting.themeId = 9
|
||||
|
||||
|
||||
export { defaultSetting, overwriteSetting }
|
|
@ -1,11 +1,84 @@
|
|||
module.exports = {
|
||||
development: {
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
|
||||
const defaultSetting = {
|
||||
version: '1.0.24',
|
||||
player: {
|
||||
togglePlayMethod: 'listLoop',
|
||||
highQuality: false,
|
||||
isShowTaskProgess: true,
|
||||
volume: 1,
|
||||
mediaDeviceId: 'default',
|
||||
isMediaDeviceRemovedStopPlay: false,
|
||||
},
|
||||
production: {
|
||||
|
||||
list: {
|
||||
isShowAlbumName: true,
|
||||
isShowSource: true,
|
||||
scroll: {
|
||||
enable: true,
|
||||
locations: {},
|
||||
},
|
||||
ajax: {
|
||||
timeout: 15000, // ajax请求超时时间
|
||||
},
|
||||
download: {
|
||||
savePath: path.join(os.homedir(), 'Desktop'),
|
||||
fileName: '歌名 - 歌手',
|
||||
maxDownloadNum: 3,
|
||||
isDownloadLrc: false,
|
||||
isEmbedPic: true,
|
||||
},
|
||||
leaderboard: {
|
||||
source: 'kw',
|
||||
tabId: 'kwbiaosb',
|
||||
},
|
||||
songList: {
|
||||
source: 'kg',
|
||||
sortId: '5',
|
||||
tagInfo: {
|
||||
name: '默认',
|
||||
id: null,
|
||||
},
|
||||
},
|
||||
odc: {
|
||||
isAutoClearSearchInput: false,
|
||||
isAutoClearSearchList: false,
|
||||
},
|
||||
search: {
|
||||
searchSource: 'kw',
|
||||
tempSearchSource: 'kw',
|
||||
isShowHotSearch: false,
|
||||
isShowHistorySearch: false,
|
||||
isFocusSearchBox: false,
|
||||
},
|
||||
network: {
|
||||
proxy: {
|
||||
enable: false,
|
||||
host: '',
|
||||
port: '',
|
||||
username: '',
|
||||
password: '',
|
||||
},
|
||||
},
|
||||
tray: {
|
||||
isShow: false,
|
||||
isToTray: false,
|
||||
},
|
||||
windowSizeId: 2,
|
||||
themeId: 0,
|
||||
langId: 'cns',
|
||||
sourceId: 'kw',
|
||||
apiSource: 'temp',
|
||||
sourceNameType: 'alias',
|
||||
randomAnimate: true,
|
||||
ignoreVersion: null,
|
||||
isAgreePact: false,
|
||||
}
|
||||
|
||||
const overwriteSetting = {
|
||||
|
||||
}
|
||||
|
||||
// 使用新年皮肤
|
||||
if (new Date().getMonth() < 2) defaultSetting.themeId = 9
|
||||
|
||||
|
||||
export { defaultSetting, overwriteSetting }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import fs from 'fs'
|
||||
import { shell, clipboard } from 'electron'
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
import crypto from 'crypto'
|
||||
import { rendererSend, rendererInvoke } from '../../common/ipc'
|
||||
import { defaultSetting, overwriteSetting } from '../config'
|
||||
import apiSource from '../config/api-source'
|
||||
|
||||
/**
|
||||
* 获取两个数之间的随机整数,大于等于min,小于max
|
||||
|
@ -184,91 +184,13 @@ export const objectDeepMerge = (target, source) => {
|
|||
* @param {*} setting
|
||||
*/
|
||||
export const updateSetting = (setting, version) => {
|
||||
const defaultVersion = '1.0.24'
|
||||
const defaultVersion = defaultSetting.version
|
||||
if (!version) {
|
||||
if (setting) {
|
||||
version = setting.version
|
||||
delete setting.version
|
||||
}
|
||||
}
|
||||
const defaultSetting = {
|
||||
player: {
|
||||
togglePlayMethod: 'listLoop',
|
||||
highQuality: false,
|
||||
isShowTaskProgess: true,
|
||||
volume: 1,
|
||||
mediaDeviceId: 'default',
|
||||
isMediaDeviceRemovedStopPlay: false,
|
||||
},
|
||||
list: {
|
||||
isShowAlbumName: true,
|
||||
isShowSource: true,
|
||||
scroll: {
|
||||
enable: true,
|
||||
locations: {},
|
||||
},
|
||||
},
|
||||
download: {
|
||||
savePath: path.join(os.homedir(), 'Desktop'),
|
||||
fileName: '歌名 - 歌手',
|
||||
maxDownloadNum: 3,
|
||||
isDownloadLrc: false,
|
||||
isEmbedPic: true,
|
||||
},
|
||||
leaderboard: {
|
||||
source: 'kw',
|
||||
tabId: 'kwbiaosb',
|
||||
},
|
||||
songList: {
|
||||
source: 'kg',
|
||||
sortId: '5',
|
||||
tagInfo: {
|
||||
name: '默认',
|
||||
id: null,
|
||||
},
|
||||
},
|
||||
odc: {
|
||||
isAutoClearSearchInput: false,
|
||||
isAutoClearSearchList: false,
|
||||
},
|
||||
search: {
|
||||
searchSource: 'kw',
|
||||
tempSearchSource: 'kw',
|
||||
isShowHotSearch: false,
|
||||
isShowHistorySearch: false,
|
||||
isFocusSearchBox: false,
|
||||
},
|
||||
network: {
|
||||
proxy: {
|
||||
enable: false,
|
||||
host: '',
|
||||
port: '',
|
||||
username: '',
|
||||
password: '',
|
||||
},
|
||||
},
|
||||
tray: {
|
||||
isShow: false,
|
||||
isToTray: false,
|
||||
},
|
||||
windowSizeId: 2,
|
||||
themeId: 0,
|
||||
langId: 'cns',
|
||||
sourceId: 'kw',
|
||||
apiSource: 'temp',
|
||||
sourceNameType: 'alias',
|
||||
randomAnimate: true,
|
||||
ignoreVersion: null,
|
||||
isAgreePact: false,
|
||||
}
|
||||
|
||||
// 使用新年皮肤
|
||||
if (new Date().getMonth() < 2) defaultSetting.themeId = 9
|
||||
|
||||
const overwriteSetting = {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!setting) {
|
||||
setting = defaultSetting
|
||||
|
@ -277,7 +199,11 @@ export const updateSetting = (setting, version) => {
|
|||
objectDeepMerge(defaultSetting, overwriteSetting)
|
||||
setting = defaultSetting
|
||||
}
|
||||
if (setting.apiSource != 'temp') setting.apiSource = 'test' // 强制设置回 test 接口源
|
||||
|
||||
if (!apiSource.some(api => api.id === setting.apiSource && !api.disabled)) {
|
||||
let api = apiSource.find(api => !api.disabled)
|
||||
if (api) setting.apiSource = api.id
|
||||
}
|
||||
|
||||
return { setting, version: defaultVersion }
|
||||
}
|
||||
|
|
|
@ -1,75 +1,21 @@
|
|||
import kw_api_temp from './kw/api-temp'
|
||||
import kw_api_test from './kw/api-test'
|
||||
import tx_api_test from './tx/api-test'
|
||||
import kg_api_test from './kg/api-test'
|
||||
import wy_api_test from './wy/api-test'
|
||||
import bd_api_test from './bd/api-test'
|
||||
import mg_api_test from './mg/api-test'
|
||||
import xm_api_test from './xm/api-test'
|
||||
// import kw_api_internal from './kw/api-internal'
|
||||
// import tx_api_internal from './tx/api-internal'
|
||||
// import kg_api_internal from './kg/api-internal'
|
||||
// import wy_api_internal from './wy/api-internal'
|
||||
// import bd_api_internal from './bd/api-internal'
|
||||
import apiSource from '../../config/api-source'
|
||||
|
||||
const apiList = {
|
||||
kw_api_test,
|
||||
tx_api_test,
|
||||
kg_api_test,
|
||||
wy_api_test,
|
||||
bd_api_test,
|
||||
mg_api_test,
|
||||
xm_api_test,
|
||||
// kw_api_internal,
|
||||
// tx_api_internal,
|
||||
// kg_api_internal,
|
||||
// wy_api_internal,
|
||||
// bd_api_internal,
|
||||
kw_api_temp,
|
||||
}
|
||||
const apiList = {}
|
||||
const supportQuality = {}
|
||||
|
||||
|
||||
const getAPI = source => {
|
||||
switch (window.globalObj.apiSource) {
|
||||
// case 'messoer':
|
||||
// return apiList[`${source}_api_messoer`]
|
||||
case 'test':
|
||||
return apiList[`${source}_api_test`]
|
||||
case 'temp':
|
||||
return apiList[`${source}_api_temp`]
|
||||
for (const api of apiSource) {
|
||||
supportQuality[api.id] = api.supportQualitys
|
||||
for (const source of Object.keys(api.supportQualitys)) {
|
||||
apiList[`${api.id}_api_${source}`] = require(`./${source}/api-${api.id}`).default
|
||||
}
|
||||
}
|
||||
|
||||
export const apis = source => {
|
||||
switch (source) {
|
||||
case 'tx':
|
||||
return getAPI('tx')
|
||||
case 'kg':
|
||||
return getAPI('kg')
|
||||
case 'wy':
|
||||
return getAPI('wy')
|
||||
case 'bd':
|
||||
return getAPI('bd')
|
||||
case 'mg':
|
||||
return getAPI('mg')
|
||||
case 'xm':
|
||||
return getAPI('xm')
|
||||
default:
|
||||
return getAPI('kw')
|
||||
}
|
||||
const getAPI = source => apiList[`${window.globalObj.apiSource}_api_${source}`]
|
||||
|
||||
const apis = source => {
|
||||
let api = getAPI(source)
|
||||
if (api) return api
|
||||
throw new Error('Api is not found')
|
||||
}
|
||||
|
||||
export const supportQuality = {
|
||||
temp: {
|
||||
kw: ['128k'],
|
||||
},
|
||||
test: {
|
||||
kw: ['128k'],
|
||||
kg: ['128k'],
|
||||
tx: ['128k'],
|
||||
wy: ['128k'],
|
||||
mg: ['128k'],
|
||||
xm: ['128k'],
|
||||
bd: ['128k'],
|
||||
},
|
||||
}
|
||||
export { apis, supportQuality }
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
|
||||
const api_internal = {
|
||||
successCode: 2200,
|
||||
// getMusicUrl(songInfo, type) {
|
||||
// const requestObj = httpFatch(`http://play.taihe.com/data/music/songlink`, {
|
||||
// method: 'post',
|
||||
// headers: {
|
||||
// Origin: 'http://play.taihe.com',
|
||||
// },
|
||||
// formData: {
|
||||
// songIds: songInfo.songmid,
|
||||
// },
|
||||
// })
|
||||
// requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
// console.log(body)
|
||||
// return Promise.reject()
|
||||
// // if (body.error_code !== this.successCode) return this.getMusicUrl(songInfo, type)
|
||||
// // return body.code === 200 ? Promise.resolve({ type, url: body.result.bitrate.file_link }) : Promise.reject(new Error(requestMsg.fail))
|
||||
// })
|
||||
// return requestObj
|
||||
// },
|
||||
getMusicInfo(songInfo, tryNum = 0) {
|
||||
const requestObj = httpFatch(`http://tingapi.ting.baidu.com/v1/restserver/ting?from=webapp_music&method=baidu.ting.song.baseInfos&song_id=${songInfo.songmid}`)
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
if (body.error_code !== this.successCode) return tryNum > 5 ? Promise.reject(new Error(requestMsg.fail)) : this.getMusicInfo(songInfo, ++tryNum)
|
||||
return body ? Promise.resolve(body.result.items[0]) : Promise.reject(new Error(requestMsg.fail))
|
||||
})
|
||||
return requestObj
|
||||
},
|
||||
getPic(songInfo) {
|
||||
const requestObj = this.getMusicInfo(songInfo)
|
||||
requestObj.promise = requestObj.promise.then(info => info.pic_premium)
|
||||
return requestObj
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
const requestObj = this.getMusicInfo(songInfo)
|
||||
requestObj.promise.then(info => httpFatch(info.lrclink).promise)
|
||||
return requestObj
|
||||
},
|
||||
}
|
||||
|
||||
export default api_internal
|
|
@ -1,41 +0,0 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
import { headers, timeout } from '../options'
|
||||
|
||||
const api_messoer = {
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`https://v1.itooi.cn/kugou/url?id=${songInfo._types[type].hash}&quality=${type.replace(/k$/, '')}&isRedirect=0`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
})
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
return body.code === 200 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(requestMsg.fail))
|
||||
})
|
||||
return requestObj
|
||||
},
|
||||
getPic(songInfo) {
|
||||
const requestObj = httpFatch(`https://v1.itooi.cn/kugou/pic?id=${songInfo.hash}&isRedirect=0`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
})
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
return body.code === 200 ? Promise.resolve(body.data) : Promise.reject(new Error(requestMsg.fail))
|
||||
})
|
||||
return requestObj
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
const requestObj = httpFatch(`https://v1.itooi.cn/kugou/lrc?id=${songInfo.hash}&isRedirect=0`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
})
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
return body ? Promise.resolve(body) : Promise.reject(new Error(requestMsg.fail))
|
||||
})
|
||||
return requestObj
|
||||
},
|
||||
}
|
||||
|
||||
export default api_messoer
|
|
@ -1,30 +0,0 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
import { headers, timeout } from '../options'
|
||||
|
||||
const api_messoer = {
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
})
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
return body.code === 200 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(requestMsg.fail))
|
||||
})
|
||||
return requestObj
|
||||
},
|
||||
getPic(songInfo) {
|
||||
const requestObj = httpFatch(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
})
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
return body.code === 200 ? Promise.resolve(body.data) : Promise.reject(new Error(requestMsg.fail))
|
||||
})
|
||||
return requestObj
|
||||
},
|
||||
}
|
||||
|
||||
export default api_messoer
|
|
@ -1,24 +0,0 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
import { headers, timeout } from '../options'
|
||||
|
||||
const api_messoer = {
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`https://v1.itooi.cn/tencent/url?id=${songInfo.strMediaMid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
})
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
return body.code === 200 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(requestMsg.fail))
|
||||
})
|
||||
return requestObj
|
||||
},
|
||||
getPic(songInfo) {
|
||||
return {
|
||||
promise: Promise.resolve(`https://y.gtimg.cn/music/photo_new/T002R500x500M000${songInfo.albumId}.jpg`),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default api_messoer
|
|
@ -230,6 +230,7 @@ import {
|
|||
setWindowSize,
|
||||
} from '../utils'
|
||||
import { rendererSend } from '../../common/ipc'
|
||||
import apiSource from '../config/api-source'
|
||||
import fs from 'fs'
|
||||
import languageList from '@/lang/languages.json'
|
||||
|
||||
|
@ -267,18 +268,11 @@ export default {
|
|||
]
|
||||
},
|
||||
apiSources() {
|
||||
return [
|
||||
{
|
||||
id: 'test',
|
||||
label: this.$t('view.setting.basic_source_test'),
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
id: 'temp',
|
||||
label: this.$t('view.setting.basic_source_temp'),
|
||||
disabled: false,
|
||||
},
|
||||
]
|
||||
return apiSource.map(api => ({
|
||||
id: api.id,
|
||||
label: this.$t('view.setting.basic_source_' + api.id) || api.name,
|
||||
disabled: api.disabled,
|
||||
}))
|
||||
},
|
||||
sourceNameTypes() {
|
||||
return [
|
||||
|
|
Loading…
Reference in New Issue