YiAi/chat/electron/shortcutManager.js
2024-01-27 19:53:17 +08:00

20 lines
455 B
JavaScript

// shortcutManager.js
const { globalShortcut, BrowserWindow } = require('electron');
let isWindowVisible = true;
function registerShortcuts(mainWindow) {
globalShortcut.register('Ctrl+L', () => {
if (mainWindow && !mainWindow.isFullScreen()) {
if (isWindowVisible) {
mainWindow.hide();
} else {
mainWindow.show();
}
isWindowVisible = !isWindowVisible;
}
});
}
module.exports = { registerShortcuts };