fix:修复了清除缓存功能的缺失

This commit is contained in:
xuncha
2026-01-17 02:45:10 +08:00
parent afa3e089b1
commit 095c8f0db6
9 changed files with 215 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import { ConfigService } from './config'
import { wcdbService } from './wcdbService'
import { join } from 'path'
import { readFile, writeFile } from 'fs/promises'
import { readFile, writeFile, rm } from 'fs/promises'
import { app } from 'electron'
export interface ChatStatistics {
@@ -528,6 +528,18 @@ class AnalyticsService {
return { success: false, error: String(e) }
}
}
async clearCache(): Promise<{ success: boolean; error?: string }> {
this.aggregateCache = null
this.fallbackAggregateCache = null
this.aggregatePromise = null
try {
await rm(this.getCacheFilePath(), { force: true })
return { success: true }
} catch (e) {
return { success: false, error: String(e) }
}
}
}
export const analyticsService = new AnalyticsService()