add quick-ask IPC channel and shortcut module

This commit is contained in:
CREDO23 2026-03-24 19:22:43 +02:00
parent 59e7f8f068
commit 801c07291e
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,29 @@
import { clipboard, globalShortcut } from 'electron';
import { IPC_CHANNELS } from '../ipc/channels';
import { getMainWindow } from './window';
const SHORTCUT = 'CommandOrControl+Option+S';
export function registerQuickAsk(): void {
const ok = globalShortcut.register(SHORTCUT, () => {
const win = getMainWindow();
if (!win) return;
const text = clipboard.readText().trim();
if (!text) return;
if (win.isMinimized()) win.restore();
win.show();
win.focus();
win.webContents.send(IPC_CHANNELS.QUICK_ASK_TEXT, text);
});
if (!ok) {
console.log(`Quick-ask: failed to register ${SHORTCUT}`);
}
}
export function unregisterQuickAsk(): void {
globalShortcut.unregister(SHORTCUT);
}