mirror of
https://github.com/2234839/web-font.git
synced 2026-04-30 05:08:14 +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>
38 lines
889 B
TypeScript
38 lines
889 B
TypeScript
import { implInterface } from "../interface";
|
||
|
||
implInterface({
|
||
async stat(path) {
|
||
const r = await tjs.stat(path);
|
||
return {
|
||
isFile: () => r.isFile,
|
||
size: r.size,
|
||
};
|
||
},
|
||
readFile(path) {
|
||
return tjs.readFile(path);
|
||
},
|
||
writeFile(path, data) {
|
||
return tjs.writeFile(path, data);
|
||
},
|
||
async readdir(path) {
|
||
const entries: { isFile: () => boolean; name: string }[] = [];
|
||
const dir = await tjs.readDir(path);
|
||
for await (const entry of dir) {
|
||
entries.push({
|
||
isFile: () => entry.isFile,
|
||
name: entry.name,
|
||
});
|
||
}
|
||
await dir.close();
|
||
return entries;
|
||
},
|
||
/** TJS 没有 mkdir,通过写入占位文件来确保目录存在 */
|
||
async mkdir(path) {
|
||
const placeholder = path + "/.keep";
|
||
await tjs.writeFile(placeholder, new Uint8Array(0));
|
||
},
|
||
unlink(path) {
|
||
return tjs.remove(path);
|
||
},
|
||
});
|