diff --git a/src/components/AppSidebar.vue b/src/components/AppSidebar.vue index c9a7164..53293f2 100644 --- a/src/components/AppSidebar.vue +++ b/src/components/AppSidebar.vue @@ -96,12 +96,20 @@ const modules = computed(() => { }); /** - * 当前登录身份,由后端按平台 {@code BoaUser} 解析(如「学生」「教师」「管理员」)。 + * 当前登录身份名称:**直接采用平台下发的 {@code currentRole.roleName}**。 * - * 前端**不自行判断角色**:角色号与判定规则属后端,前端复刻一份迟早会不一致。 - * 展示它的意义是让用户理解"为什么我能用的功能和别人不一样"。 + * 与 {@code GetUserInfo} / 门户顶栏同源 —— 平台把当前身份叫什么(「老师」「校领导」 + * 「工作号」…)就原样显示什么,前端不做任何重命名、也不自行判权。 + * + * 取值优先级:① {@code GetUserInfo} 回来的 {@code currentRole.roleName}(权威) + * → ② 后端 {@code /api/agent/tools} 的 {@code identity.roleName}(同一字段的转述) + * → ③ 归一化标签 {@code catalog.roles}(教师/学生/…,仅在平台没下发角色名时兜底)。 */ -const roleText = computed(() => props.catalog?.roles || ""); +const roleText = computed(() => { + const fromUser = props.user?.currentRole?.roleName; + const fromCatalog = props.catalog?.identity?.roleName; + return (fromUser || fromCatalog || props.catalog?.roles || "").trim(); +}); function pick(m: { key: string; sample: string }) { if (!m.sample) return; @@ -179,7 +187,7 @@ function pick(m: { key: string; sample: string }) { {{ roleText }} diff --git a/src/types/agent.ts b/src/types/agent.ts index ad1a31d..260e296 100644 --- a/src/types/agent.ts +++ b/src/types/agent.ts @@ -7,6 +7,15 @@ export interface UserInfoVo { account?: string; profilePicture?: string; deptName?: string; + /** 当前身份(平台下发,与 GetUserInfo 一致):roleName 即门户里当前激活的身份名 */ + currentRole?: { + roleId?: number; + /** 平台当前身份名称,如「老师」「校领导」「学生」 */ + roleName?: string; + schId?: number; + schName?: string; + [key: string]: any; + }; [key: string]: any; }