分离可用音质控制逻辑

pull/225/head
lyswhut 2020-04-29 12:33:41 +08:00
parent e51ee8c1ad
commit a62d8304e2
26 changed files with 127 additions and 133 deletions

30
package-lock.json generated
View File

@ -1217,9 +1217,9 @@
"dev": true "dev": true
}, },
"@types/uglify-js": { "@types/uglify-js": {
"version": "3.0.5", "version": "3.9.0",
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.0.5.tgz", "resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.9.0.tgz",
"integrity": "sha512-L7EbSkhSaWBpkl+PZAEAqZTqtTeIsq7s/oX/q0LNnxxJoRVKQE0T81XDVyaxjiiKQwiV2vhVeYRqxdRNqGOGJw==", "integrity": "sha512-3ZcoyPYHVOCcLpnfZwD47KFLr8W/mpUcgjpf1M4Q78TMJIw7KMAHSjiCLJp1z3ZrBR9pTLbe191O0TldFK5zcw==",
"dev": true, "dev": true,
"requires": { "requires": {
"source-map": "^0.6.1" "source-map": "^0.6.1"
@ -1234,9 +1234,9 @@
} }
}, },
"@types/webpack": { "@types/webpack": {
"version": "4.41.10", "version": "4.41.12",
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.10.tgz", "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.12.tgz",
"integrity": "sha512-vIy0qaq8AjOjZLuFPqpo7nAJzcoVXMdw3mvpNN07Uvdy0p1IpJeLNBe3obdRP7FX2jIusDE7z1pZa0A6qYUgnA==", "integrity": "sha512-BpCtM4NnBen6W+KEhrL9jKuZCXVtiH6+0b6cxdvNt2EwU949Al334PjQSl2BeAyvAX9mgoNNG21wvjP3xZJJ5w==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/anymatch": "*", "@types/anymatch": "*",
@ -5339,9 +5339,9 @@
"dev": true "dev": true
}, },
"electron": { "electron": {
"version": "8.2.3", "version": "8.2.4",
"resolved": "https://registry.npmjs.org/electron/-/electron-8.2.3.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-8.2.4.tgz",
"integrity": "sha512-FJUp103c8yJBoAaj/QM/OBde57iJh95u1yGJBytMUXmLFSsx78LmNE03QN4XCODyzi76IEcasvUcK6scogRLbQ==", "integrity": "sha512-Lle0InIgSAHZxD5KDY0wZ1A2Zlc6GHwMhAxoHMzn05mndyP1YBkCYHc0TDDofzUTrsLFofduPjlknO5Oj9fTPA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",
@ -5350,9 +5350,9 @@
}, },
"dependencies": { "dependencies": {
"@types/node": { "@types/node": {
"version": "12.12.36", "version": "12.12.37",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.36.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.37.tgz",
"integrity": "sha512-hmmypvyO/uTLFYCYu6Hlb3ydeJ11vXRxg8/WJ0E3wvwmPO0y47VqnfmXFVuWlysO0Zyj+je1Y33rQeuYkZ51GQ==", "integrity": "sha512-4mXKoDptrXAwZErQHrLzpe0FN/0Wmf5JRniSVIdwUrtDf9wnmEV1teCNLBo/TwuXhkK/bVegoEn/wmb+x0AuPg==",
"dev": true "dev": true
} }
} }
@ -8427,9 +8427,9 @@
} }
}, },
"html-webpack-plugin": { "html-webpack-plugin": {
"version": "4.2.0", "version": "4.2.1",
"resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.2.0.tgz", "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.2.1.tgz",
"integrity": "sha512-zL7LYTuq/fcJX6vV6tmmvFR508Bd9e6kvVGbS76YAjZ2CPVRzsjkvDYs/SshPevpolSdTWgaDV39D6k6oQoVFw==", "integrity": "sha512-zTTPxKJ8bgRe4RVDzT1MZW8ysW5wwDfJmD3AN+7mw2MKMWZJibZzBgHaDqnL6FJg1kvk38sQPMJNmI8Q1Ntr9A==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/html-minifier-terser": "^5.0.0", "@types/html-minifier-terser": "^5.0.0",

View File

@ -51,7 +51,7 @@
"lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-formatter-friendly --fix src" "lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-formatter-friendly --fix src"
}, },
"browserslist": [ "browserslist": [
"Electron 8.2.3" "Electron 8.2.4"
], ],
"engines": { "engines": {
"node": ">= 12" "node": ">= 12"
@ -160,7 +160,7 @@
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"css-loader": "^3.5.3", "css-loader": "^3.5.3",
"del": "^5.1.0", "del": "^5.1.0",
"electron": "^8.2.3", "electron": "^8.2.4",
"electron-builder": "^22.5.1", "electron-builder": "^22.5.1",
"electron-debug": "^3.0.1", "electron-debug": "^3.0.1",
"electron-devtools-installer": "^3.0.0", "electron-devtools-installer": "^3.0.0",
@ -175,7 +175,7 @@
"eslint-plugin-standard": "^4.0.1", "eslint-plugin-standard": "^4.0.1",
"file-loader": "^6.0.0", "file-loader": "^6.0.0",
"friendly-errors-webpack-plugin": "^1.7.0", "friendly-errors-webpack-plugin": "^1.7.0",
"html-webpack-plugin": "^4.2.0", "html-webpack-plugin": "^4.2.1",
"less": "^3.11.1", "less": "^3.11.1",
"less-loader": "^6.0.0", "less-loader": "^6.0.0",
"markdown-it": "^10.0.0", "markdown-it": "^10.0.0",

View File

@ -34,5 +34,5 @@
### 其他 ### 其他
更新 Electron 到 8.2.3 更新 Electron 到 8.2.4

View File

@ -44,6 +44,7 @@ export default {
apiSource: 'test', apiSource: 'test',
proxy: {}, proxy: {},
isShowPact: false, isShowPact: false,
qualityList: {},
xm: { xm: {
isShowVerify: false, isShowVerify: false,
}, },
@ -121,6 +122,7 @@ export default {
this.saveSearchHistoryList(n) this.saveSearchHistoryList(n)
}, },
'globalObj.apiSource'(n) { 'globalObj.apiSource'(n) {
this.globalObj.qualityList = music.supportQuality[n]
if (n != this.setting.apiSource) { if (n != this.setting.apiSource) {
this.setSetting(Object.assign({}, this.setting, { this.setSetting(Object.assign({}, this.setting, {
apiSource: n, apiSource: n,
@ -196,6 +198,7 @@ export default {
this.initData() this.initData()
this.globalObj.apiSource = this.setting.apiSource this.globalObj.apiSource = this.setting.apiSource
this.globalObj.qualityList = music.supportQuality[this.setting.apiSource]
this.globalObj.proxy = Object.assign({}, this.setting.network.proxy) this.globalObj.proxy = Object.assign({}, this.setting.network.proxy)
window.globalObj = this.globalObj window.globalObj = this.globalObj

View File

@ -56,7 +56,7 @@ div(:class="$style.player")
<script> <script>
import Lyric from 'lrc-file-parser' import Lyric from 'lrc-file-parser'
import { rendererSend } from '../../../common/ipc' import { rendererSend } from '../../../common/ipc'
import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, debounce } from '../../utils' import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, debounce, 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'
import { isMac } from '../../../common/utils' import { isMac } from '../../../common/utils'
@ -125,9 +125,6 @@ export default {
progress() { progress() {
return this.nowPlayTime / this.maxPlayTime || 0 return this.nowPlayTime / this.maxPlayTime || 0
}, },
isAPITemp() {
return this.setting.apiSource == 'temp'
},
}, },
mounted() { mounted() {
this.init() this.init()
@ -368,10 +365,8 @@ export default {
const filePath = path.join(this.setting.download.savePath, item.fileName) const filePath = path.join(this.setting.download.savePath, item.fileName)
if ((!await checkPath(filePath) || !item.isComplate || /\.ape$/.test(filePath))) list.push(item) if ((!await checkPath(filePath) || !item.isComplate || /\.ape$/.test(filePath))) list.push(item)
} }
} else if (this.isAPITemp) {
list = this.list.filter(s => s.source == 'kw')
} else { } else {
list = this.list list = this.list.filter(s => this.assertApiSupport(s.source))
} }
return list return list
}, },
@ -379,7 +374,7 @@ export default {
// console.log(playIndex) // console.log(playIndex)
let list = await this.filterList() let list = await this.filterList()
if (!list.length) return this.setPlayIndex(-1) if (!list.length) return this.setPlayIndex(-1)
let playIndex = this.list === list ? this.playIndex : list.indexOf(this.list[this.playIndex]) let playIndex = list.indexOf(this.list[this.playIndex])
let index let index
switch (this.setting.player.togglePlayMethod) { switch (this.setting.player.togglePlayMethod) {
case 'random': case 'random':
@ -393,14 +388,14 @@ export default {
return return
} }
if (index < 0) return if (index < 0) return
if (this.list !== list) index = this.list.indexOf(list[index]) index = this.list.indexOf(list[index])
this.setPlayIndex(index) this.setPlayIndex(index)
}, },
async handleNext() { async handleNext() {
// if (this.list.listName === null) return // if (this.list.listName === null) return
let list = await this.filterList() let list = await this.filterList()
if (!list.length) return this.setPlayIndex(-1) if (!list.length) return this.setPlayIndex(-1)
let playIndex = this.list === list ? this.playIndex : list.indexOf(this.list[this.playIndex]) let playIndex = list.indexOf(this.list[this.playIndex])
// console.log(playIndex) // console.log(playIndex)
let index let index
switch (this.setting.player.togglePlayMethod) { switch (this.setting.player.togglePlayMethod) {
@ -417,7 +412,7 @@ export default {
return return
} }
if (index < 0) return if (index < 0) return
if (this.list !== list) index = this.list.indexOf(list[index]) index = this.list.indexOf(list[index])
this.setPlayIndex(index) this.setPlayIndex(index)
}, },
hanldeListRandom(list, index) { hanldeListRandom(list, index) {
@ -470,14 +465,9 @@ export default {
this.musicInfo.img = null this.musicInfo.img = null
}, },
getPlayType(highQuality, songInfo) { getPlayType(highQuality, songInfo) {
switch (songInfo.source) {
case 'wy':
case 'tx':
return '128k'
// case 'kg':
}
let type = '128k' let type = '128k'
if (highQuality && songInfo._types['320k']) type = '320k' let list = window.globalObj.qualityList[songInfo.source]
if (highQuality && songInfo._types['320k'] && list && list.includes('320k')) type = '320k'
return type return type
}, },
setUrl(targetSong, isRefresh, isRetryed = false) { setUrl(targetSong, isRefresh, isRetryed = false) {
@ -654,6 +644,9 @@ export default {
break break
} }
}, },
assertApiSupport(source) {
return assertApiSupport(source)
},
}, },
} }
</script> </script>

View File

@ -29,6 +29,9 @@ export default {
info() { info() {
return this.musicInfo || {} return this.musicInfo || {}
}, },
qualityList() {
return window.globalObj.qualityList[this.musicInfo.source]
},
}, },
methods: { methods: {
handleClick(type) { handleClick(type) {
@ -51,16 +54,7 @@ export default {
} }
}, },
checkSource(type) { checkSource(type) {
switch (this.musicInfo.source) { return this.qualityList.includes(type)
case 'wy':
case 'tx':
return type == '128k'
case 'xm':
return type == '128k' || type == '320k'
default:
return true
}
}, },
}, },
} }

View File

@ -28,9 +28,9 @@ div(:class="$style.songList")
td(style="width: 20%; padding-left: 0; padding-right: 0;") td(style="width: 20%; padding-left: 0; padding-right: 0;")
material-list-buttons(:index="index" :search-btn="true" material-list-buttons(:index="index" :search-btn="true"
:remove-btn="false" @btn-click="handleListBtnClick" :remove-btn="false" @btn-click="handleListBtnClick"
:listAdd-btn="item.source == 'kw' || !isAPITemp" :listAdd-btn="assertApiSupport(item.source)"
:play-btn="item.source == 'kw' || !isAPITemp" :play-btn="assertApiSupport(item.source)"
:download-btn="item.source == 'kw' || !isAPITemp") :download-btn="assertApiSupport(item.source)")
//- button.btn-info(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k'] || item._types.flac" @click.stop='openDownloadModal(index)') //- button.btn-info(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k'] || item._types.flac" @click.stop='openDownloadModal(index)')
//- button.btn-secondary(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k']" @click.stop='testPlay(index)') //- button.btn-secondary(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k']" @click.stop='testPlay(index)')
//- button.btn-success(type='button' v-if="(item._types['128k'] || item._types['192k'] || item._types['320k']) && userInfo" @click.stop='showListModal(index)') //- button.btn-success(type='button' v-if="(item._types['128k'] || item._types['192k'] || item._types['320k']) && userInfo" @click.stop='showListModal(index)')
@ -41,12 +41,12 @@ div(:class="$style.songList")
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")
div(v-show="!list.length" :class="$style.noitem") div(v-show="!list.length" :class="$style.noitem")
p(v-html="noItem") p(v-html="noItem")
material-flow-btn(:show="isShowEditBtn && (source == 'kw' || !isAPITemp)" :remove-btn="false" @btn-click="handleFlowBtnClick") material-flow-btn(:show="isShowEditBtn && assertApiSupport(source)" :remove-btn="false" @btn-click="handleFlowBtnClick")
</template> </template>
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { scrollTo, clipboardWriteText } from '../../utils' import { scrollTo, clipboardWriteText, assertApiSupport } from '../../utils'
export default { export default {
name: 'MaterialSongList', name: 'MaterialSongList',
model: { model: {
@ -86,9 +86,6 @@ export default {
}, },
computed: { computed: {
...mapGetters(['setting']), ...mapGetters(['setting']),
isAPITemp() {
return this.setting.apiSource == 'temp'
},
}, },
watch: { watch: {
selectdList(n) { selectdList(n) {
@ -185,7 +182,7 @@ export default {
this.clickIndex = index this.clickIndex = index
return return
} }
this.emitEvent((this.source == 'kw' || !this.isAPITemp) ? 'testPlay' : 'search', index) this.emitEvent(this.assertApiSupport(this.source) ? 'testPlay' : 'search', index)
this.clickTime = 0 this.clickTime = 0
this.clickIndex = -1 this.clickIndex = -1
}, },
@ -274,6 +271,9 @@ export default {
clipboardWriteText(str) clipboardWriteText(str)
}) })
}, },
assertApiSupport(source) {
return assertApiSupport(source)
},
}, },
} }
</script> </script>

