新增快捷键设置

This commit is contained in:
lyswhut
2020-06-24 01:20:56 +08:00
parent 2424c76c50
commit 9b82cdfe53
58 changed files with 2254 additions and 1450 deletions
+109
View File
@@ -0,0 +1,109 @@
const { player: hotKeyPlayer, common: hotKeyCommon, desktop_lyric: hotKeyDesktopLyric } = require('./hotKey')
module.exports = {
local: {
enable: true,
keys: {
'mod+f5': {
type: hotKeyPlayer.toggle_play.type,
name: hotKeyPlayer.toggle_play.name,
action: hotKeyPlayer.toggle_play.action,
},
'mod+left': {
type: hotKeyPlayer.prev.type,
name: hotKeyPlayer.prev.name,
action: hotKeyPlayer.prev.action,
},
'mod+right': {
type: hotKeyPlayer.next.type,
name: hotKeyPlayer.next.name,
action: hotKeyPlayer.next.action,
},
f1: {
type: hotKeyCommon.focusSearchInput.type,
name: hotKeyCommon.focusSearchInput.name,
action: hotKeyCommon.focusSearchInput.action,
},
'mod+w': {
type: hotKeyCommon.min.type,
name: hotKeyCommon.min.name,
action: hotKeyCommon.min.action,
},
},
},
global: {
enable: false,
keys: {
MediaPlayPause: {
type: hotKeyPlayer.toggle_play.type,
name: null,
action: hotKeyPlayer.toggle_play.action,
},
MediaPreviousTrack: {
type: hotKeyPlayer.prev.type,
name: null,
action: hotKeyPlayer.prev.action,
},
MediaNextTrack: {
type: hotKeyPlayer.next.type,
name: null,
action: hotKeyPlayer.next.action,
},
VolumeUp: {
type: hotKeyPlayer.volume_up.type,
name: null,
action: hotKeyPlayer.volume_up.action,
},
VolumeDown: {
type: hotKeyPlayer.volume_down.type,
name: null,
action: hotKeyPlayer.volume_down.action,
},
VolumeMute: {
type: hotKeyPlayer.volume_mute.type,
name: null,
action: hotKeyPlayer.volume_mute.action,
},
'mod+alt+f5': {
type: hotKeyPlayer.toggle_play.type,
name: hotKeyPlayer.toggle_play.name,
action: hotKeyPlayer.toggle_play.action,
},
'mod+alt+left': {
type: hotKeyPlayer.prev.type,
name: hotKeyPlayer.prev.name,
action: hotKeyPlayer.prev.action,
},
'mod+alt+right': {
type: hotKeyPlayer.next.type,
name: hotKeyPlayer.next.name,
action: hotKeyPlayer.next.action,
},
'mod+alt+up': {
type: hotKeyPlayer.volume_up.type,
name: hotKeyPlayer.volume_up.name,
action: hotKeyPlayer.volume_up.action,
},
'mod+alt+down': {
type: hotKeyPlayer.volume_down.type,
name: hotKeyPlayer.volume_down.name,
action: hotKeyPlayer.volume_down.action,
},
'mod+alt+0': {
type: hotKeyDesktopLyric.toggle_visible.type,
name: hotKeyDesktopLyric.toggle_visible.name,
action: hotKeyDesktopLyric.toggle_visible.action,
},
'mod+alt+-': {
type: hotKeyDesktopLyric.toggle_lock.type,
name: hotKeyDesktopLyric.toggle_lock.name,
action: hotKeyDesktopLyric.toggle_lock.action,
},
'mod+alt+=': {
type: hotKeyDesktopLyric.toggle_always_top.type,
name: hotKeyDesktopLyric.toggle_always_top.name,
action: hotKeyDesktopLyric.toggle_always_top.action,
},
},
},
}
+2 -1
View File
@@ -3,12 +3,13 @@ const os = require('os')
const { isMac } = require('./utils')
const defaultSetting = {
version: '1.0.30',
version: '1.0.31',
player: {
togglePlayMethod: 'listLoop',
highQuality: false,
isShowTaskProgess: true,
volume: 1,
isMute: false,
mediaDeviceId: 'default',
isMediaDeviceRemovedStopPlay: false,
},
+83
View File
@@ -0,0 +1,83 @@
const names = require('../main/events/_name')
const hotKey = {
common: {
min: {
name: 'min',
action: 'min',
},
min_toggle: {
name: 'toggle_min',
action: 'toggle_min',
},
hide_toggle: {
name: 'toggle_hide',
action: 'toggle_hide',
},
close: {
name: 'toggle_close',
action: 'toggle_close',
},
focusSearchInput: {
name: 'focus_search_input',
action: 'focus_search_input',
},
},
player: {
toggle_play: {
name: 'toggle_play',
action: 'toggle_play',
},
next: {
name: 'next',
action: 'next',
},
prev: {
name: 'prev',
action: 'prev',
},
volume_up: {
name: 'volume_up',
action: 'volume_up',
},
volume_down: {
name: 'volume_down',
action: 'volume_down',
},
volume_mute: {
name: 'volume_mute',
action: 'volume_mute',
},
},
desktop_lyric: {
toggle_visible: {
name: 'toggle_visible',
action: 'toggle_visible',
},
toggle_lock: {
name: 'toggle_lock',
action: 'toggle_lock',
},
toggle_always_top: {
name: 'toggle_always_top',
action: 'toggle_always_top',
},
},
}
const keyName = {
player: names.mainWindow.name,
desktop_lyric: names.winLyric.name,
}
for (const type of Object.keys(hotKey)) {
let item = hotKey[type]
for (const key of Object.keys(item)) {
item[key].action = `${type}_${item[key].action}`
item[key].name = `${type}_${item[key].name}`
item[key].type = keyName[type]
}
}
exports.common = hotKey.common
exports.player = hotKey.player
exports.desktop_lyric = hotKey.desktop_lyric
+12
View File
@@ -36,6 +36,11 @@ const names = {
get_lyric_info: 'get_lyric_info',
set_lyric_info: 'set_lyric_info',
set_config: 'set_config',
set_hot_key_config: 'set_hot_key_config',
key_down: 'key_down',
quit: 'quit',
min_toggle: 'min_toggle',
hide_toggle: 'hide_toggle',
},
winLyric: {
close: 'close',
@@ -44,6 +49,12 @@ const names = {
set_lyric_config: 'set_lyric_config',
get_lyric_config: 'get_lyric_config',
set_win_bounds: 'set_win_bounds',
key_down: 'key_down',
},
hotKey: {
enable: 'enable',
status: 'status',
set_config: 'set_config',
},
}
@@ -56,3 +67,4 @@ for (const item of Object.keys(names)) {
exports.mainWindow = names.mainWindow
exports.winLyric = names.winLyric
exports.hotKey = names.hotKey
+27
View File
@@ -2,6 +2,7 @@ const log = require('electron-log')
const Store = require('electron-store')
const { defaultSetting, overwriteSetting } = require('./defaultSetting')
const apiSource = require('../renderer/utils/music/api-source-info')
const defaultHotKey = require('./defaultHotKey')
exports.isLinux = process.platform == 'linux'
exports.isWin = process.platform == 'win32'
@@ -169,3 +170,29 @@ exports.initSetting = () => {
electronStore_config.set('setting', newSetting)
return newSetting
}
/**
* 初始化快捷键设置
*/
exports.initHotKey = () => {
const electronStore_hotKey = new Store({
name: 'hotKey',
})
let localConfig = electronStore_hotKey.get('local')
if (!localConfig) {
localConfig = defaultHotKey.local
electronStore_hotKey.set('local', localConfig)
}
let globalConfig = electronStore_hotKey.get('global')
if (!globalConfig) {
globalConfig = defaultHotKey.global
electronStore_hotKey.set('global', globalConfig)
}
return {
global: globalConfig,
local: localConfig,
}
}