Phase 5 구현: SQLite DB + History/Dictionary 서비스 + UI
- 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) + 이력 자동 저장 연동
This commit is contained in:
parent
4a5cf6c819
commit
291e2a29d0
17 changed files with 3111 additions and 35 deletions
64
src/main/ipc/history-handlers.ts
Normal file
64
src/main/ipc/history-handlers.ts
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
// src/main/ipc/history-handlers.ts
|
||||
|
||||
import { ipcMain } from 'electron'
|
||||
import { IPC_CHANNELS } from '@shared/ipc-channels'
|
||||
import { ipcSuccess, ipcError, ErrorCode } from '@shared/errors'
|
||||
import { getHistoryService } from '../services/HistoryService'
|
||||
import type {
|
||||
HistoryQueryParams,
|
||||
HistoryGetByIdParams,
|
||||
HistoryDeleteParams,
|
||||
HistorySearchParams
|
||||
} from '@shared/types'
|
||||
|
||||
export function registerHistoryHandlers(): void {
|
||||
ipcMain.handle(IPC_CHANNELS.HISTORY.GET_ALL, async (_event, params: HistoryQueryParams) => {
|
||||
try {
|
||||
return ipcSuccess(getHistoryService().list(params))
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBQueryFailed, 'Failed to get history')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.HISTORY.GET_BY_ID, async (_event, params: HistoryGetByIdParams) => {
|
||||
try {
|
||||
return ipcSuccess(getHistoryService().getById(params.id))
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBQueryFailed, 'Failed to get history entry')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.HISTORY.DELETE, async (_event, params: HistoryDeleteParams) => {
|
||||
try {
|
||||
getHistoryService().delete(params.id)
|
||||
return ipcSuccess(undefined)
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBWriteFailed, 'Failed to delete history entry')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.HISTORY.DELETE_ALL, async () => {
|
||||
try {
|
||||
getHistoryService().deleteAll()
|
||||
return ipcSuccess(undefined)
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBWriteFailed, 'Failed to delete all history')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.HISTORY.SEARCH, async (_event, params: HistorySearchParams) => {
|
||||
try {
|
||||
return ipcSuccess(getHistoryService().search(params))
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBQueryFailed, 'Failed to search history')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.STATS.GET_SUMMARY, async () => {
|
||||
try {
|
||||
return ipcSuccess(getHistoryService().getStats())
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBQueryFailed, 'Failed to get stats')
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue