20260819173221
This commit is contained in:
1 parent
1ffc8e1ac9
commit
a0a4273f4c
326 files changed
+301646
-2314
No files matched your search
@@ -29,7 +29,7 @@ export const usePermissionStore = defineStore('permissions', () => {
|
||||
const powerSet = computed(() => new Set(powerCodes.value))
|
||||
const isG3soft = computed(() => {
|
||||
return (
|
||||
String(authStore.user?.account || '')
|
||||
String(authStore.loginInfo.user?.account || '')
|
||||
.trim()
|
||||
.toLowerCase() === 'g3soft'
|
||||
)
|
||||
@@ -39,8 +39,8 @@ export const usePermissionStore = defineStore('permissions', () => {
|
||||
* 加载权限数据;重复调用对同一主体去重,并发调用共享同一请求。
|
||||
*/
|
||||
async function load() {
|
||||
const userId = String(authStore.user?.id || '')
|
||||
const principalKey = `${String(authStore.orgId || '')}:${userId}`
|
||||
const userId = String(authStore.loginInfo.user?.id || '')
|
||||
const principalKey = `${String(authStore.userInfo.orgId || '')}:${userId}`
|
||||
|
||||
// 管理员提权:直接加载全部启用模块,不查授权表
|
||||
if (isG3soft.value) {
|
||||
@@ -153,9 +153,16 @@ export const usePermissionStore = defineStore('permissions', () => {
|
||||
}
|
||||
|
||||
function clear() {
|
||||
loadVersion++
|
||||
loadingPromise = null
|
||||
loadingPrincipalKey = ''
|
||||
// 仅当“正在进行中的请求属于别的主体”时才作废它(如切换账号),
|
||||
// 否则保留进行中请求、只清空已加载数据,交由后续 load 结果填充。
|
||||
// 这避免登录(setSession 后守卫立即 load)被自身的 watch(clear) 误作废,导致菜单空白。
|
||||
const userId = String(authStore.loginInfo.user?.id || '')
|
||||
const principalKey = `${String(authStore.userInfo.orgId || '')}:${userId}`
|
||||
if (loadingPrincipalKey && loadingPrincipalKey !== principalKey) {
|
||||
loadVersion++
|
||||
loadingPromise = null
|
||||
loadingPrincipalKey = ''
|
||||
}
|
||||
loadedPrincipalKey.value = ''
|
||||
modules.value = []
|
||||
grantedPageIds.value = []
|
||||
@@ -165,7 +172,12 @@ export const usePermissionStore = defineStore('permissions', () => {
|
||||
|
||||
// 登录主体变化(退出/切换账号)时清空权限缓存
|
||||
watch(
|
||||
() => [authStore.orgId, authStore.user?.id, authStore.user?.account, authStore.token],
|
||||
() => [
|
||||
authStore.userInfo.orgId,
|
||||
authStore.loginInfo.user?.id,
|
||||
authStore.loginInfo.user?.account,
|
||||
authStore.loginInfo.token,
|
||||
],
|
||||
clear,
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user