feat(frontend): Phase C 固定企业模式 - VITE_FIXED_ENTITY_ID 支持登录无下拉/隐藏切换器

- 新增 src/utils/entity.ts: isFixedEntity/getFixedEntityId/effectiveEntityId
- Login.vue: 固定企业版隐藏企业下拉显示只读徽标, 登录直接带固定 entity_id
- MainLayout.vue: 切换器加 !isFixedEntity() 守卫, 固定版顶部显示企业 tag, logo 带企业名
- ReportCenter.vue: 页内企业切换下拉加守卫, getEntityId 固定版恒取构建锁定值
- .env.example: VITE_FIXED_ENTITY_ID 示例与说明
- 验证脚本 backend/scripts/verify_phase_c_fixed_entity_e2e.py (22项, 双build E2E全过)
This commit is contained in:
Hermes CI Fix
2026-09-08 11:27:01 +08:00
parent 193061cf4d
commit ebe0962c09
6 changed files with 388 additions and 13 deletions
+25
View File
@@ -0,0 +1,25 @@
// ── 固定企业模式(Phase C 2026-09-08)──
// VITE_FIXED_ENTITY_ID:构建期锁定单一企业(供 Phase A 子域名独立版 hanke/bohai.cma.sxbh.ltd 使用)。
// 设置(如 VITE_FIXED_ENTITY_ID=1)=固定企业独立版:登录页隐藏企业下拉、MainLayout/ReportCenter 隐藏切换器,
// 登录直接携带该 entity_id;数据天然为该企业,无需内部切换。
// 未设置 = 超管/多企业切换版(默认,行为与旧版完全一致)。
const fixedRaw: string = (import.meta.env.VITE_FIXED_ENTITY_ID as string | undefined) || ''
const fixedId: number | undefined = fixedRaw.trim() === '' ? undefined : Number(fixedRaw)
/** 是否固定企业独立版(构建期由 VITE_FIXED_ENTITY_ID 决定,运行时不变) */
export function isFixedEntity(): boolean {
return fixedId !== undefined && !Number.isNaN(fixedId)
}
/** 固定企业 ID;非固定版返回 undefined */
export function getFixedEntityId(): number | undefined {
return isFixedEntity() ? fixedId : undefined
}
/** 当前生效 entity_id:固定企业版取构建锁定值;切换版取 localStorage(登录/切换时写入) */
export function effectiveEntityId(): number {
const f = getFixedEntityId()
if (f !== undefined) return f
const stored = Number(localStorage.getItem('cma_entity_id'))
return Number.isNaN(stored) ? 1 : stored
}