分离可用音质控制逻辑
This commit is contained in:
@@ -56,7 +56,7 @@ div(:class="$style.player")
|
||||
<script>
|
||||
import Lyric from 'lrc-file-parser'
|
||||
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 { requestMsg } from '../../utils/message'
|
||||
import { isMac } from '../../../common/utils'
|
||||
@@ -125,9 +125,6 @@ export default {
|
||||
progress() {
|
||||
return this.nowPlayTime / this.maxPlayTime || 0
|
||||
},
|
||||
isAPITemp() {
|
||||
return this.setting.apiSource == 'temp'
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
@@ -368,10 +365,8 @@ export default {
|
||||
const filePath = path.join(this.setting.download.savePath, item.fileName)
|
||||
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 {
|
||||
list = this.list
|
||||
list = this.list.filter(s => this.assertApiSupport(s.source))
|
||||
}
|
||||
return list
|
||||
},
|
||||
@@ -379,7 +374,7 @@ export default {
|
||||
// console.log(playIndex)
|
||||
let list = await this.filterList()
|
||||
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
|
||||
switch (this.setting.player.togglePlayMethod) {
|
||||
case 'random':
|
||||
@@ -393,14 +388,14 @@ export default {
|
||||
return
|
||||
}
|
||||
if (index < 0) return
|
||||
if (this.list !== list) index = this.list.indexOf(list[index])
|
||||
index = this.list.indexOf(list[index])
|
||||
this.setPlayIndex(index)
|
||||
},
|
||||
async handleNext() {
|
||||
// if (this.list.listName === null) return
|
||||
let list = await this.filterList()
|
||||
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)
|
||||
let index
|
||||
switch (this.setting.player.togglePlayMethod) {
|
||||
@@ -417,7 +412,7 @@ export default {
|
||||
return
|
||||
}
|
||||
if (index < 0) return
|
||||
if (this.list !== list) index = this.list.indexOf(list[index])
|
||||
index = this.list.indexOf(list[index])
|
||||
this.setPlayIndex(index)
|
||||
},
|
||||
hanldeListRandom(list, index) {
|
||||
@@ -470,14 +465,9 @@ export default {
|
||||
this.musicInfo.img = null
|
||||
},
|
||||
getPlayType(highQuality, songInfo) {
|
||||
switch (songInfo.source) {
|
||||
case 'wy':
|
||||
case 'tx':
|
||||
return '128k'
|
||||
// case 'kg':
|
||||
}
|
||||
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
|
||||
},
|
||||
setUrl(targetSong, isRefresh, isRetryed = false) {
|
||||
@@ -654,6 +644,9 @@ export default {
|
||||
break
|
||||
}
|
||||
},
|
||||
assertApiSupport(source) {
|
||||
return assertApiSupport(source)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -29,6 +29,9 @@ export default {
|
||||
info() {
|
||||
return this.musicInfo || {}
|
||||
},
|
||||
qualityList() {
|
||||
return window.globalObj.qualityList[this.musicInfo.source]
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleClick(type) {
|
||||
@@ -51,16 +54,7 @@ export default {
|
||||
}
|
||||
},
|
||||
checkSource(type) {
|
||||
switch (this.musicInfo.source) {
|
||||
case 'wy':
|
||||
case 'tx':
|
||||
return type == '128k'
|
||||
case 'xm':
|
||||
return type == '128k' || type == '320k'
|
||||
|
||||
default:
|
||||
return true
|
||||
}
|
||||
return this.qualityList.includes(type)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ div(:class="$style.songList")
|
||||
td(style="width: 20%; padding-left: 0; padding-right: 0;")
|
||||
material-list-buttons(:index="index" :search-btn="true"
|
||||
:remove-btn="false" @btn-click="handleListBtnClick"
|
||||
:listAdd-btn="item.source == 'kw' || !isAPITemp"
|
||||
:play-btn="item.source == 'kw' || !isAPITemp"
|
||||
:download-btn="item.source == 'kw' || !isAPITemp")
|
||||
:listAdd-btn="assertApiSupport(item.source)"
|
||||
:play-btn="assertApiSupport(item.source)"
|
||||
: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-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)') +
|
||||
@@ -41,12 +41,12 @@ div(:class="$style.songList")
|
||||
transition(enter-active-class="animated-fast fadeIn" leave-active-class="animated-fast fadeOut")
|
||||
div(v-show="!list.length" :class="$style.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>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import { scrollTo, clipboardWriteText } from '../../utils'
|
||||
import { scrollTo, clipboardWriteText, assertApiSupport } from '../../utils'
|
||||
export default {
|
||||
name: 'MaterialSongList',
|
||||
model: {
|
||||
@@ -86,9 +86,6 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['setting']),
|
||||
isAPITemp() {
|
||||
return this.setting.apiSource == 'temp'
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
selectdList(n) {
|
||||
@@ -185,7 +182,7 @@ export default {
|
||||
this.clickIndex = index
|
||||
return
|
||||
}
|
||||
this.emitEvent((this.source == 'kw' || !this.isAPITemp) ? 'testPlay' : 'search', index)
|
||||
this.emitEvent(this.assertApiSupport(this.source) ? 'testPlay' : 'search', index)
|
||||
this.clickTime = 0
|
||||
this.clickIndex = -1
|
||||
},
|
||||
@@ -274,6 +271,9 @@ export default {
|
||||
clipboardWriteText(str)
|
||||
})
|
||||
},
|
||||
assertApiSupport(source) {
|
||||
return assertApiSupport(source)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user