Files
affiliate_dash/frontend
yml2213 e692790aa7 fix(admin): 平台路由不再依赖商户上下文,消除管理端被残留上下文锁死
问题:Tenant 中间件挂在整个已登录分组上,包括 /api/platform/*。管理员
localStorage 里一旦残留一个已禁用/已删除的商户 ID,ResolveMerchantForAdmin 就会对
所有请求返回 403——连"去把它改回来"的平台页面都打不开,整个管理端被锁死。

判断依据:逐条核对 35 条 /platform/* 路由与 13 个平台侧 handler,租户依赖为 0。
平台接口本身就是跨商户的,商户上下文对它们没有意义。

- router:平台分组从租户中间件里摘出,只挂 Auth + RequireRole(admin);
  商户侧分组保持 Tenant 不变,单商户隔离语义一点没动
- 搬迁后逐条比对路由集合:平台 35 条、商户侧全部一致
- request.ts:对 /platform/* 以及管理员的 /dashboard 不再发送 X-Merchant-ID,
  作为第二道防线(后者后端本就按角色忽略商户,带上只会引入 403 风险)

回归测试:新增 TestPlatformRoutesIgnoreStaleMerchantContext(无上下文 / 残留不存在的
商户两种情形都必须 200)与 TestMerchantRoutesStillRejectStaleContext(商户侧仍须 403)。
已实测这两个用例在未修复时会失败,报 403「当前账号无权访问该商户」/「商户不存在或已禁用」。

实测(无效商户上下文下):/api/platform/orders → 200 total=37;
/api/platform/merchants、rock/config、product-catalog → 200;/api/merchant/orders → 403。
2026-10-06 20:39:57 +08:00
..
2026-08-04 15:34:34 +08:00
2026-07-20 14:58:57 +08:00
2026-07-20 14:58:57 +08:00
2026-07-20 14:58:57 +08:00
2026-07-20 14:58:57 +08:00
2026-07-20 14:58:57 +08:00
2026-07-20 14:58:57 +08:00
2026-07-20 14:58:57 +08:00
2026-07-20 14:58:57 +08:00
2026-07-20 14:58:57 +08:00
2026-08-04 15:34:34 +08:00

React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.

Currently, two official plugins are available:

React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.

Expanding the Oxlint configuration

If you are developing a production application, we recommend enabling type-aware lint rules by installing oxlint-tsgolint and editing .oxlintrc.json:

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": ["react", "typescript", "oxc"],
  "options": {
    "typeAware": true
  },
  "rules": {
    "react/rules-of-hooks": "error",
    "react/only-export-components": ["warn", { "allowConstantExport": true }]
  }
}

See the Oxlint rules documentation for the full list of rules and categories.