- DB: better-sqlite3 + drizzle-orm (history/dictionary/stats, WAL 모드) - HistoryService: CRUD + 검색 + 통계 + 30일 보존 정책, 세션 완료 시 자동 저장 - DictionaryService: CRUD + 검색 + 사용 횟수 추적 + STT 프롬프트 힌트 - HistoryPage: 목록 + 검색 + 삭제 + 복사 + 페이지네이션 - DictionaryPage: 목록 + 검색 + 추가 다이얼로그 + 삭제 - DashboardPage: 실데이터 통계 (총/오늘 세션, 시간, 단어수, 연속일수) - IPC: history/dictionary/stats 핸들러 + preload API - Bootstrap: DB 초기화 (critical) + 이력 자동 저장 연동
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
// src/main/ipc/dictionary-handlers.ts
|
|
|
|
import { ipcMain } from 'electron'
|
|
import { IPC_CHANNELS } from '@shared/ipc-channels'
|
|
import { ipcSuccess, ipcError, ErrorCode } from '@shared/errors'
|
|
import { getDictionaryService } from '../services/DictionaryService'
|
|
import type {
|
|
DictionaryQueryParams,
|
|
DictionaryAddParams,
|
|
DictionaryUpdateParams,
|
|
DictionaryDeleteParams,
|
|
DictionarySearchParams
|
|
} from '@shared/types'
|
|
|
|
export function registerDictionaryHandlers(): void {
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.GET_ALL, async (_event, params: DictionaryQueryParams) => {
|
|
try {
|
|
return ipcSuccess(getDictionaryService().list(params))
|
|
} catch {
|
|
return ipcError(ErrorCode.DBQueryFailed, 'Failed to get dictionary')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.ADD, async (_event, params: DictionaryAddParams) => {
|
|
try {
|
|
return ipcSuccess(getDictionaryService().add(params))
|
|
} catch {
|
|
return ipcError(ErrorCode.DBWriteFailed, 'Failed to add dictionary entry')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.UPDATE, async (_event, params: DictionaryUpdateParams) => {
|
|
try {
|
|
return ipcSuccess(getDictionaryService().update(params))
|
|
} catch {
|
|
return ipcError(ErrorCode.DBWriteFailed, 'Failed to update dictionary entry')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.DELETE, async (_event, params: DictionaryDeleteParams) => {
|
|
try {
|
|
getDictionaryService().delete(params.id)
|
|
return ipcSuccess(undefined)
|
|
} catch {
|
|
return ipcError(ErrorCode.DBWriteFailed, 'Failed to delete dictionary entry')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.SEARCH, async (_event, params: DictionarySearchParams) => {
|
|
try {
|
|
return ipcSuccess(getDictionaryService().search(params))
|
|
} catch {
|
|
return ipcError(ErrorCode.DBQueryFailed, 'Failed to search dictionary')
|
|
}
|
|
})
|
|
}
|