refactor(portal): 避开 views/ssw/* 路径前缀冲突 + 移除中间件 hack

- 真源从 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 恢复)
This commit is contained in:
admin committed 2026-08-08 10:20:55 +08:00
1 parent 2502d4fd97
commit ce1cfb22ca
5 files changed
+7 -39

No files matched your search

+2 -18
View File
@@ -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()
})
},
},
],
},
};
-1
View File
@@ -1 +0,0 @@
/Users/xs/Desktop/ssw/jweb/apps/jnpf-web-apps-main/public/ssw
+1
View File
@@ -0,0 +1 @@
/Users/xs/Desktop/ssw/jweb/apps/jnpf-web-apps-main/public/ssw-tds
+4 -20
View File
@@ -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: {