Files
JayuCloud/YumiNail-Frontend/src/views/admin/admin-helpers.ts
T

30 lines
885 B
TypeScript

import { loadCachedAdminUserInfo, isBootstrapAdminUser, type AdminCachedUserInfo } from '@/utils/admin-session'
export { loadCachedAdminUserInfo, isBootstrapAdminUser }
export type { AdminCachedUserInfo }
export const getAdminRoleLabel = (type?: number) => {
switch (type) {
case 4:
return '平台管理员'
case 2:
return '店长'
case 3:
return '美甲师'
default:
return '后台账号'
}
}
export const getAdminShopOptions = (userInfo?: AdminCachedUserInfo | null) => {
const ids = userInfo?.shopIds || []
const names = userInfo?.shopNames || []
return ids.map((id, index) => ({
id: String(id),
name: names[index] || `门店 ${id}`
}))
}
export const getAdminCurrentShopName = (userInfo?: AdminCachedUserInfo | null) =>
userInfo?.shopName || (isBootstrapAdminUser(userInfo) ? '平台总览模式' : '游客模式')