- npm workspaces 루트 (apps/*, packages/*) 세팅 - V1 전체를 apps/desktop/으로 git mv (src, resources, tests, sidecar, scripts, electron.vite.config.ts, electron-builder.yml, vitest.config.ts, tsconfig.node.json, tsconfig.web.json) - apps/desktop/package.json 신규 (name=@d3ro/desktop) - productName: 'd3ro-voice' 명시 — app.getName()을 고정하여 userData 경로 %APPDATA%\d3ro-voice\ 그대로 유지 (기존 DB/설정 연속성 보장) - 루트 package.json을 workspace 루트로 재구성, 공통 devDep만 유지 (typescript, eslint, prettier) - turbo.json, tsconfig.base.json 추가 (Turborepo 자체 설치는 별도 sub-phase) - memory/project_status.md 생성 (규칙 13) 검증: - npm run typecheck 통과 - npm run build 통과 (electron-vite main+preload+renderer) - npm run dev 실제 실행 → DB/핫키/Ollama 자동 실행 모두 정상
81 lines
2.8 KiB
TypeScript
81 lines
2.8 KiB
TypeScript
// src/main/ipc/hotkey-handlers.ts
|
|
|
|
import { ipcMain } from 'electron'
|
|
import { IPC_CHANNELS } from '@shared/ipc-channels'
|
|
import { ipcSuccess, ipcError, ErrorCode } from '@shared/errors'
|
|
import { getHotkeyService } from '../services/HotkeyService'
|
|
import { configGet, configSet } from '../services/ConfigService'
|
|
import type { SetHotkeyParams, SetEnabledParams } from '@shared/types'
|
|
|
|
export function registerHotkeyHandlers(): void {
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.GET_DICTATION_SHORTCUT, async () => {
|
|
return ipcSuccess(configGet('dictationShortcut'))
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.SET_DICTATION_SHORTCUT, async (_event, params: SetHotkeyParams) => {
|
|
try {
|
|
configSet('dictationShortcut', params.binding)
|
|
getHotkeyService().loadFromConfig()
|
|
return ipcSuccess(undefined)
|
|
} catch {
|
|
return ipcError(ErrorCode.HotkeyRegistrationFailed, 'Failed to set dictation shortcut')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.GET_HANDS_FREE_SHORTCUT, async () => {
|
|
return ipcSuccess(configGet('handsFreeShortcut'))
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.SET_HANDS_FREE_SHORTCUT, async (_event, params: SetHotkeyParams) => {
|
|
try {
|
|
configSet('handsFreeShortcut', params.binding)
|
|
getHotkeyService().loadFromConfig()
|
|
return ipcSuccess(undefined)
|
|
} catch {
|
|
return ipcError(ErrorCode.HotkeyRegistrationFailed, 'Failed to set hands-free shortcut')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.GET_COMMAND_SHORTCUT, async () => {
|
|
return ipcSuccess(configGet('commandShortcut'))
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.SET_COMMAND_SHORTCUT, async (_event, params: SetHotkeyParams) => {
|
|
try {
|
|
configSet('commandShortcut', params.binding)
|
|
getHotkeyService().loadFromConfig()
|
|
return ipcSuccess(undefined)
|
|
} catch {
|
|
return ipcError(ErrorCode.HotkeyRegistrationFailed, 'Failed to set command shortcut')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.GET_CAPTION_SHORTCUT, async () => {
|
|
return ipcSuccess(configGet('captionShortcut'))
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.SET_CAPTION_SHORTCUT, async (_event, params: SetHotkeyParams) => {
|
|
try {
|
|
configSet('captionShortcut', params.binding)
|
|
getHotkeyService().loadFromConfig()
|
|
return ipcSuccess(undefined)
|
|
} catch {
|
|
return ipcError(ErrorCode.HotkeyRegistrationFailed, 'Failed to set caption shortcut')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.IS_ENABLED, async () => {
|
|
return ipcSuccess(configGet('hotkeyEnabled'))
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.HOTKEY.SET_ENABLED, async (_event, params: SetEnabledParams) => {
|
|
configSet('hotkeyEnabled', params.enabled)
|
|
const hotkey = getHotkeyService()
|
|
if (params.enabled) {
|
|
hotkey.start()
|
|
} else {
|
|
hotkey.stop()
|
|
}
|
|
return ipcSuccess(undefined)
|
|
})
|
|
}
|