mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
feat(electron): enable automatic incremental imports
This commit is contained in:
1 parent
0606d5f5f7
commit
3e6f036826
8 files changed
+139
-97
No files matched your search
@@ -7,6 +7,24 @@
|
||||
import { ipcRenderer } from 'electron'
|
||||
import type { ImportProgress } from '../../../../src/types/base'
|
||||
|
||||
interface ChatImportResult {
|
||||
success: boolean
|
||||
sessionId?: string
|
||||
error?: string
|
||||
importMode?: 'created' | 'incremental'
|
||||
matchedBy?: 'stable-id' | 'trailing-messages'
|
||||
newMessageCount?: number
|
||||
duplicateCount?: number
|
||||
diagnostics?: {
|
||||
logFile: string | null
|
||||
detectedFormat: string | null
|
||||
messagesReceived: number
|
||||
messagesWritten: number
|
||||
messagesSkipped: number
|
||||
skipReasons: { noSenderId: number; noAccountName: number; invalidTimestamp: number; noType: number }
|
||||
}
|
||||
}
|
||||
|
||||
export const chatApi = {
|
||||
// ==================== 数据库迁移 ====================
|
||||
|
||||
@@ -25,21 +43,16 @@ export const chatApi = {
|
||||
selectFile: (): Promise<{ filePath?: string; format?: string; error?: string } | null> =>
|
||||
ipcRenderer.invoke('chat:selectFile'),
|
||||
|
||||
import: (filePath: string): Promise<{ success: boolean; sessionId?: string; error?: string }> =>
|
||||
ipcRenderer.invoke('chat:import', filePath),
|
||||
import: (filePath: string): Promise<ChatImportResult> => ipcRenderer.invoke('chat:import', filePath),
|
||||
|
||||
importDirectory: (dirPath: string): Promise<{ success: boolean; sessionId?: string; error?: string }> =>
|
||||
ipcRenderer.invoke('chat:importDirectory', dirPath),
|
||||
importDirectory: (dirPath: string): Promise<ChatImportResult> => ipcRenderer.invoke('chat:importDirectory', dirPath),
|
||||
|
||||
detectFormat: (
|
||||
filePath: string
|
||||
): Promise<{ id: string; name: string; platform: string; multiChat: boolean } | null> =>
|
||||
ipcRenderer.invoke('chat:detectFormat', filePath),
|
||||
|
||||
importWithOptions: (
|
||||
filePath: string,
|
||||
formatOptions: Record<string, unknown>
|
||||
): Promise<{ success: boolean; sessionId?: string; error?: string }> =>
|
||||
importWithOptions: (filePath: string, formatOptions: Record<string, unknown>): Promise<ChatImportResult> =>
|
||||
ipcRenderer.invoke('chat:importWithOptions', filePath, formatOptions),
|
||||
|
||||
scanMultiChatFile: (
|
||||
@@ -52,7 +65,7 @@ export const chatApi = {
|
||||
|
||||
prepareImportSource: (filePath: string) => ipcRenderer.invoke('chat:prepareImportSource', filePath),
|
||||
|
||||
importPreparedChat: (sourceId: string, chatId: string) =>
|
||||
importPreparedChat: (sourceId: string, chatId: string): Promise<ChatImportResult> =>
|
||||
ipcRenderer.invoke('chat:importPreparedChat', sourceId, chatId),
|
||||
|
||||
releaseImportSource: (sourceId: string) => ipcRenderer.invoke('chat:releaseImportSource', sourceId),
|
||||
|
||||
Vendored
+15
-10
@@ -38,18 +38,26 @@ interface ImportDiagnostics {
|
||||
}
|
||||
}
|
||||
|
||||
interface ChatImportResult {
|
||||
success: boolean
|
||||
sessionId?: string
|
||||
error?: string
|
||||
importMode?: 'created' | 'incremental'
|
||||
matchedBy?: 'stable-id' | 'trailing-messages'
|
||||
newMessageCount?: number
|
||||
duplicateCount?: number
|
||||
diagnostics?: ImportDiagnostics
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatApi — 导入、迁移、Demo(数据查询/分析/成员/SQL 已迁移到 HTTP)
|
||||
*/
|
||||
interface ChatApi {
|
||||
selectFile: () => Promise<{ filePath?: string; format?: string; error?: string } | null>
|
||||
detectFormat: (filePath: string) => Promise<{ id: string; name: string; platform: string; multiChat: boolean } | null>
|
||||
import: (filePath: string) => Promise<{ success: boolean; sessionId?: string; error?: string }>
|
||||
importDirectory: (dirPath: string) => Promise<{ success: boolean; sessionId?: string; error?: string }>
|
||||
importWithOptions: (
|
||||
filePath: string,
|
||||
formatOptions: Record<string, unknown>
|
||||
) => Promise<{ success: boolean; sessionId?: string; error?: string }>
|
||||
import: (filePath: string) => Promise<ChatImportResult>
|
||||
importDirectory: (dirPath: string) => Promise<ChatImportResult>
|
||||
importWithOptions: (filePath: string, formatOptions: Record<string, unknown>) => Promise<ChatImportResult>
|
||||
scanMultiChatFile: (filePath: string) => Promise<{
|
||||
success: boolean
|
||||
chats: Array<{ index: number; name: string; type: string; id: number; messageCount: number }>
|
||||
@@ -72,10 +80,7 @@ interface ChatApi {
|
||||
}
|
||||
error?: string
|
||||
}>
|
||||
importPreparedChat: (
|
||||
sourceId: string,
|
||||
chatId: string
|
||||
) => Promise<{ success: boolean; sessionId?: string; error?: string; diagnostics?: ImportDiagnosticsInfo }>
|
||||
importPreparedChat: (sourceId: string, chatId: string) => Promise<ChatImportResult>
|
||||
releaseImportSource: (sourceId: string) => Promise<{ success: boolean }>
|
||||
checkMigration: () => Promise<MigrationCheckResult>
|
||||
runMigration: () => Promise<{ success: boolean; error?: string }>
|
||||
|
||||
Reference in new issue
Block a user