feat: implement AI insights service and settings tab

Add core insight service and IPC handlers; update config and settings page.

Co-authored-by: Jason <159670257+Jasonzhu1207@users.noreply.github.com>
This commit is contained in:
v0
2026-04-05 15:32:22 +00:00
parent 209b91bfef
commit 93a9df48f4
6 changed files with 837 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ import { cloudControlService } from './services/cloudControlService'
import { destroyNotificationWindow, registerNotificationHandlers, showNotification } from './windows/notificationWindow'
import { httpService } from './services/httpService'
import { messagePushService } from './services/messagePushService'
import { insightService } from './services/insightService'
import { bizService } from './services/bizService'
// 配置自动更新
@@ -1394,6 +1395,15 @@ function registerIpcHandlers() {
return result
})
// AI 见解
ipcMain.handle('insight:testConnection', async () => {
return insightService.testConnection()
})
ipcMain.handle('insight:getTodayStats', async () => {
return insightService.getTodayStats()
})
ipcMain.handle('config:clear', async () => {
if (isLaunchAtStartupSupported() && getSystemLaunchAtStartup()) {
const result = setSystemLaunchAtStartup(false)
@@ -3119,8 +3129,10 @@ app.whenReady().then(async () => {
registerIpcHandlers()
chatService.addDbMonitorListener((type, json) => {
messagePushService.handleDbMonitorChange(type, json)
insightService.handleDbMonitorChange(type, json)
})
messagePushService.start()
insightService.start()
await delay(200)
// 检查配置状态
@@ -3241,6 +3253,7 @@ app.on('before-quit', async () => {
if (tray) { try { tray.destroy() } catch {} tray = null }
// 通知窗使用 hide 而非 close退出时主动销毁避免残留窗口阻塞进程退出。
destroyNotificationWindow()
insightService.stop()
// 兜底5秒后强制退出防止某个异步任务卡住导致进程残留
const forceExitTimer = setTimeout(() => {
console.warn('[App] Force exit after timeout')