feat(export): add sns arkmejson format and consolidate export flow changes

This commit is contained in:
tisonhuang
2026-03-04 13:14:40 +08:00
parent e1243522b0
commit c5eed25f06
7 changed files with 473 additions and 1249 deletions

View File

@@ -991,115 +991,11 @@ function registerIpcHandlers() {
return chatService.getSessionMessageCounts(sessionIds)
})
ipcMain.handle('chat:getExportContentSessionCounts', async (_, options?: {
triggerRefresh?: boolean
forceRefresh?: boolean
traceId?: string
ipcMain.handle('chat:enrichSessionsContactInfo', async (_, usernames: string[], options?: {
skipDisplayName?: boolean
onlyMissingAvatar?: boolean
}) => {
const traceId = typeof options?.traceId === 'string' ? options.traceId.trim() : ''
const startedAt = Date.now()
if (traceId) {
exportCardDiagnosticsService.stepStart({
traceId,
stepId: 'main-ipc-export-content-counts',
stepName: 'Main IPC: chat:getExportContentSessionCounts',
source: 'main',
message: '主进程收到导出卡片统计请求',
data: {
forceRefresh: options?.forceRefresh === true,
triggerRefresh: options?.triggerRefresh !== false
}
})
}
try {
const result = await chatService.getExportContentSessionCounts(options)
if (traceId) {
exportCardDiagnosticsService.stepEnd({
traceId,
stepId: 'main-ipc-export-content-counts',
stepName: 'Main IPC: chat:getExportContentSessionCounts',
source: 'main',
status: result?.success ? 'done' : 'failed',
durationMs: Date.now() - startedAt,
message: result?.success ? '主进程统计请求完成' : '主进程统计请求失败',
data: result?.success
? {
totalSessions: result?.data?.totalSessions || 0,
pendingMediaSessions: result?.data?.pendingMediaSessions || 0,
refreshing: result?.data?.refreshing === true
}
: { error: result?.error || '未知错误' }
})
}
return result
} catch (error) {
if (traceId) {
exportCardDiagnosticsService.stepEnd({
traceId,
stepId: 'main-ipc-export-content-counts',
stepName: 'Main IPC: chat:getExportContentSessionCounts',
source: 'main',
status: 'failed',
durationMs: Date.now() - startedAt,
message: '主进程统计请求抛出异常',
data: { error: String(error) }
})
}
throw error
}
})
ipcMain.handle('chat:refreshExportContentSessionCounts', async (_, options?: {
forceRefresh?: boolean
traceId?: string
}) => {
const traceId = typeof options?.traceId === 'string' ? options.traceId.trim() : ''
const startedAt = Date.now()
if (traceId) {
exportCardDiagnosticsService.stepStart({
traceId,
stepId: 'main-ipc-refresh-export-content-counts',
stepName: 'Main IPC: chat:refreshExportContentSessionCounts',
source: 'main',
message: '主进程收到刷新导出卡片统计请求',
data: { forceRefresh: options?.forceRefresh === true }
})
}
try {
const result = await chatService.refreshExportContentSessionCounts(options)
if (traceId) {
exportCardDiagnosticsService.stepEnd({
traceId,
stepId: 'main-ipc-refresh-export-content-counts',
stepName: 'Main IPC: chat:refreshExportContentSessionCounts',
source: 'main',
status: result?.success ? 'done' : 'failed',
durationMs: Date.now() - startedAt,
message: result?.success ? '主进程刷新请求完成' : '主进程刷新请求失败',
data: result?.success ? undefined : { error: result?.error || '未知错误' }
})
}
return result
} catch (error) {
if (traceId) {
exportCardDiagnosticsService.stepEnd({
traceId,
stepId: 'main-ipc-refresh-export-content-counts',
stepName: 'Main IPC: chat:refreshExportContentSessionCounts',
source: 'main',
status: 'failed',
durationMs: Date.now() - startedAt,
message: '主进程刷新请求抛出异常',
data: { error: String(error) }
})
}
throw error
}
})
ipcMain.handle('chat:enrichSessionsContactInfo', async (_, usernames: string[]) => {
return chatService.enrichSessionsContactInfo(usernames)
return chatService.enrichSessionsContactInfo(usernames, options)
})
ipcMain.handle('chat:getMessages', async (_, sessionId: string, offset?: number, limit?: number, startTime?: number, endTime?: number, ascending?: boolean) => {