mirror of
https://github.com/2234839/web-font.git
synced 2026-06-02 15:24:16 +08:00
- 新增 skills/chinese-web-typography.md 作为提供给 AI agent 的排版智能文件 - 重写 README.md(中文默认),新增 README.en.md(英文版),互相引用 - 新增 TypographyDemo.vue 前后对比组件,展示中文字体效果差异 - 新增 src/i18n.ts 轻量国际化方案,所有组件文案支持中英切换 - 后端 /api/fonts 返回 temporary 字段标识临时字体 - 升级至 v1.8.0 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
22 lines
690 B
TypeScript
22 lines
690 B
TypeScript
import { jsonResponse, parseUrl } from "../shared";
|
|
import { readdir, stat } 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) };
|
|
}
|