Update WBBR frontend template collection

This commit is contained in:
Codex
2026-08-27 20:15:24 +08:00
parent bd4d54a110
commit e444605e5d
85 changed files with 6322 additions and 115 deletions

50
scripts/start-local.mjs Normal file
View File

@@ -0,0 +1,50 @@
import { spawn, spawnSync } from "node:child_process";
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
const cacheFile = resolve(
projectRoot,
"node_modules/vinext/dist/server/static-file-cache.js",
);
const originalLine = 'const pathname = "/" + relativePath;';
const windowsSafeLine =
'const pathname = "/" + relativePath.replaceAll("\\\\", "/");';
if (!existsSync(cacheFile)) {
console.error("未找到项目依赖,请先执行 npm install。");
process.exit(1);
}
const cacheSource = readFileSync(cacheFile, "utf8");
if (cacheSource.includes(originalLine)) {
writeFileSync(
cacheFile,
cacheSource.replace(originalLine, windowsSafeLine),
"utf8",
);
console.log("已应用 Windows 静态资源路径兼容处理。");
}
const build = spawnSync(npmCommand, ["run", "build"], {
cwd: projectRoot,
stdio: "inherit",
});
if (build.status !== 0) {
process.exit(build.status ?? 1);
}
console.log("\n整个模板项目正在启动http://localhost:3000/\n");
const server = spawn(npmCommand, ["run", "start", "--", "--port", "3000"], {
cwd: projectRoot,
stdio: "inherit",
});
server.on("exit", (code) => process.exit(code ?? 0));
for (const signal of ["SIGINT", "SIGTERM"]) {
process.on(signal, () => server.kill(signal));
}