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>
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
/**
|
|
* 同时启动前端 (vite) 和后端 (tsx backend/app.ts) 的开发服务器
|
|
* Ctrl+C 会同时终止两个进程
|
|
*/
|
|
import { spawn } from "node:child_process";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const ROOT_DIR = join(__dirname, "..");
|
|
|
|
/** 子进程列表,用于退出时统一清理 */
|
|
const children: ReturnType<typeof spawn>[] = [];
|
|
|
|
/** 清理所有子进程 */
|
|
function cleanup() {
|
|
for (const child of children) {
|
|
child.kill("SIGTERM");
|
|
}
|
|
}
|
|
|
|
process.on("SIGINT", () => {
|
|
cleanup();
|
|
process.exit(0);
|
|
});
|
|
process.on("SIGTERM", () => {
|
|
cleanup();
|
|
process.exit(0);
|
|
});
|
|
|
|
console.log("Starting frontend and backend dev servers...\n");
|
|
|
|
const backend = spawn("pnpx", ["tsx", "watch", "backend/app.ts"], {
|
|
cwd: ROOT_DIR,
|
|
stdio: "inherit",
|
|
shell: true,
|
|
});
|
|
children.push(backend);
|
|
|
|
const frontend = spawn("pnpm", ["dev:frontend"], {
|
|
cwd: ROOT_DIR,
|
|
stdio: "inherit",
|
|
shell: true,
|
|
});
|
|
children.push(frontend);
|