Phase 6 구현: 커스텀 명령어 + i18n (ko/en)
- CustomInstructionService: 프리셋 5개 (번역/요약/전문리라이트/코드설명/자유프롬프트) - 커스텀 명령어 CRUD + 프리셋 보호 (삭제 불가) - CommandsPage: 명령어 목록 + 추가/편집 다이얼로그 - i18n: ko.json/en.json 리소스 파일, t() 함수, React 컨텍스트 - IPC: instruction 핸들러 6개 - AppLayout: Commands 네비게이션 추가
This commit is contained in:
parent
5ccbf85a65
commit
d940c5020e
11 changed files with 701 additions and 5 deletions
67
src/main/ipc/instruction-handlers.ts
Normal file
67
src/main/ipc/instruction-handlers.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// src/main/ipc/instruction-handlers.ts
|
||||
|
||||
import { ipcMain } from 'electron'
|
||||
import { ipcSuccess, ipcError, ErrorCode } from '@shared/errors'
|
||||
import { getCustomInstructionService } from '../services/CustomInstructionService'
|
||||
import type { CustomInstruction } from '../services/CustomInstructionService'
|
||||
|
||||
// IPC_CHANNELS에 instruction 채널이 없으므로 직접 문자열 사용
|
||||
// (Phase 6 전용, 설계서 02에는 미포함)
|
||||
const CHANNELS = {
|
||||
GET_ALL: 'instruction:getAll',
|
||||
GET_BY_ID: 'instruction:getById',
|
||||
CREATE: 'instruction:create',
|
||||
UPDATE: 'instruction:update',
|
||||
DELETE: 'instruction:delete',
|
||||
REORDER: 'instruction:reorder'
|
||||
} as const
|
||||
|
||||
export function registerInstructionHandlers(): void {
|
||||
ipcMain.handle(CHANNELS.GET_ALL, async () => {
|
||||
return ipcSuccess(getCustomInstructionService().getAll())
|
||||
})
|
||||
|
||||
ipcMain.handle(CHANNELS.GET_BY_ID, async (_event, params: { id: string }) => {
|
||||
return ipcSuccess(getCustomInstructionService().getById(params.id))
|
||||
})
|
||||
|
||||
ipcMain.handle(
|
||||
CHANNELS.CREATE,
|
||||
async (
|
||||
_event,
|
||||
params: { name: string; description: string; prompt: string; icon?: string }
|
||||
) => {
|
||||
try {
|
||||
const result = getCustomInstructionService().create(params)
|
||||
return ipcSuccess(result)
|
||||
} catch {
|
||||
return ipcError(ErrorCode.ConfigWriteFailed, 'Failed to create instruction')
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
ipcMain.handle(
|
||||
CHANNELS.UPDATE,
|
||||
async (_event, params: { id: string; data: Partial<CustomInstruction> }) => {
|
||||
try {
|
||||
const result = getCustomInstructionService().update(params.id, params.data)
|
||||
return ipcSuccess(result)
|
||||
} catch {
|
||||
return ipcError(ErrorCode.ConfigWriteFailed, 'Failed to update instruction')
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
ipcMain.handle(CHANNELS.DELETE, async (_event, params: { id: string }) => {
|
||||
const result = getCustomInstructionService().delete(params.id)
|
||||
if (!result) {
|
||||
return ipcError(ErrorCode.ConfigWriteFailed, 'Cannot delete builtin instruction')
|
||||
}
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
|
||||
ipcMain.handle(CHANNELS.REORDER, async (_event, params: { ids: string[] }) => {
|
||||
getCustomInstructionService().reorder(params.ids)
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue