mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
feat: 新增聊天消息关键词搜索功能
- wcdbCore: 绑定 wcdb_search_messages DLL 函数,添加 searchMessages 方法 - wcdbWorker: 添加 searchMessages case - wcdbService: 添加 searchMessages 代理方法 - chatService: 添加 searchMessages,结果解析为 Message 对象 - main: 注册 chat:searchMessages IPC handler
This commit is contained in:
@@ -6580,6 +6580,20 @@ class ChatService {
|
||||
}
|
||||
}
|
||||
|
||||
async searchMessages(keyword: string, sessionId?: string, limit?: number, offset?: number, beginTimestamp?: number, endTimestamp?: number): Promise<{ success: boolean; messages?: Message[]; error?: string }> {
|
||||
try {
|
||||
const result = await wcdbService.searchMessages(keyword, sessionId, limit, offset, beginTimestamp, endTimestamp)
|
||||
if (!result.success || !result.messages) {
|
||||
return { success: false, error: result.error || '搜索失败' }
|
||||
}
|
||||
const messages = result.messages.map((row: any) => this.parseMessage(row)).filter(Boolean) as Message[]
|
||||
return { success: true, messages }
|
||||
} catch (e) {
|
||||
console.error('ChatService: searchMessages 失败:', e)
|
||||
return { success: false, error: String(e) }
|
||||
}
|
||||
}
|
||||
|
||||
private parseMessage(row: any): Message {
|
||||
const rawContent = this.decodeMessageContent(
|
||||
this.getRowField(row, [
|
||||
|
||||
Reference in New Issue
Block a user