feat: 新增对话数据缓存管理模块,优化统计数据读取性能

This commit is contained in:
digua
2026-03-29 11:55:15 +08:00
committed by digua
parent bfca7ff133
commit 211a8110b0
17 changed files with 298 additions and 45 deletions
+11 -1
View File
@@ -7,6 +7,7 @@ import type { IpcContext } from './types'
import {
getAppDataDir,
getDatabaseDir,
getCacheDir,
getAiDataDir,
getLogsDir,
getDownloadsDir,
@@ -92,6 +93,14 @@ export function registerCacheHandlers(_context: IpcContext): void {
icon: 'i-heroicons-sparkles',
canClear: false, // 不允许一键清理
},
{
id: 'cache',
name: 'settings.storage.cache.statsCache.name',
description: 'settings.storage.cache.statsCache.description',
path: getCacheDir(),
icon: 'i-heroicons-bolt',
canClear: true,
},
// 临时文件已有自动清理机制(应用启动时、合并完成后),无需暴露给用户
{
id: 'logs',
@@ -185,8 +194,8 @@ export function registerCacheHandlers(_context: IpcContext): void {
* 清理指定缓存目录
*/
ipcMain.handle('cache:clear', async (_, cacheId: string) => {
// 只允许清理 logstemp 由系统自动清理,downloads 已改为系统下载目录)
const allowedDirs: Record<string, string> = {
cache: getCacheDir(),
logs: getLogsDir(),
}
@@ -271,6 +280,7 @@ export function registerCacheHandlers(_context: IpcContext): void {
const dirPaths: Record<string, string> = {
base: getAppDataDir(),
databases: getDatabaseDir(),
cache: getCacheDir(),
ai: getAiDataDir(),
logs: getLogsDir(),
downloads: getDownloadsDir(), // 系统下载目录