杂务:整理文档并收口 YumiNail 修复

This commit is contained in:
xiaowang
2026-05-21 18:43:59 +08:00
parent 3797938616
commit 9227ec6175
362 changed files with 8358 additions and 19928 deletions
+22
View File
@@ -1,5 +1,7 @@
import { permissionApi } from '@/api/permission'
import { computed, ref } from 'vue'
import { isBootstrapAdminUser, loadCachedAdminUserInfo } from '@/utils/admin-session'
import { isAllowedForShoplessPlatformAdmin } from '@/utils/platform-admin-permissions'
const USER_PERMISSIONS_STORAGE_KEY = 'userPermissions'
@@ -22,6 +24,8 @@ const readPermissionsFromStorage = () => {
const userPermissions = ref<string[]>(readPermissionsFromStorage() || [])
const loadingPermissions = ref(false)
const isPlatformAdminUser = () => Number(loadCachedAdminUserInfo()?.type) === 4
export const getStoredUserPermissions = () => readPermissionsFromStorage()
export const setStoredUserPermissions = (permissions: string[]) => {
@@ -51,14 +55,32 @@ export const fetchUserPermissionsStrict = async () => {
export const usePermission = () => {
const hasPermission = (permissionCode: string) => {
if (isBootstrapAdminUser(loadCachedAdminUserInfo())) {
return isAllowedForShoplessPlatformAdmin(permissionCode)
}
if (isPlatformAdminUser() && isAllowedForShoplessPlatformAdmin(permissionCode)) {
return isAllowedForShoplessPlatformAdmin(permissionCode)
}
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)
}
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)
}
return permissionCodes.every(code => userPermissions.value.includes(code))
}