@xcanwin/manyoyo 7.0.9 → 7.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/web/frontend/app.js +2 -2
- package/lib/web/frontend/login.js +1 -1
- package/lib/web/frontend/shadcn.html +83 -84
- package/lib/web/server.js +28 -11
- package/package.json +4 -3
package/lib/web/server.js
CHANGED
|
@@ -4098,10 +4098,19 @@ function renderIndexHtml(ctx) {
|
|
|
4098
4098
|
}
|
|
4099
4099
|
|
|
4100
4100
|
function renderShadcnHtml(ctx) {
|
|
4101
|
-
// shadcn
|
|
4102
|
-
//
|
|
4103
|
-
//
|
|
4104
|
-
|
|
4101
|
+
// shadcn.html 是 vite singlefile 打包产物,全部依赖内联成一个 <script>,
|
|
4102
|
+
// 用 .replace('</head>', ...) 有极小概率命中某个库源码里字面量出现的
|
|
4103
|
+
// "</head>",把注入脚本插进内联脚本中间导致整页解析错乱;所以不复用
|
|
4104
|
+
// injectServeTitleFlag 那个 </head> 定位方式,改成跟 applyServeTitle 同款
|
|
4105
|
+
// 更窄、更安全的 <title> 定位,插一个 meta 标记告知前端跳过动态改写 document.title
|
|
4106
|
+
let html = applyServeTitle(loadTemplate('shadcn.html'), ctx);
|
|
4107
|
+
if (typeof ctx.serveTitle === 'string') {
|
|
4108
|
+
html = html.replace(
|
|
4109
|
+
/<\/title>/,
|
|
4110
|
+
() => '</title>\n <meta name="manyoyo-serve-title" content="1">'
|
|
4111
|
+
);
|
|
4112
|
+
}
|
|
4113
|
+
return html;
|
|
4105
4114
|
}
|
|
4106
4115
|
|
|
4107
4116
|
function renderLoginHtml(ctx) {
|
|
@@ -4305,12 +4314,13 @@ async function handleWebAuthRoutes(req, res, pathname, ctx, state) {
|
|
|
4305
4314
|
return true;
|
|
4306
4315
|
}
|
|
4307
4316
|
|
|
4317
|
+
// 旧版默认主题(现为 /legacy 兜底路由)的登录页
|
|
4308
4318
|
if (req.method === 'GET' && pathname === '/auth/login') {
|
|
4309
4319
|
sendHtml(res, 200, renderLoginHtml(ctx));
|
|
4310
4320
|
return true;
|
|
4311
4321
|
}
|
|
4312
4322
|
|
|
4313
|
-
// shadcn/ui
|
|
4323
|
+
// 默认主题(shadcn/ui 版)的登录页:与 / 、/shadcn 复用同一份构建产物,
|
|
4314
4324
|
// 由前端按 pathname 自行渲染登录表单,登录逻辑仍复用 /auth/login 接口
|
|
4315
4325
|
if (req.method === 'GET' && pathname === '/shadcn/auth/login') {
|
|
4316
4326
|
sendHtml(res, 200, applyServeTitle(loadTemplate('shadcn.html'), ctx));
|
|
@@ -4374,12 +4384,12 @@ function sendWebUnauthorized(res, pathname, ctx) {
|
|
|
4374
4384
|
sendJson(res, 401, { error: 'UNAUTHORIZED' });
|
|
4375
4385
|
return;
|
|
4376
4386
|
}
|
|
4377
|
-
if (pathname === '/' || pathname === '') {
|
|
4378
|
-
sendRedirect(res, 302, '/auth/login', { 'Set-Cookie': getWebAuthClearCookie() });
|
|
4387
|
+
if (pathname === '' || pathname === '/' || pathname === '/shadcn') {
|
|
4388
|
+
sendRedirect(res, 302, '/shadcn/auth/login', { 'Set-Cookie': getWebAuthClearCookie() });
|
|
4379
4389
|
return;
|
|
4380
4390
|
}
|
|
4381
|
-
if (pathname === '/
|
|
4382
|
-
sendRedirect(res, 302, '/
|
|
4391
|
+
if (pathname === '/legacy') {
|
|
4392
|
+
sendRedirect(res, 302, '/auth/login', { 'Set-Cookie': getWebAuthClearCookie() });
|
|
4383
4393
|
return;
|
|
4384
4394
|
}
|
|
4385
4395
|
sendHtml(
|
|
@@ -5565,17 +5575,24 @@ async function startWebServer(options) {
|
|
|
5565
5575
|
return;
|
|
5566
5576
|
}
|
|
5567
5577
|
|
|
5578
|
+
// shadcn/ui 版前端现在是默认主题,构建产物见 frontend-shadcn/(npm run build:web-shadcn)
|
|
5568
5579
|
if (req.method === 'GET' && pathname === '/') {
|
|
5569
|
-
sendHtml(res, 200,
|
|
5580
|
+
sendHtml(res, 200, renderShadcnHtml(ctx));
|
|
5570
5581
|
return;
|
|
5571
5582
|
}
|
|
5572
5583
|
|
|
5573
|
-
// shadcn
|
|
5584
|
+
// /shadcn 保留为 / 的别名,兼容此前"试验性预览"阶段留下的书签/脚本
|
|
5574
5585
|
if (req.method === 'GET' && pathname === '/shadcn') {
|
|
5575
5586
|
sendHtml(res, 200, renderShadcnHtml(ctx));
|
|
5576
5587
|
return;
|
|
5577
5588
|
}
|
|
5578
5589
|
|
|
5590
|
+
// 旧版默认主题:不再是默认路由,移到 /legacy 继续保留一段时间作为兜底
|
|
5591
|
+
if (req.method === 'GET' && pathname === '/legacy') {
|
|
5592
|
+
sendHtml(res, 200, renderIndexHtml(ctx));
|
|
5593
|
+
return;
|
|
5594
|
+
}
|
|
5595
|
+
|
|
5579
5596
|
const appFrontendMatch = pathname.match(/^\/app\/frontend\/([A-Za-z0-9._-]+)$/);
|
|
5580
5597
|
if (req.method === 'GET' && appFrontendMatch) {
|
|
5581
5598
|
const assetName = appFrontendMatch[1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xcanwin/manyoyo",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.12",
|
|
4
4
|
"imageVersion": "1.9.1-common",
|
|
5
5
|
"playwrightCliVersion": "0.1.18",
|
|
6
6
|
"description": "AI Agent CLI Security Sandbox for Docker and Podman",
|
|
@@ -34,11 +34,12 @@
|
|
|
34
34
|
"build:web-editor": "node scripts/build-web-code-editor.js",
|
|
35
35
|
"build:web-shadcn": "node scripts/build-web-shadcn.js",
|
|
36
36
|
"dev:web-shadcn": "node scripts/dev-web-shadcn.js",
|
|
37
|
+
"test:web-shadcn": "node scripts/test-web-shadcn.js",
|
|
37
38
|
"prepack": "npm run build:web-editor && npm run build:web-shadcn",
|
|
38
39
|
"prepare": "npm run build:web-editor",
|
|
39
40
|
"install-link": "npm link",
|
|
40
|
-
"test": "jest --coverage",
|
|
41
|
-
"test:unit": "jest test/",
|
|
41
|
+
"test": "jest --coverage && npm run test:web-shadcn",
|
|
42
|
+
"test:unit": "jest test/ && npm run test:web-shadcn",
|
|
42
43
|
"lint": "echo 'Lint check passed'",
|
|
43
44
|
"docs:dev": "vitepress dev docs --host 127.0.0.1 --port 5173",
|
|
44
45
|
"docs:build": "vitepress build docs",
|