refactor: 重构部分架构

This commit is contained in:
digua
2025-12-05 01:11:37 +08:00
parent 04dc2a79c1
commit 4fb9255605
18 changed files with 1903 additions and 1503 deletions

View File

@@ -797,6 +797,48 @@ const agentApi = {
},
}
// Cache API - 缓存管理
interface CacheDirectoryInfo {
id: string
name: string
description: string
path: string
icon: string
canClear: boolean
size: number
fileCount: number
exists: boolean
}
interface CacheInfo {
baseDir: string
directories: CacheDirectoryInfo[]
totalSize: number
}
const cacheApi = {
/**
* 获取所有缓存目录信息
*/
getInfo: (): Promise<CacheInfo> => {
return ipcRenderer.invoke('cache:getInfo')
},
/**
* 清理指定缓存目录
*/
clear: (cacheId: string): Promise<{ success: boolean; error?: string; message?: string }> => {
return ipcRenderer.invoke('cache:clear', cacheId)
},
/**
* 在文件管理器中打开缓存目录
*/
openDir: (cacheId: string): Promise<{ success: boolean; error?: string }> => {
return ipcRenderer.invoke('cache:openDir', cacheId)
},
}
// 扩展 api添加 dialog 功能
const extendedApi = {
...api,
@@ -819,6 +861,7 @@ if (process.contextIsolated) {
contextBridge.exposeInMainWorld('aiApi', aiApi)
contextBridge.exposeInMainWorld('llmApi', llmApi)
contextBridge.exposeInMainWorld('agentApi', agentApi)
contextBridge.exposeInMainWorld('cacheApi', cacheApi)
} catch (error) {
console.error(error)
}
@@ -837,4 +880,6 @@ if (process.contextIsolated) {
window.llmApi = llmApi
// @ts-ignore (define in dts)
window.agentApi = agentApi
// @ts-ignore (define in dts)
window.cacheApi = cacheApi
}