refactor: ♻️ 提取 ROLE_ROOT 常量到 constants 目录并全局统一引用

This commit is contained in:
Ray.Hao
2025-05-20 10:34:44 +08:00
parent 2a3d2543ee
commit 7df7e1f47b
16 changed files with 63 additions and 64 deletions

View File

@@ -4,6 +4,7 @@ import { Storage } from "@/utils/storage";
import { ACCESS_TOKEN_KEY } from "@/constants/cache-keys";
import router from "@/router";
import { usePermissionStore, useUserStore } from "@/store";
import { ROLE_ROOT } from "@/constants";
export function setupPermission() {
// 白名单路由
@@ -78,7 +79,7 @@ export function hasAuth(value: string | string[], type: "button" | "role" = "but
const { roles, perms } = useUserStore().userInfo;
// 超级管理员 拥有所有权限
if (type === "button" && roles.includes("ROOT")) {
if (type === "button" && roles.includes(ROLE_ROOT)) {
return true;
}