全部播放功能

This commit is contained in:
LasyIsLazy 2020-08-17 15:32:31 +08:00
parent 9aeae1e460
commit 1bcf0c92ac
10 changed files with 53 additions and 4 deletions

View File

@ -0,0 +1,13 @@
const { globalShortcut, app } = require('electron')
app.on('ready', function() {
globalShortcut.register('CommandOrControl+Alt+P', function() {
global.mainWindow.webContents.send('player:togglePlay')
})
globalShortcut.register('CommandOrControl+Alt+Right', function() {
global.mainWindow.webContents.send('player:next')
})
})
app.on('will-quit', function() {
globalShortcut.unregisterAll()
})

View File

@ -515,6 +515,9 @@ export default {
window.getComputedStyle(this.$refs.dom_progress, null).width,
)
},
/**
* 播放/暂停
*/
togglePlay() {
if (!audio.src) return
if (this.isPlay) {

View File

@ -1,6 +1,7 @@
{
"lists_new_list_btn": "Create list",
"lists_new_list_input": "New list...",
"lists_play": "Play",
"lists_rename": "Rename",
"lists_moveup": "Move Up",
"lists_movedown": "Move Down",

View File

@ -1,4 +1,5 @@
{
"play_all": "Play All",
"back": "Back",
"loding_list": "Loading the list...",
"loding_list_fail": "List loading failed",

View File

@ -1,6 +1,7 @@
{
"lists_new_list_btn": "新建列表",
"lists_new_list_input": "新列表...",
"lists_play": "播放",
"lists_rename": "重命名",
"lists_moveup": "上移",
"lists_movedown": "下移",

View File

@ -1,4 +1,5 @@
{
"play_all": "播放全部",
"back": "返回",
"loding_list": "列表加载中...",
"loding_list_fail": "列表加载失败",

View File

@ -1,6 +1,7 @@
{
"lists_new_list_btn": "新建列表",
"lists_new_list_input": "新列表...",
"lists_play": "播放",
"lists_rename": "重命名",
"lists_moveup": "上移",
"lists_movedown": "下移",

View File

@ -1,4 +1,5 @@
{
"play_all": "播放全部",
"back": "返回",
"loding_list": "列表加载中...",
"loding_list_fail": "列表加載失敗",

View File

@ -7,9 +7,9 @@
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='70%' viewBox='0 0 24 24' space='preserve')
use(xlink:href='#icon-list-add')
ul.scroll(:class="$style.listsContent" ref="dom_lists_list")
li(:class="[$style.listsItem, defaultList.id == listId ? $style.active : null]" :title="defaultList.name" @click="handleListToggle(defaultList.id)")
li(:class="[$style.listsItem, defaultList.id == listId ? $style.active : null]" :title="defaultList.name" @click="handleListToggle(defaultList.id)" @contextmenu="handleListsItemRigthClick($event, -2)")
span(:class="$style.listsLabel") {{defaultList.name}}
li(:class="[$style.listsItem, loveList.id == listId ? $style.active : null]" :title="loveList.name" @click="handleListToggle(loveList.id)")
li(:class="[$style.listsItem, loveList.id == listId ? $style.active : null]" :title="loveList.name" @click="handleListToggle(loveList.id)" @contextmenu="handleListsItemRigthClick($event, -1)")
span(:class="$style.listsLabel") {{loveList.name}}
li.user-list(:class="[$style.listsItem, item.id == listId ? $style.active : null, listsData.rightClickItemIndex == index ? $style.clicked : null]" @contextmenu="handleListsItemRigthClick($event, index)" :title="item.name" v-for="(item, index) in userList" :key="item.id")
span(:class="$style.listsLabel" @click="handleListToggle(item.id, index + 2)") {{item.name}}
@ -100,6 +100,7 @@ export default {
listsData: {
isShowItemMenu: false,
itemMenuControl: {
play: true,
rename: true,
moveup: true,
movedown: true,
@ -176,6 +177,11 @@ export default {
},
listsItemMenu() {
return [
{
name: this.$t('view.list.lists_play'),
action: 'play',
disabled: !this.listsData.itemMenuControl.play,
},
{
name: this.$t('view.list.lists_rename'),
action: 'rename',
@ -661,6 +667,7 @@ export default {
let location = offsetTop - 150
if (location > 0) this.$refs.dom_lists_list.scrollTop = location
},
/** 切换歌单为激活状态 */
handleListToggle(id) {
if (id == this.listId) return
this.$router.push({
@ -669,8 +676,10 @@ export default {
}).catch(_ => _)
},
handleListsItemRigthClick(event, index) {
// console.log('handleListsItemRigthClick', index)
this.listsData.itemMenuControl.moveup = index > 0
this.listsData.itemMenuControl.movedown = index < this.userList.length - 1
this.listsData.itemMenuControl.movedown = index >= 0 && index < this.userList.length - 1
this.listsData.itemMenuControl.remove = this.listsData.itemMenuControl.rename = index > 0
this.listsData.rightClickItemIndex = index
this.listsData.menuLocation.x = event.currentTarget.offsetLeft + event.offsetX
this.listsData.menuLocation.y = event.currentTarget.offsetTop + event.offsetY - this.$refs.dom_lists_list.scrollTop
@ -708,6 +717,13 @@ export default {
this.listsData.isShowItemMenu = false
let dom
switch (action && action.action) {
case 'play':
this.handleListToggle(this.lists[index + 2].id)
// console.log('play--', index, this.lists[index + 2])
this.$nextTick(() => {
this.testPlay(0)
})
break
case 'rename':
dom = this.$refs.dom_lists_list.querySelectorAll('.user-list')[index]
this.$nextTick(() => {

View File

@ -14,6 +14,7 @@
//- | &nbsp;
//- material-btn(:class="$style.closeDetailButton" :disabled="detailLoading" @click="playSongListDetail")
//- | &nbsp;
material-btn(:class="$style.closeDetailButton" @click="playAll") {{$t('view.song_list.play_all')}}
material-btn(:class="$style.closeDetailButton" @click="hideListDetail") {{$t('view.song_list.back')}}
material-song-list(v-model="selectedData" @action="handleSongListAction" :source="source" :page="listDetail.page" :limit="listDetail.limit"
:total="listDetail.total" :noItem="isGetDetailFailed ? $t('view.song_list.loding_list_fail') : $t('view.song_list.loding_list')" :list="listDetail.list")
@ -359,6 +360,14 @@ export default {
this.setTagListWidth()
}, 50)
},
playAll() {
if (this.listDetail.list.length) {
const filterList = this.filterList(this.listDetail.list)
this.listAddMultiple({ id: 'default', list: filterList })
this.resetSelect()
this.testPlay(0)
}
},
handleListAddModalClose(isSelect) {
if (isSelect) this.resetSelect()
this.isShowListAddMultiple = false
@ -515,7 +524,9 @@ export default {
flex: none;
display: flex;
align-items: center;
padding-right: 15px;
> * {
margin-right: 15px;
}
}
.song-list-detail-content {