feat(sidebar): 身份名称直接绑定平台 currentRole.roleName
build / build (push) Successful in 1m58s

- 左下角身份标签改为直接展示平台下发的 roleName(与 GetUserInfo / 门户同源),
  平台叫什么就显示什么,不再用归一化的「教师/学生/管理员」桶
- 取值优先级:GetUserInfo.currentRole.roleName → /api/agent/tools identity.roleName → catalog.roles 兜底
- 实测 byLoginName(lijing) 返回 currentRole={roleId:1, roleName:"老师"},改后左下角显示「老师」
- UserInfoVo 补充 currentRole 字段类型
This commit is contained in:
lijing
2026-10-12 16:34:20 +08:00
parent 946d953103
commit 854550c019
2 changed files with 22 additions and 5 deletions
+13 -5
View File
@@ -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 }) { function pick(m: { key: string; sample: string }) {
if (!m.sample) return; if (!m.sample) return;
@@ -179,7 +187,7 @@ function pick(m: { key: string; sample: string }) {
<em <em
v-if="roleText" v-if="roleText"
class="sb__role" class="sb__role"
:title="`当前身份:${roleText}(能力模块已按该身份过滤)`" :title="`当前身份:${roleText}(平台当前身份,能力模块已按该身份过滤)`"
> >
{{ roleText }} {{ roleText }}
</em> </em>
+9
View File
@@ -7,6 +7,15 @@ export interface UserInfoVo {
account?: string; account?: string;
profilePicture?: string; profilePicture?: string;
deptName?: string; deptName?: string;
/** 当前身份(平台下发,与 GetUserInfo 一致):roleName 即门户里当前激活的身份名 */
currentRole?: {
roleId?: number;
/** 平台当前身份名称,如「老师」「校领导」「学生」 */
roleName?: string;
schId?: number;
schName?: string;
[key: string]: any;
};
[key: string]: any; [key: string]: any;
} }