崮生(子虚) d68551d23e feat(stats): 统计计数跨重启持久化 + 依赖升级
- 新增 stats_store.ts:防抖写盘 font/.stats.json,热路径零磁盘 IO
- shared.ts 暴露 initStats/markStatsDirty/snapshotStats
- app.ts 启动恢复累计计数 + 退出前尽力落盘
- 路由热路径打脏标记(防抖 30s 批量落盘)
- 清理未用变量/导入/常量
- 升级依赖:vue 3.6.0-beta.17、typescript 7.0.2、vite 8.1.5 等

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 21:43:12 +08:00

22 lines
675 B
TypeScript

import { jsonResponse } from "../shared";
import { readdir } from "../interface";
import { fontDirs } from "../config";
/** GET /api/fonts — 列出所有可用字体 */
export async function handleListFonts(req: Request, _res: Response) {
const allFonts: Array<{ name: string; temporary: boolean }> = [];
for (const dir of fontDirs) {
try {
const entries = await readdir(dir);
for (const entry of entries) {
if (entry.isFile() && /\.(ttf|otf|woff|woff2)$/i.test(entry.name)) {
allFonts.push({ name: entry.name, temporary: dir === "font/temp" });
}
}
} catch {}
}
return { req, res: jsonResponse(allFonts) };
}