重构: App拆分10域文件+并发安全+结构化日志+依赖升级
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user