mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 14:18:03 +00:00
feat: custom shortcuts
This commit is contained in:
parent
78d90f15f5
commit
e54c606c6d
9 changed files with 439 additions and 56 deletions
47
src/utils/shortcuts.js
Normal file
47
src/utils/shortcuts.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// default shortcuts
|
||||
// for more info, check https://www.electronjs.org/docs/api/accelerator
|
||||
|
||||
export default [
|
||||
{
|
||||
id: 'play',
|
||||
name: '播放/暂停',
|
||||
shortcut: 'CommandOrControl+P',
|
||||
globalShortcut: 'Alt+CommandOrControl+P',
|
||||
},
|
||||
{
|
||||
id: 'next',
|
||||
name: '下一首',
|
||||
shortcut: 'CommandOrControl+Right',
|
||||
globalShortcut: 'Alt+CommandOrControl+Right',
|
||||
},
|
||||
{
|
||||
id: 'previous',
|
||||
name: '上一首',
|
||||
shortcut: 'CommandOrControl+Left',
|
||||
globalShortcut: 'Alt+CommandOrControl+Left',
|
||||
},
|
||||
{
|
||||
id: 'increaseVolume',
|
||||
name: '增加音量',
|
||||
shortcut: 'CommandOrControl+Up',
|
||||
globalShortcut: 'Alt+CommandOrControl+Up',
|
||||
},
|
||||
{
|
||||
id: 'decreaseVolume',
|
||||
name: '减少音量',
|
||||
shortcut: 'CommandOrControl+Down',
|
||||
globalShortcut: 'Alt+CommandOrControl+Down',
|
||||
},
|
||||
{
|
||||
id: 'like',
|
||||
name: '喜欢歌曲',
|
||||
shortcut: 'CommandOrControl+L',
|
||||
globalShortcut: 'Alt+CommandOrControl+L',
|
||||
},
|
||||
{
|
||||
id: 'minimize',
|
||||
name: '隐藏/显示播放器',
|
||||
shortcut: 'CommandOrControl+M',
|
||||
globalShortcut: 'Alt+CommandOrControl+M',
|
||||
},
|
||||
];
|
||||
|
|
@ -8,6 +8,21 @@ const updateSetting = () => {
|
|||
...parsedSettings,
|
||||
};
|
||||
|
||||
if (
|
||||
settings.shortcuts.length !== initLocalStorage.settings.shortcuts.length
|
||||
) {
|
||||
// 当新增 shortcuts 时
|
||||
const oldShortcutsId = settings.shortcuts.map(s => s.id);
|
||||
const newShortcutsId = initLocalStorage.settings.shortcuts.filter(
|
||||
s => oldShortcutsId.includes(s.id) === false
|
||||
);
|
||||
newShortcutsId.map(id => {
|
||||
settings.shortcuts.push(
|
||||
initLocalStorage.settings.shortcuts.find(s => s.id === id)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
localStorage.setItem('settings', JSON.stringify(settings));
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue