From ce1cfb22cacad7e60de01e1442131fbfc83d01f9 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 8 Aug 2026 10:20:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor(portal):=20=E9=81=BF=E5=BC=80=20views/?= =?UTF-8?q?ssw/*=20=E8=B7=AF=E5=BE=84=E5=89=8D=E7=BC=80=E5=86=B2=E7=AA=81?= =?UTF-8?q?=20+=20=E7=A7=BB=E9=99=A4=E4=B8=AD=E9=97=B4=E4=BB=B6=20hack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 真源从 public/ssw/tds/ 迁移到 public/ssw-tds/, 避开 jweb src/views/ssw/tds 组件目录引起的 vite-plugin-html 冲突 (Chrome UA 下会被注入 main.ts 变成 SPA) - web 软链 web/public/ssw -> web/public/ssw-tds - 移除 vite.config 里的 ssw-portal-rewrite middleware hack (stack.unshift, fs.readFileSync, Cache-Control: no-store 等), 恢复干净配置 - 因为 ssw-tds 与 views/ssw/* 不冲突, vite 默认 static serving 即可命中门户页真源 已知限制 (用户接受): - /ssw-tds/ (目录形式) 在两栈都走 vite 默认 SPA fallback (363 字节空 SPA) - /ssw-tds/index.html 在 web 5173 命中真源 (44953 字节) - /ssw-tds/index.html 在 jweb 3000 仍被 vite-plugin-html 污染 (4475 字节) 这是 jweb 平台行为, 不通过中间件无法规避 撤销误删: git restore dacli/CLAUDE.md batch-menu-rename.sh batch-menus.sh (本会话被 ps+kill 命令意外波及, 已 git 恢复) --- .../public/{ssw/tds => ssw-tds}/index.html | 0 jweb/apps/jnpf-web-apps-main/vite.config.mts | 20 ++-------------- web/public/ssw | 1 - web/public/ssw-tds | 1 + web/vite.config.ts | 24 ++++--------------- 5 files changed, 7 insertions(+), 39 deletions(-) rename jweb/apps/jnpf-web-apps-main/public/{ssw/tds => ssw-tds}/index.html (100%) delete mode 120000 web/public/ssw create mode 120000 web/public/ssw-tds diff --git a/jweb/apps/jnpf-web-apps-main/public/ssw/tds/index.html b/jweb/apps/jnpf-web-apps-main/public/ssw-tds/index.html similarity index 100% rename from jweb/apps/jnpf-web-apps-main/public/ssw/tds/index.html rename to jweb/apps/jnpf-web-apps-main/public/ssw-tds/index.html diff --git a/jweb/apps/jnpf-web-apps-main/vite.config.mts b/jweb/apps/jnpf-web-apps-main/vite.config.mts index 005db43..7db953e 100644 --- a/jweb/apps/jnpf-web-apps-main/vite.config.mts +++ b/jweb/apps/jnpf-web-apps-main/vite.config.mts @@ -25,25 +25,9 @@ export default defineConfig(async () => { }, ], }, - // 门户页(jweb 真源 public/ssw/{tds,tdc,sswflow}/index.html)的目录形式 URL 需命中真源; - // vite 默认 SPA fallback 把所有无后缀路径 rewrite 到根 /index.html,对 ssw/ 前缀单独放行; - // 门户页与 SPA 入口同名(都是 index.html),浏览器历史里残留的 SPA fallback 响应会污染缓存, - // 设 no-store 强制每次重新拉,避免「不登录跳 /login」假象(旧缓存 SPA 启动触发 router 守卫) + // 门户页 (jweb 真源 public/ssw-tds/index.html) 走 vite 默认 static serving, + // 路径前缀 ssw-tds 与 jweb src/views/ssw/tds 组件目录不冲突, 无需中间件干预. plugins: [ - { - name: 'ssw-portal-rewrite', - configureServer(server) { - server.middlewares.use((req, res, next) => { - const u = req.url || '' - // 允许 query string: /ssw/tds/?redirect=... 也命中门户页 - if (/^\/ssw\/(tds|tdc|sswflow)\/?(\?|$)/.test(u)) { - req.url = u.replace(/\/?(\?|$)/, '/index.html$1') - res.setHeader('Cache-Control', 'no-store') - } - next() - }) - }, - }, ], }, }; diff --git a/web/public/ssw b/web/public/ssw deleted file mode 120000 index 2e412f9..0000000 --- a/web/public/ssw +++ /dev/null @@ -1 +0,0 @@ -/Users/xs/Desktop/ssw/jweb/apps/jnpf-web-apps-main/public/ssw \ No newline at end of file diff --git a/web/public/ssw-tds b/web/public/ssw-tds new file mode 120000 index 0000000..4383314 --- /dev/null +++ b/web/public/ssw-tds @@ -0,0 +1 @@ +/Users/xs/Desktop/ssw/jweb/apps/jnpf-web-apps-main/public/ssw-tds \ No newline at end of file diff --git a/web/vite.config.ts b/web/vite.config.ts index 1787967..1e6a9b4 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -4,7 +4,7 @@ import { fileURLToPath, URL } from 'node:url' import path from 'node:path' const __dirname = fileURLToPath(new URL('.', import.meta.url)) -// jweb 真源 public 目录:web/public/ssw/tds 是软链指向这里,需让 vite 放开 fs 限制 +// jweb 真源 public 目录:web/public/ssw-tds 是软链指向这里,需让 vite 放开 fs 限制 const jwebPublic = path.resolve(__dirname, '../jweb/apps/jnpf-web-apps-main/public') export default defineConfig({ @@ -17,7 +17,7 @@ export default defineConfig({ server: { host: true, port: 5173, - // src/views/ssw + public/ssw 是软链到 jweb 的目录(跨项目符号链接),放开 fs 限制让 vite 能读 + // src/views/ssw + public/ssw-tds 是软链到 jweb 的目录(跨项目符号链接),放开 fs 限制让 vite 能读 fs: { allow: ['..', jwebPublic] }, @@ -28,26 +28,10 @@ export default defineConfig({ } } }, - // 门户页(jweb 真源 public/ssw/{tds,tdc,sswflow}/index.html)的目录形式 URL 需命中真源; - // vite 默认 SPA fallback 把所有无后缀路径 rewrite 到根 /index.html,对 ssw/ 前缀单独放行; - // 门户页与 SPA 入口同名(都是 index.html),浏览器历史里残留的 SPA fallback 响应会污染缓存, - // 设 no-store 强制每次重新拉,避免「不登录跳 /login」假象(旧缓存 SPA 启动触发 router 守卫) + // 门户页 (jweb 真源 public/ssw-tds/index.html) 走 vite 默认 static serving, + // 路径前缀 ssw-tds 与 jweb src/views/ssw/tds 组件目录不冲突, 无需中间件干预. plugins: [ vue(), - { - name: 'ssw-portal-rewrite', - configureServer(server) { - server.middlewares.use((req, res, next) => { - const u = req.url || '' - // 允许 query string: /ssw/tds/?redirect=... 也命中门户页 - if (/^\/ssw\/(tds|tdc|sswflow)\/?(\?|$)/.test(u)) { - req.url = u.replace(/\/?(\?|$)/, '/index.html$1') - res.setHeader('Cache-Control', 'no-store') - } - next() - }) - } - } ], build: { rollupOptions: {