新版界面挂载:/next/ 提供 web/dist 构建,单页回退并限制在目录内

试用、演示模式默认开启,云端需设置 WEB_NEXT=1;其余地址行为不变。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
黄健铭andClaude Opus 5.5 committed 2026-12-04 18:36:57 -08:00
1 parent 33fedc2e68
commit 40bff0be94
5 files changed
+273 -2

No files matched your search

+3 -1
View File
@@ -22,6 +22,7 @@ const { securityHeaders } = require('./middleware/security-headers');
const { checkRequest } = require('./middleware/request-guard');
const { requireActor } = require('./middleware/session');
const { serveStatic } = require('./middleware/static');
const { serveWebNext, webNextEnabled, isNextPath } = require('./middleware/web-next');
const { sendError } = require('./middleware/errors');
const UNMATCHED = {
@@ -63,7 +64,7 @@ async function runRoute(route, ctx) {
}
// 处理顺序:安全响应头 → Host/405/来源校验 → 登录前路由 → 解析当前账号 → /api/、/print/ 的 401/409
// → 路由(含未匹配)→ 静态文件 → 统一错误响应。
// → 路由(含未匹配)→ 新版界面 /next/(启用时)→ 静态文件 → 统一错误响应。
function createHandler(app, routes) {
const router = createRouter(routes);
const enabled = route => !route.when || route.when(app);
@@ -91,6 +92,7 @@ function createHandler(app, routes) {
requireActor(req, ctx.actor);
return await runRoute(hit?.route ?? UNMATCHED[req.method], ctx);
}
if (isNextPath(pathname) && webNextEnabled(app)) return serveWebNext(res, pathname, isPost);
serveStatic(res, pathname, isPost);
} catch (e) {
sendError(res, e);