fix: 🐛 修复增删改查组件报错的bug
修复增删改查组件报错的bug
This commit is contained in:
@@ -71,3 +71,18 @@ function redirectToLogin(to: RouteLocationNormalized, next: NavigationGuardNext)
|
|||||||
const redirect = queryString ? `${to.path}?${queryString}` : to.path;
|
const redirect = queryString ? `${to.path}?${queryString}` : to.path;
|
||||||
next(`/login?redirect=${encodeURIComponent(redirect)}`);
|
next(`/login?redirect=${encodeURIComponent(redirect)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 判断是否有权限 */
|
||||||
|
export function hasAuth(value: string | string[], type: "button" | "role" = "button") {
|
||||||
|
const { roles, perms } = useUserStore().userInfo;
|
||||||
|
|
||||||
|
// 超级管理员 拥有所有权限
|
||||||
|
if (type === "button" && roles.includes("ROOT")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auths = type === "button" ? perms : roles;
|
||||||
|
return typeof value === "string"
|
||||||
|
? auths.includes(value)
|
||||||
|
: value.some((perm) => auths.includes(perm));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user