重构: App拆分10域文件+并发安全+结构化日志+依赖升级

This commit is contained in:
lxy
2026-05-16 20:45:14 +08:00
parent d17c20c579
commit 767311fc04
27 changed files with 1457 additions and 1218 deletions
@@ -22,6 +22,7 @@ const CONTENT_DETECT_MAX_SIZE = 500 * 1024 // 500KB
// 缓存检测结果
const contentDetectCache = new Map<string, { timestamp: number; result: any }>()
const CACHE_TTL = 60000 // 1分钟缓存
const CACHE_MAX_SIZE = 200
// ====== URL 工具函数(导出供外部使用) ======
@@ -122,6 +123,7 @@ export function useFilePreview() {
try {
const result = await detectFileTypeByContent(path)
const data = { category: result.category, ext: result.extension }
if (contentDetectCache.size >= CACHE_MAX_SIZE) contentDetectCache.clear()
contentDetectCache.set(path, { timestamp: Date.now(), result: data })
return data
} catch {