fetch(modify):修改原来的bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m53s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m53s
This commit is contained in:
@@ -23,15 +23,45 @@ export const useUserStore = defineStore(
|
||||
const searchHistory = ref<AppRouteRecord[]>([])
|
||||
const accessToken = ref('')
|
||||
const refreshToken = ref('')
|
||||
const permissions = ref<string[]>([])
|
||||
|
||||
const getUserInfo = computed(() => info.value)
|
||||
const getSettingState = computed(() => useSettingStore().$state)
|
||||
const getWorktabState = computed(() => useWorktabStore().$state)
|
||||
const getPermissions = computed(() => permissions.value)
|
||||
|
||||
const setUserInfo = (newInfo: UserInfo) => {
|
||||
info.value = newInfo
|
||||
}
|
||||
|
||||
const setPermissions = (perms: string[]) => {
|
||||
permissions.value = perms
|
||||
}
|
||||
|
||||
// 检查是否是超级管理员
|
||||
const isSuperAdmin = computed(() => info.value.user_type === 1)
|
||||
|
||||
// 检查是否有某个权限
|
||||
const hasPermission = (permission: string): boolean => {
|
||||
// 超级管理员拥有所有权限
|
||||
if (isSuperAdmin.value) return true
|
||||
return permissions.value.includes(permission)
|
||||
}
|
||||
|
||||
// 检查是否有某些权限中的任意一个
|
||||
const hasAnyPermission = (perms: string[]): boolean => {
|
||||
// 超级管理员拥有所有权限
|
||||
if (isSuperAdmin.value) return true
|
||||
return perms.some((perm) => permissions.value.includes(perm))
|
||||
}
|
||||
|
||||
// 检查是否有所有指定权限
|
||||
const hasAllPermissions = (perms: string[]): boolean => {
|
||||
// 超级管理员拥有所有权限
|
||||
if (isSuperAdmin.value) return true
|
||||
return perms.every((perm) => permissions.value.includes(perm))
|
||||
}
|
||||
|
||||
const setLoginStatus = (status: boolean) => {
|
||||
isLogin.value = status
|
||||
}
|
||||
@@ -74,6 +104,7 @@ export const useUserStore = defineStore(
|
||||
lockPassword.value = ''
|
||||
accessToken.value = ''
|
||||
refreshToken.value = ''
|
||||
permissions.value = []
|
||||
useWorktabStore().opened = []
|
||||
sessionStorage.removeItem('iframeRoutes')
|
||||
resetRouterState(router)
|
||||
@@ -90,10 +121,17 @@ export const useUserStore = defineStore(
|
||||
searchHistory,
|
||||
accessToken,
|
||||
refreshToken,
|
||||
permissions,
|
||||
getUserInfo,
|
||||
getSettingState,
|
||||
getWorktabState,
|
||||
getPermissions,
|
||||
isSuperAdmin,
|
||||
setUserInfo,
|
||||
setPermissions,
|
||||
hasPermission,
|
||||
hasAnyPermission,
|
||||
hasAllPermissions,
|
||||
setLoginStatus,
|
||||
setLanguage,
|
||||
setSearchHistory,
|
||||
|
||||
Reference in New Issue
Block a user