重构Salon后台单管理员与经营驾驶舱

This commit is contained in:
2026-10-26 01:19:23 +08:00
parent 17cf16db36
commit b8327146cb
35 changed files with 1087 additions and 4158 deletions
+7 -20
View File
@@ -1,7 +1,6 @@
import { permissionApi } from '@/api/permission'
import { computed, ref } from 'vue'
import { isBootstrapAdminUser, loadCachedAdminUserInfo } from '@/utils/admin-session'
import { isAllowedForShoplessPlatformAdmin } from '@/utils/platform-admin-permissions'
import { loadCachedAdminUserInfo } from '@/utils/admin-session'
/**
* Purpose: USER_PERMISSIONS_STORAGE_KEY supports permission.ts by holding or executing the user permissions storage key page or API role.
@@ -76,6 +75,9 @@ export const clearStoredPermissions = () => {
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
export const fetchUserPermissionsStrict = async () => {
if (isPlatformAdminUser()) {
return setStoredUserPermissions([])
}
loadingPermissions.value = true
try {
const permissions = await permissionApi.getUserPermissions()
@@ -95,32 +97,17 @@ export const fetchUserPermissionsStrict = async () => {
*/
export const usePermission = () => {
const hasPermission = (permissionCode: string) => {
if (isBootstrapAdminUser(loadCachedAdminUserInfo())) {
return isAllowedForShoplessPlatformAdmin(permissionCode)
}
if (isPlatformAdminUser() && isAllowedForShoplessPlatformAdmin(permissionCode)) {
return isAllowedForShoplessPlatformAdmin(permissionCode)
}
if (isPlatformAdminUser()) return true
return userPermissions.value.includes(permissionCode)
}
const hasAnyPermission = (permissionCodes: string[]) => {
if (isBootstrapAdminUser(loadCachedAdminUserInfo())) {
return permissionCodes.some(isAllowedForShoplessPlatformAdmin)
}
if (isPlatformAdminUser() && permissionCodes.some(isAllowedForShoplessPlatformAdmin)) {
return permissionCodes.some(isAllowedForShoplessPlatformAdmin)
}
if (isPlatformAdminUser()) return true
return permissionCodes.some(code => userPermissions.value.includes(code))
}
const hasAllPermissions = (permissionCodes: string[]) => {
if (isBootstrapAdminUser(loadCachedAdminUserInfo())) {
return permissionCodes.every(isAllowedForShoplessPlatformAdmin)
}
if (isPlatformAdminUser() && permissionCodes.every(isAllowedForShoplessPlatformAdmin)) {
return permissionCodes.every(isAllowedForShoplessPlatformAdmin)
}
if (isPlatformAdminUser()) return true
return permissionCodes.every(code => userPermissions.value.includes(code))
}