feat: 添加微信数据库实时监控,聊天记录自动刷新

This commit is contained in:
电摇小子
2026-06-30 14:36:45 +08:00
parent 10dc74e2a1
commit 5a87a10d12
10 changed files with 294 additions and 35 deletions
+4 -1
View File
@@ -34,7 +34,9 @@ declare global {
interface Window {
electron: ElectronAPI
api: {
initDb: (key: string) => Promise<boolean | { success: boolean; error?: string }>
initDb: (
key: string
) => Promise<boolean | { success: boolean; error?: string; monitoring?: boolean }>
getContacts: (filter?: string) => Promise<Contact[]>
getMessages: (userMd5: string, startTime?: number, endTime?: number) => Promise<Message[]>
search: (keyword: string) => Promise<string | null>
@@ -72,6 +74,7 @@ declare global {
}>
pasteAndSaveDbKey: () => Promise<{ success: boolean; key?: string; error?: string }>
clearSavedDbKey: () => Promise<{ success: boolean; error?: string }>
onWcdbChange: (callback: (payload: { type: string; json: string }) => void) => () => void
onDbKeyStatus: (callback: (payload: { message: string }) => void) => () => void
}
}
+8
View File
@@ -28,6 +28,14 @@ const api = {
autoGetDbKey: () => ipcRenderer.invoke('key:autoGetDbKey'),
pasteAndSaveDbKey: () => ipcRenderer.invoke('key:pasteAndSaveDbKey'),
clearSavedDbKey: () => ipcRenderer.invoke('key:clearSavedDbKey'),
onWcdbChange: (callback: (payload: { type: string; json: string }) => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
payload: { type: string; json: string }
): void => callback(payload)
ipcRenderer.on('wcdb-change', listener)
return () => ipcRenderer.removeListener('wcdb-change', listener)
},
onDbKeyStatus: (callback: (payload: { message: string }) => void) => {
const listener = (_event: Electron.IpcRendererEvent, payload: { message: string }): void =>
callback(payload)