View File

@ -1,5 +1,5 @@
{ {
"btn_tip": "腾讯、网易音源仅支持下载128k音质\n虾米音源不支持下载无损音质", "btn_tip": "该音质不可用",
"lossless": "无损音质", "lossless": "无损音质",
"high_quality": "高品音质", "high_quality": "高品音质",
"normal": "普通音质" "normal": "普通音质"

View File

@ -1,5 +1,5 @@
{ {
"btn_tip": "騰訊、網易、音源僅支持下載128k音質\n蝦米音源不支持下載無損音質", "btn_tip": "該音質不可用",
"lossless": "無損音質", "lossless": "無損音質",
"high_quality": "高品音質", "high_quality": "高品音質",
"normal": "普通音質" "normal": "普通音質"

View File

@ -1,5 +1,5 @@
{ {
"btn_tip": "Tencent and NetEase only support 128k audio quality\nXiami sources does not support 128k audio quality", "btn_tip": "The audio quality is not available",
"lossless": "Lossless", "lossless": "Lossless",
"high_quality": "High Quality", "high_quality": "High Quality",
"normal": "Normal" "normal": "Normal"

View File

@ -207,6 +207,7 @@ const actions = {
} }
}, },
createDownloadMultiple({ state, rootState }, { list, type }) { createDownloadMultiple({ state, rootState }, { list, type }) {
if (!list.length) return
addTask([...list], type, this) addTask([...list], type, this)
}, },
async startTask({ commit, state, rootState }, downloadInfo) { async startTask({ commit, state, rootState }, downloadInfo) {

View File

@ -428,3 +428,6 @@ export const setWindowSize = (width, height) => rendererSend('setWindowSize', {
export const getProxyInfo = () => window.globalObj.proxy.enable export const getProxyInfo = () => window.globalObj.proxy.enable
? `http://${window.globalObj.proxy.username}:${window.globalObj.proxy.password}@${window.globalObj.proxy.host}:${window.globalObj.proxy.port};` ? `http://${window.globalObj.proxy.username}:${window.globalObj.proxy.password}@${window.globalObj.proxy.host}:${window.globalObj.proxy.port};`
: undefined : undefined
export const assertApiSupport = source => window.globalObj.qualityList[source] != undefined

View File

@ -12,7 +12,7 @@ import xm_api_test from './xm/api-test'
// import wy_api_internal from './wy/api-internal' // import wy_api_internal from './wy/api-internal'
// import bd_api_internal from './bd/api-internal' // import bd_api_internal from './bd/api-internal'
const apis = { const apiList = {
kw_api_test, kw_api_test,
tx_api_test, tx_api_test,
kg_api_test, kg_api_test,
@ -32,15 +32,15 @@ const apis = {
const getAPI = source => { const getAPI = source => {
switch (window.globalObj.apiSource) { switch (window.globalObj.apiSource) {
// case 'messoer': // case 'messoer':
// return apis[`${source}_api_messoer`] // return apiList[`${source}_api_messoer`]
case 'test': case 'test':
return apis[`${source}_api_test`] return apiList[`${source}_api_test`]
case 'temp': case 'temp':
return apis[`${source}_api_temp`] return apiList[`${source}_api_temp`]
} }
} }
export default source => { export const apis = source => {
switch (source) { switch (source) {
case 'tx': case 'tx':
return getAPI('tx') return getAPI('tx')
@ -58,3 +58,18 @@ export default source => {
return getAPI('kw') return getAPI('kw')
} }
} }
export const supportQuality = {
temp: {
kw: ['128k'],
},
test: {
kw: ['128k'],
kg: ['128k'],
tx: ['128k'],
wy: ['128k'],
mg: ['128k'],
xm: ['128k'],
bd: ['128k'],
},
}

View File

@ -1,5 +1,5 @@
import leaderboard from './leaderboard' import leaderboard from './leaderboard'
import api_source from '../api-source' import { apis } from '../api-source'
import musicInfo from './musicInfo' import musicInfo from './musicInfo'
import songList from './songList' import songList from './songList'
import { httpFetch } from '../../request' import { httpFetch } from '../../request'
@ -12,7 +12,7 @@ const bd = {
musicSearch, musicSearch,
hotSearch, hotSearch,
getMusicUrl(songInfo, type) { getMusicUrl(songInfo, type) {
return api_source('bd').getMusicUrl(songInfo, type) return apis('bd').getMusicUrl(songInfo, type)
}, },
getPic(songInfo) { getPic(songInfo) {
const requestObj = this.getMusicInfo(songInfo) const requestObj = this.getMusicInfo(songInfo)
@ -25,10 +25,10 @@ const bd = {
return requestObj return requestObj
}, },
// getLyric(songInfo) { // getLyric(songInfo) {
// return api_source('bd').getLyric(songInfo) // return apis('bd').getLyric(songInfo)
// }, // },
// getPic(songInfo) { // getPic(songInfo) {
// return api_source('bd').getPic(songInfo) // return apis('bd').getPic(songInfo)
// }, // },
getMusicInfo(songInfo) { getMusicInfo(songInfo) {
return musicInfo.getMusicInfo(songInfo.songmid) return musicInfo.getMusicInfo(songInfo.songmid)

View File

@ -5,6 +5,9 @@ import wy from './wy'
import mg from './mg' import mg from './mg'
import bd from './bd' import bd from './bd'
import xm from './xm' import xm from './xm'
import { supportQuality } from './api-source'
const sources = { const sources = {
sources: [ sources: [
{ {
@ -52,4 +55,5 @@ export default {
sm && sm.init && sm.init() sm && sm.init && sm.init()
} }
}, },
supportQuality,
} }

View File

@ -1,5 +1,5 @@
import leaderboard from './leaderboard' import leaderboard from './leaderboard'
import api_source from '../api-source' import { apis } from '../api-source'
import songList from './songList' import songList from './songList'
import musicSearch from './musicSearch' import musicSearch from './musicSearch'
import pic from './pic' import pic from './pic'
@ -12,19 +12,19 @@ const kg = {
musicSearch, musicSearch,
hotSearch, hotSearch,
getMusicUrl(songInfo, type) { getMusicUrl(songInfo, type) {
return api_source('kg').getMusicUrl(songInfo, type) return apis('kg').getMusicUrl(songInfo, type)
}, },
getLyric(songInfo) { getLyric(songInfo) {
return lyric.getLyric(songInfo) return lyric.getLyric(songInfo)
}, },
// getLyric(songInfo) { // getLyric(songInfo) {
// return api_source('kg').getLyric(songInfo) // return apis('kg').getLyric(songInfo)
// }, // },
getPic(songInfo) { getPic(songInfo) {
return pic.getPic(songInfo) return pic.getPic(songInfo)
}, },
// getPic(songInfo) { // getPic(songInfo) {
// return api_source('kg').getPic(songInfo) // return apis('kg').getPic(songInfo)
// }, // },
} }

View File

@ -5,7 +5,7 @@ import { formatSinger, getToken } from './util'
import leaderboard from './leaderboard' import leaderboard from './leaderboard'
import lyric from './lyric' import lyric from './lyric'
import pic from './pic' import pic from './pic'
import api_source from '../api-source' import { apis } from '../api-source'
import songList from './songList' import songList from './songList'
import hotSearch from './hotSearch' import hotSearch from './hotSearch'
@ -58,7 +58,7 @@ const kw = {
}, },
getMusicUrl(songInfo, type) { getMusicUrl(songInfo, type) {
return api_source('kw').getMusicUrl(songInfo, type) return apis('kw').getMusicUrl(songInfo, type)
}, },
getMusicInfo(songInfo) { getMusicInfo(songInfo) {

View File

@ -1,4 +1,4 @@
import api_source from '../api-source' import { apis } from '../api-source'
import leaderboard from './leaderboard' import leaderboard from './leaderboard'
import songList from './songList' import songList from './songList'
import musicSearch from './musicSearch' import musicSearch from './musicSearch'
@ -12,7 +12,7 @@ const mg = {
leaderboard, leaderboard,
hotSearch, hotSearch,
getMusicUrl(songInfo, type) { getMusicUrl(songInfo, type) {
return api_source('mg').getMusicUrl(songInfo, type) return apis('mg').getMusicUrl(songInfo, type)
}, },
getLyric(songInfo) { getLyric(songInfo) {
return lyric.getLyric(songInfo) return lyric.getLyric(songInfo)

View File

@ -2,7 +2,7 @@ import leaderboard from './leaderboard'
import lyric from './lyric' import lyric from './lyric'
import songList from './songList' import songList from './songList'
import musicSearch from './musicSearch' import musicSearch from './musicSearch'
import api_source from '../api-source' import { apis } from '../api-source'
import hotSearch from './hotSearch' import hotSearch from './hotSearch'
const tx = { const tx = {
@ -12,14 +12,14 @@ const tx = {
hotSearch, hotSearch,
getMusicUrl(songInfo, type) { getMusicUrl(songInfo, type) {
return api_source('tx').getMusicUrl(songInfo, type) return apis('tx').getMusicUrl(songInfo, type)
}, },
getLyric(songInfo) { getLyric(songInfo) {
// let singer = songInfo.singer.indexOf('、') > -1 ? songInfo.singer.split('、')[0] : songInfo.singer // let singer = songInfo.singer.indexOf('、') > -1 ? songInfo.singer.split('、')[0] : songInfo.singer
return lyric.getLyric(songInfo.songmid) return lyric.getLyric(songInfo.songmid)
}, },
getPic(songInfo) { getPic(songInfo) {
return api_source('tx').getPic(songInfo) return apis('tx').getPic(songInfo)
}, },
} }

View File

@ -8,14 +8,9 @@ import crypto from 'crypto'
const types = ['flac', 'wav', 'ape', '320k', '192k', '128k'] const types = ['flac', 'wav', 'ape', '320k', '192k', '128k']
export const getMusicType = (info, type) => { export const getMusicType = (info, type) => {
switch (info.source) { let list = window.globalObj.qualityList[info.source]
// case 'kg': if (!list) return '128k'
case 'wy': if (!list.includes(type)) type = list[list.length - 1]
case 'tx':
return '128k'
case 'xm':
if (type == 'wav') type = '320k'
}
const rangeType = types.slice(types.indexOf(type)) const rangeType = types.slice(types.indexOf(type))
for (const type of rangeType) { for (const type of rangeType) {
if (info._types[type]) return type if (info._types[type]) return type

View File

@ -1,5 +1,5 @@
import leaderboard from './leaderboard' import leaderboard from './leaderboard'
import api_source from '../api-source' import { apis } from '../api-source'
import getLyric from './lyric' import getLyric from './lyric'
import getMusicInfo from './musicInfo' import getMusicInfo from './musicInfo'
import musicSearch from './musicSearch' import musicSearch from './musicSearch'
@ -12,7 +12,7 @@ const wy = {
songList, songList,
hotSearch, hotSearch,
getMusicUrl(songInfo, type) { getMusicUrl(songInfo, type) {
return api_source('wy').getMusicUrl(songInfo, type) return apis('wy').getMusicUrl(songInfo, type)
}, },
getLyric(songInfo) { getLyric(songInfo) {
return getLyric(songInfo.songmid) return getLyric(songInfo.songmid)

View File

@ -1,4 +1,4 @@
import api_source from '../api-source' import { apis } from '../api-source'
import leaderboard from './leaderboard' import leaderboard from './leaderboard'
import songList from './songList' import songList from './songList'
import musicSearch from './musicSearch' import musicSearch from './musicSearch'
@ -14,7 +14,7 @@ const xm = {
hotSearch, hotSearch,
closeVerifyModal, closeVerifyModal,
getMusicUrl(songInfo, type) { getMusicUrl(songInfo, type) {
return api_source('xm').getMusicUrl(songInfo, type) return apis('xm').getMusicUrl(songInfo, type)
}, },
getLyric(songInfo) { getLyric(songInfo) {
return lyric.getLyric(songInfo) return lyric.getLyric(songInfo)

View File

@ -34,9 +34,6 @@ export default {
types() { types() {
return this.source ? this.sourceInfo.sourceList[this.source] : [] return this.source ? this.sourceInfo.sourceList[this.source] : []
}, },
isAPITemp() {
return this.setting.apiSource == 'temp'
},
}, },
watch: { watch: {
tabId(n, o) { tabId(n, o) {
@ -124,14 +121,7 @@ export default {
this.isShowDownload = false this.isShowDownload = false
}, },
handleAddDownloadMultiple(type) { handleAddDownloadMultiple(type) {
switch (this.source) { if (this.source == 'xm' && type == 'flac') type = 'wav'
// case 'kg':
case 'tx':
case 'wy':
type = '128k'
case 'xm':
if (type == 'flac') type = 'wav'
}
this.createDownloadMultiple({ list: [...this.selectdData], type }) this.createDownloadMultiple({ list: [...this.selectdData], type })
this.isShowDownloadMultiple = false this.isShowDownloadMultiple = false
this.resetSelect() this.resetSelect()

View File

@ -16,7 +16,7 @@
table table
tbody(@contextmenu="handleContextMenu" ref="dom_tbody") tbody(@contextmenu="handleContextMenu" ref="dom_tbody")
tr(v-for='(item, index) in list' :key='item.songmid' :id="'mid_' + item.songmid" tr(v-for='(item, index) in list' :key='item.songmid' :id="'mid_' + item.songmid"
@click="handleDoubleClick($event, index)" :class="[isPlayList && playIndex === index ? $style.active : '', (isAPITemp && item.source != 'kw') ? $style.disabled : '']") @click="handleDoubleClick($event, index)" :class="[isPlayList && playIndex === index ? $style.active : '', assertApiSupport(item.source) ? null : $style.disabled]")
td.nobreak.center(style="width: 37px;" :class="$style.noSelect" @click.stop) {{index + 1}} td.nobreak.center(style="width: 37px;" :class="$style.noSelect" @click.stop) {{index + 1}}
td.break(style="width: 25%;") td.break(style="width: 25%;")
span.select {{item.name}} span.select {{item.name}}
@ -49,7 +49,7 @@
<script> <script>
import { mapMutations, mapGetters, mapActions } from 'vuex' import { mapMutations, mapGetters, mapActions } from 'vuex'
import { throttle, scrollTo, clipboardWriteText } from '../utils' import { throttle, scrollTo, clipboardWriteText, assertApiSupport } from '../utils'
export default { export default {
name: 'List', name: 'List',
data() { data() {
@ -88,9 +88,6 @@ export default {
list() { list() {
return this.listData.list return this.listData.list
}, },
isAPITemp() {
return this.setting.apiSource == 'temp'
},
listData() { listData() {
if (!this.listId) return this.defaultList if (!this.listId) return this.defaultList
let targetList let targetList
@ -333,7 +330,7 @@ export default {
} }
}, },
testPlay(index) { testPlay(index) {
if (this.isAPITemp && this.list[index].source != 'kw') return if (!this.assertApiSupport(this.list[index].source)) return
this.setPlayList({ list: this.list, listId: this.listId, index }) this.setPlayList({ list: this.list, listId: this.listId, index })
}, },
handleRemove(index) { handleRemove(index) {
@ -343,7 +340,7 @@ export default {
switch (info.action) { switch (info.action) {
case 'download': { case 'download': {
const minfo = this.list[info.index] const minfo = this.list[info.index]
if (this.isAPITemp && minfo.source != 'kw') return if (!this.assertApiSupport(minfo.source)) return
this.musicInfo = minfo this.musicInfo = minfo
this.$nextTick(() => { this.$nextTick(() => {
this.isShowDownload = true this.isShowDownload = true
@ -378,7 +375,7 @@ export default {
// asyncSetArray(this.selectdData, isSelect ? [...this.list] : []) // asyncSetArray(this.selectdData, isSelect ? [...this.list] : [])
}, },
handleAddDownloadMultiple(type) { handleAddDownloadMultiple(type) {
const list = this.setting.apiSource == 'temp' ? this.selectdData.filter(s => s.source == 'kw') : [...this.selectdData] const list = this.selectdData.filter(s => this.assertApiSupport(s.source))
this.createDownloadMultiple({ list, type }) this.createDownloadMultiple({ list, type })
this.removeAllSelect() this.removeAllSelect()
this.isShowDownloadMultiple = false this.isShowDownloadMultiple = false
@ -420,6 +417,9 @@ export default {
clipboardWriteText(str) clipboardWriteText(str)
}) })
}, },
assertApiSupport(source) {
return assertApiSupport(source)
},
}, },
} }
</script> </script>

View File

@ -30,8 +30,8 @@
span.select {{item.albumName}} span.select {{item.albumName}}
td(style="width: 15%; padding-left: 0; padding-right: 0;") td(style="width: 15%; padding-left: 0; padding-right: 0;")
material-list-buttons(:index="index" :remove-btn="false" :class="$style.listBtn" material-list-buttons(:index="index" :remove-btn="false" :class="$style.listBtn"
:play-btn="item.source == 'kw' || !isAPITemp" :play-btn="assertApiSupport(item.source)"
:download-btn="item.source == 'kw' || !isAPITemp" :download-btn="assertApiSupport(item.source)"
@btn-click="handleListBtnClick") @btn-click="handleListBtnClick")
td(style="width: 10%;") td(style="width: 10%;")
span(:class="[$style.time, $style.noSelect]") {{item.interval || '--/--'}} span(:class="[$style.time, $style.noSelect]") {{item.interval || '--/--'}}
@ -53,14 +53,14 @@
p {{$t('view.search.no_item')}} p {{$t('view.search.no_item')}}
material-download-modal(:show="isShowDownload" :musicInfo="musicInfo" @select="handleAddDownload" @close="isShowDownload = false") material-download-modal(:show="isShowDownload" :musicInfo="musicInfo" @select="handleAddDownload" @close="isShowDownload = false")
material-download-multiple-modal(:show="isShowDownloadMultiple" :list="selectdData" @select="handleAddDownloadMultiple" @close="isShowDownloadMultiple = false") material-download-multiple-modal(:show="isShowDownloadMultiple" :list="selectdData" @select="handleAddDownloadMultiple" @close="isShowDownloadMultiple = false")
material-flow-btn(:show="isShowEditBtn && (searchSourceId == 'kw' || searchSourceId == 'all' || !isAPITemp)" :remove-btn="false" @btn-click="handleFlowBtnClick") material-flow-btn(:show="isShowEditBtn && (searchSourceId == 'all' || assertApiSupport(searchSourceId))" :remove-btn="false" @btn-click="handleFlowBtnClick")
material-list-add-modal(:show="isShowListAdd" :musicInfo="musicInfo" @close="isShowListAdd = false") material-list-add-modal(:show="isShowListAdd" :musicInfo="musicInfo" @close="isShowListAdd = false")
material-list-add-multiple-modal(:show="isShowListAddMultiple" :musicList="selectdData" @close="handleListAddModalClose") material-list-add-multiple-modal(:show="isShowListAddMultiple" :musicList="selectdData" @close="handleListAddModalClose")
</template> </template>
<script> <script>
import { mapGetters, mapActions, mapMutations } from 'vuex' import { mapGetters, mapActions, mapMutations } from 'vuex'
import { scrollTo, clipboardWriteText } from '../utils' import { scrollTo, clipboardWriteText, assertApiSupport } from '../utils'
// import music from '../utils/music' // import music from '../utils/music'
export default { export default {
name: 'Search', name: 'Search',
@ -151,9 +151,6 @@ export default {
listInfo() { listInfo() {
return this.setting.search.searchSource == 'all' ? this.allList : this.sourceList[this.setting.search.searchSource] return this.setting.search.searchSource == 'all' ? this.allList : this.sourceList[this.setting.search.searchSource]
}, },
isAPITemp() {
return this.setting.apiSource == 'temp'
},
hotSearchList() { hotSearchList() {
return this.$store.getters['hotSearch/list'][this.setting.search.searchSource] || [] return this.$store.getters['hotSearch/list'][this.setting.search.searchSource] || []
}, },
@ -303,7 +300,7 @@ export default {
targetSong = this.selectdData[0] targetSong = this.selectdData[0]
this.listAddMultiple({ id: 'default', list: this.filterList(this.selectdData) }) this.listAddMultiple({ id: 'default', list: this.filterList(this.selectdData) })
} else { } else {
if (this.isAPITemp && this.listInfo.list[index].source != 'kw') return if (!this.assertApiSupport(this.listInfo.list[index].source)) return
targetSong = this.listInfo.list[index] targetSong = this.listInfo.list[index]
this.listAdd({ id: 'default', musicInfo: targetSong }) this.listAdd({ id: 'default', musicInfo: targetSong })
} }
@ -353,7 +350,10 @@ export default {
} }
}, },
filterList(list) { filterList(list) {
return this.setting.apiSource == 'temp' ? list.filter(s => s.source == 'kw') : [...list] return this.searchSourceId == 'all'
? list.filter(s => this.assertApiSupport(s.source))
: this.assertApiSupport(this.searchSourceId)
? [...list] : []
}, },
handleListAddModalClose(isClearSelect) { handleListAddModalClose(isClearSelect) {
if (isClearSelect) this.removeAllSelect() if (isClearSelect) this.removeAllSelect()
@ -383,6 +383,9 @@ export default {
}, },
}) })
}, },
assertApiSupport(source) {
return assertApiSupport(source)
},
}, },
} }
</script> </script>

View File

@ -60,7 +60,7 @@
<script> <script>
import { mapGetters, mapMutations, mapActions } from 'vuex' import { mapGetters, mapMutations, mapActions } from 'vuex'
import { scrollTo } from '../utils' import { scrollTo, assertApiSupport } from '../utils'
// import music from '../utils/music' // import music from '../utils/music'
export default { export default {
name: 'SongList', name: 'SongList',
@ -108,9 +108,6 @@ export default {
} }
return list return list
}, },
isAPITemp() {
return this.setting.apiSource == 'temp'
},
tagList() { tagList() {
let tagInfo = this.tags[this.source] let tagInfo = this.tags[this.source]
return tagInfo ? [{ name: '热门标签', list: [...tagInfo.hotTag] }, ...tagInfo.tags] : [] return tagInfo ? [{ name: '热门标签', list: [...tagInfo.hotTag] }, ...tagInfo.tags] : []
@ -208,7 +205,7 @@ export default {
this.resetSelect() this.resetSelect()
} else { } else {
targetSong = this.listDetail.list[index] targetSong = this.listDetail.list[index]
if (this.isAPITemp && targetSong.source != 'kw') return if (!this.assertApiSupport(targetSong.source)) return
this.listAdd({ id: 'default', musicInfo: targetSong }) this.listAdd({ id: 'default', musicInfo: targetSong })
} }
let targetIndex = this.defaultList.list.findIndex( let targetIndex = this.defaultList.list.findIndex(
@ -250,14 +247,7 @@ export default {
this.isShowDownload = false this.isShowDownload = false
}, },
handleAddDownloadMultiple(type) { handleAddDownloadMultiple(type) {
switch (this.source) { if (this.source == 'xm' && type == 'flac') type = 'wav'
// case 'kg':
case 'tx':
case 'wy':
type = '128k'
case 'xm':
if (type == 'flac') type = 'wav'
}
this.createDownloadMultiple({ list: this.filterList(this.selectdData), type }) this.createDownloadMultiple({ list: this.filterList(this.selectdData), type })
this.resetSelect() this.resetSelect()
this.isShowDownloadMultiple = false this.isShowDownloadMultiple = false
@ -334,7 +324,7 @@ export default {
this.handleGetListDetail(this.importSongListText, 1) this.handleGetListDetail(this.importSongListText, 1)
}, },
filterList(list) { filterList(list) {
return this.setting.apiSource == 'temp' ? list.filter(s => s.source == 'kw') : [...list] return list.filter(s => this.assertApiSupport(s.source))
}, },
setTagListWidth() { setTagListWidth() {
this.isInitedTagListWidth = true this.isInitedTagListWidth = true
@ -347,6 +337,9 @@ export default {
return Promise.reject(err) return Promise.reject(err)
}) })
}, },
assertApiSupport(source) {
return assertApiSupport(source)
},
/* addSongListDetail() { /* addSongListDetail() {
// this.detailLoading = true // this.detailLoading = true
// this.getListDetailAll(this.selectListInfo.id).then(() => { // this.getListDetailAll(this.selectListInfo.id).then(() => {