Merge branch 'dev' into v1

This commit is contained in:
lyswhut
2020-05-07 20:38:03 +08:00
12 changed files with 95 additions and 61 deletions
+3 -3
View File
@@ -617,12 +617,12 @@ export default {
},
async setMediaDevice() {
let mediaDeviceId = this.setting.player.mediaDeviceId
if (!mediaDeviceId) return
const devices = await navigator.mediaDevices.enumerateDevices()
let device = devices.find(device => device.deviceId === mediaDeviceId)
if (!device) return this.setMediaDeviceId('default')
const deviceId = device ? device.deviceId : 'default'
// console.log(device)
this.audio.setSinkId(device.deviceId).catch((err) => {
this.audio.setSinkId(deviceId).catch(err => {
console.log(err)
this.setMediaDeviceId('default')
})
+28 -30
View File
@@ -1,41 +1,38 @@
import mousetrap from 'mousetrap'
let eventHub
const bindKeys = [
'shift',
'mod',
'mod+a',
]
const bindKey = () => {
mousetrap.reset()
mousetrap.bind('shift', (event, combo) => {
eventHub.$emit('key_shift_down', { event, combo })
return false
}, 'keydown')
mousetrap.bind('shift', (event, combo) => {
eventHub.$emit('key_shift_up', { event, combo })
return false
}, 'keyup')
mousetrap.bind('mod', (event, combo) => {
eventHub.$emit('key_mod_down', { event, combo })
return false
}, 'keydown')
mousetrap.bind('mod', (event, combo) => {
eventHub.$emit('key_mod_up', { event, combo })
return false
}, 'keyup')
mousetrap.bind('mod+a', (event, combo) => {
eventHub.$emit('key_mod+a_down', { event, combo })
return false
}, 'keydown')
mousetrap.bind('mod+a', (event, combo) => {
eventHub.$emit('key_mod+a_up', { event, combo })
return false
}, 'keyup')
for (const key of bindKeys) {
mousetrap.bind(key, (event, combo) => {
eventHub.$emit(`key_${key}_down`, { event, combo })
return false
}, 'keydown')
mousetrap.bind(key, (event, combo) => {
eventHub.$emit(`key_${key}_up`, { event, combo })
return false
}, 'keyup')
}
}
const unbindKey = () => {
mousetrap.unbind('shift', 'keydown')
mousetrap.unbind('shift', 'keyup')
mousetrap.unbind('mod', 'keydown')
mousetrap.unbind('mod', 'keyup')
mousetrap.unbind('mod+a', 'keydown')
mousetrap.unbind('mod+a', 'keyup')
for (const key of bindKeys) {
mousetrap.unbind(key, 'keydown')
mousetrap.unbind(key, 'keyup')
}
}
const handleFocus = () => {
for (const key of bindKeys) {
eventHub.$emit(`key_${key}_up`, { combo: key })
}
}
export default () => {
@@ -43,4 +40,5 @@ export default () => {
eventHub.$on('bindKey', bindKey)
eventHub.$on('unbindKey', unbindKey)
eventHub.$on('focus', handleFocus)
}
+11
View File
@@ -0,0 +1,11 @@
import Vue from 'vue'
import bindkey from './bindkey'
import { rendererOn } from '../../common/ipc'
window.eventHub = new Vue()
bindkey()
rendererOn('focus', () => {
window.eventHub.$emit('focus')
})
+2 -6
View File
@@ -1,6 +1,8 @@
import Vue from 'vue'
import { sync } from 'vuex-router-sync'
import './config/event'
// Components
import './components'
@@ -14,14 +16,8 @@ import store from './store'
import '../common/error'
import bindkey from './config/bindkey'
sync(store, router)
window.eventHub = new Vue()
bindkey()
Vue.config.productionTip = false
new Vue({
+8 -5
View File
@@ -68,7 +68,7 @@ const getStartTask = (list, downloadStatus, maxDownloadNum) => {
let downloadCount = 0
const waitList = list.filter(item => item.status == downloadStatus.WAITING ? true : (item.status === downloadStatus.RUN && ++downloadCount && false))
// console.log(downloadCount, waitList)
return downloadCount < maxDownloadNum && waitList.length > 0 && waitList.shift()
return downloadCount < maxDownloadNum ? waitList.shift() || null : false
}
const awaitRequestAnimationFrame = () => new Promise(resolve => window.requestAnimationFrame(() => resolve()))
@@ -409,11 +409,14 @@ const actions = {
async startTask({ state, rootState, commit, dispatch }, downloadInfo) {
// 检查是否可以开始任务
let result = getStartTask(state.list, state.downloadStatus, rootState.setting.download.maxDownloadNum)
if (result) {
if (!downloadInfo || downloadInfo.isComplate || downloadInfo.status == state.downloadStatus.RUN) downloadInfo = result
if (downloadInfo && !downloadInfo.isComplate && downloadInfo.status != state.downloadStatus.RUN) {
if (result === false) {
commit('setStatus', { downloadInfo, status: state.downloadStatus.WAITING })
return
}
} else {
if (downloadInfo) commit('setStatus', { downloadInfo, status: state.downloadStatus.WAITING })
return
if (!result) return
downloadInfo = result
}
let dl = dls[downloadInfo.key]
+1 -1
View File
@@ -201,7 +201,7 @@ export const updateSetting = (setting, version) => {
},
list: {
isShowAlbumName: true,
isShowSource: false,
isShowSource: true,
scroll: {
enable: true,
locations: {},
+3 -1
View File
@@ -614,7 +614,9 @@ export default {
},
async getMediaDevice() {
const devices = await navigator.mediaDevices.enumerateDevices()
const audioDevices = devices.filter(device => device.kind === 'audiooutput')
let audioDevices = devices.filter(device => device.kind === 'audiooutput')
let currentId = this.current_setting.player.mediaDeviceId
if (!audioDevices.some(device => device.deviceId === currentId)) this.current_setting.player.mediaDeviceId = 'default'
this.mediaDevices = audioDevices
// console.log(this.mediaDevices)
},