diff --git a/src/api/user/types.ts b/src/api/user/types.ts index 057be5f3..ba38dabf 100644 --- a/src/api/user/types.ts +++ b/src/api/user/types.ts @@ -2,9 +2,10 @@ * 登录用户信息 */ export interface UserInfo { - userId: number; - nickname: string; - avatar: string; + userId?: number; + username?: string; + nickname?: string; + avatar?: string; roles: string[]; perms: string[]; } diff --git a/src/directive/permission/index.ts b/src/directive/permission/index.ts index 11d32068..2bd2c705 100644 --- a/src/directive/permission/index.ts +++ b/src/directive/permission/index.ts @@ -7,7 +7,7 @@ import { Directive, DirectiveBinding } from "vue"; export const hasPerm: Directive = { mounted(el: HTMLElement, binding: DirectiveBinding) { // 「超级管理员」拥有所有的按钮权限 - const { roles, perms } = useUserStoreHook(); + const { roles, perms } = useUserStoreHook().user; if (roles.includes("ROOT")) { return true; } @@ -40,7 +40,7 @@ export const hasRole: Directive = { if (value) { const requiredRoles = value; // DOM绑定需要的角色编码 - const { roles } = useUserStoreHook(); + const { roles } = useUserStoreHook().user; const hasRole = roles.some((perm) => { return requiredRoles.includes(perm); }); diff --git a/src/layout/components/NavBar/NavRight.vue b/src/layout/components/NavBar/NavRight.vue index 8cc4ef5e..63cb1aa8 100644 --- a/src/layout/components/NavBar/NavRight.vue +++ b/src/layout/components/NavBar/NavRight.vue @@ -16,7 +16,7 @@
- +