mirror of
https://github.com/2234839/web-font.git
synced 2026-04-30 21:43:24 +08:00
- 前端UI重构:字体选择器、文本预览、CSS输出+复制、下载字体、上传区域 - 后端新增API:/api/fonts(列出字体)、/api/config(公开配置)、/api/upload(上传字体) - 字体查找支持模糊匹配(精确 > 前缀 > 包含) - 上传功能分两种模式:临时上传(ENV开关,FIFO上限10个)和管理员上传(API Key认证) - 新增multipart解析器、配置模块、文件系统抽象(writeFile/readdir/mkdir/unlink) - 后端启动时等待运行时初始化完成,确保接口可用 - dev-all.ts后端启用tsx watch模式自动重载 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
654 B
TypeScript
28 lines
654 B
TypeScript
import { implInterface } from "../interface";
|
|
import { stat, readFile, writeFile, readdir, mkdir, unlink } from "fs/promises";
|
|
implInterface({
|
|
async stat(path) {
|
|
const r = await stat(path);
|
|
return r;
|
|
},
|
|
readFile(path) {
|
|
return readFile(path);
|
|
},
|
|
writeFile(path, data) {
|
|
return writeFile(path, data);
|
|
},
|
|
async readdir(path) {
|
|
const entries = await readdir(path, { withFileTypes: true });
|
|
return entries.map((entry) => ({
|
|
isFile: () => entry.isFile(),
|
|
name: entry.name,
|
|
}));
|
|
},
|
|
async mkdir(path) {
|
|
await mkdir(path, { recursive: true });
|
|
},
|
|
unlink(path) {
|
|
return unlink(path);
|
|
},
|
|
});
|