2023-11-23 18:28:53 +08:00
|
|
|
import { globalShortcut } from "electron";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 注册全局快捷键
|
|
|
|
|
* @param {BrowserWindow} win - 程序窗口
|
|
|
|
|
*/
|
|
|
|
|
const createGlobalShortcut = (win) => {
|
|
|
|
|
// 刷新程序
|
2023-12-04 13:35:06 +08:00
|
|
|
globalShortcut.register("CmdOrCtrl+Shift+R", () => {
|
2023-12-02 17:25:23 +08:00
|
|
|
if (win && win.isFocused()) win?.reload();
|
2023-11-23 18:28:53 +08:00
|
|
|
});
|
2023-12-04 13:35:06 +08:00
|
|
|
|
|
|
|
|
// 打开开发者工具
|
|
|
|
|
globalShortcut.register("CmdOrCtrl+Shift+I", () => {
|
|
|
|
|
if (win && win.isFocused()) {
|
|
|
|
|
win?.webContents.openDevTools({
|
|
|
|
|
mode: "right",
|
|
|
|
|
activate: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-11-23 18:28:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default createGlobalShortcut;
|