liuyun ed9af5337d
Some checks are pending
CI / backend (push) Waiting to run
CI / frontend (push) Waiting to run
docs(spec): 归档 tenant-brand + 同步租户品牌主 spec
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-11 22:33:21 +08:00

2.0 KiB
Raw Permalink Blame History

Context

tenant 已有 code/name/status/remark,前端顶栏标题「投云科技」、Logo(本地资源)、主色(app store 默认 #2E7FA3)、底部版权均为全局硬编码。动机见 proposal.md - Why。

Goals / Non-Goals

Goals:

  • 租户可配置品牌名/Logo/主色/版权,登录后前端按当前租户渲染。

Non-Goals:

  • 不做登录页的租户级品牌预渲染(多租户下登录前无法确定租户,登录页仍用全局配置)。
  • 不做品牌图床/上传(Logo 用 URL)。

Decisions

D1 — tenant 加 4 个可空品牌字段

brand_name(64)、logo_url(255)、theme_color(16,如 #2E7FA3)、copyright(255),均可空;空则前端回退。

D2 — GET /auth/brand 放在 auth,仅登录态

AuthService.getBrand(tenantCode) 查 tenant,返回 { name, brandName, logoUrl, themeColor, copyright };字段为空原样返回 null,由前端回退。放在 auth 与既有 menus/permissions(当前用户上下文)一致。

D3 — 前端登录后应用品牌

layout onMounted 随 menu/dict/permission 一并拉取 GET /auth/brand,存进 auth store(brand ref):

  • 主色:brand.themeColor 非空则 app.themeColor = brand.themeColor;
  • 标题:brand.brandName ?? tenant.name ?? '投云科技';
  • Logo:brand.logoUrl ?? 本地默认 logo;
  • 版权:brand.copyright ?? '云南投云科技有限公司'。

D4 — 租户管理表单加品牌字段

tenant 表单加 4 个可选字段(theme_color 用颜色选择器或文本),列表/详情展示 brand_name。

Risks / Trade-offs

  • [主色覆盖用户手动选择] → 登录时仅当 brand.themeColor 非空才覆盖;用户在设置面板改色仍即时生效。
  • [Logo 外链失效] → 前端 img 加载失败时回退默认(onerror 或留空)。

Migration Plan

  1. Prisma migration:sys_tenant 加 4 列(可空,无回填)。
  2. 代码上线。
  3. 回滚:向后兼容,回滚代码即可。

Open Questions

无。