mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
feat: add global shortcut setting (#470)
* feat: add global short cut setting * fix: fix settings not work * fix: call initIpcMan after createWindow * fix: fix build error (typo)
This commit is contained in:
parent
b98bf909fb
commit
36447ae5d8
7 changed files with 50 additions and 7 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { app, ipcMain, dialog } from "electron";
|
||||
import { app, dialog, globalShortcut, ipcMain } from "electron";
|
||||
import match from "@njzy/unblockneteasemusic";
|
||||
import { registerGlobalShortcut } from "@/electron/globalShortcut";
|
||||
|
||||
const client = require("discord-rich-presence")("818936529484906596");
|
||||
|
||||
export function initIpcMain(win, store) {
|
||||
|
|
@ -61,6 +63,14 @@ export function initIpcMain(win, store) {
|
|||
|
||||
ipcMain.on("settings", (event, options) => {
|
||||
store.set("settings", options);
|
||||
const isRegisterShortcut = globalShortcut.isRegistered(
|
||||
"Alt+CommandOrControl+P"
|
||||
);
|
||||
if (options.enableGlobalShortcut) {
|
||||
!isRegisterShortcut && registerGlobalShortcut(win);
|
||||
} else {
|
||||
isRegisterShortcut && globalShortcut.unregisterAll();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on("playDiscordPresence", (event, track) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue