perf: 添加权限Set 替换检查权限数组 提高检查权限性能

This commit is contained in:
zws
2025-01-21 09:23:37 +08:00
parent 5c0ee866a0
commit d710c9d27e
3 changed files with 14 additions and 27 deletions

View File

@ -16,6 +16,7 @@ interface UserVO {
interface UserInfoVO {
// USER 缓存
permissions: string[]
permissionsSet: Set<string>
roles: string[]
isSetUser: boolean
user: UserVO
@ -24,6 +25,7 @@ interface UserInfoVO {
export const useUserStore = defineStore('admin-user', {
state: (): UserInfoVO => ({
permissions: [],
permissionsSet: new Set<string>(),
roles: [],
isSetUser: false,
user: {
@ -58,6 +60,7 @@ export const useUserStore = defineStore('admin-user', {
userInfo = await getInfo()
}
this.permissions = userInfo.permissions
this.permissionsSet = new Set(userInfo.permissions)
this.roles = userInfo.roles
this.user = userInfo.user
this.isSetUser = true