refactor(user): 优化用户权限检查和界面显示逻辑
- 移除邀请人ID表单项并注释相关代码 - 注释掉邀请信息检测成功提示弹窗功能 - 在开发、生产、测试环境中添加本地API调试配置选项 - 添加分销商角色权限检查,非分销商无法查看客户列表 - 使用useRef避免重复显示无权限提示 - 在客户列表页面添加权限验证和加载状态处理 - 移除用户卡片中的余额、积分、优惠券、礼品卡等显示组件 - 简化用户角色名称获取逻辑,优先使用用户角色数组第一个角色名称 - 优化用户信息加载和权限验证流程
This commit is contained in:
@@ -10,6 +10,7 @@ export const useUser = () => {
|
||||
const [user, setUser] = useState<User | null>(null);
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [userInfo] = useState<User>()
|
||||
|
||||
// 自动登录(通过OpenID)
|
||||
const autoLoginByOpenId = async () => {
|
||||
@@ -256,23 +257,10 @@ export const useUser = () => {
|
||||
return user?.nickname || user?.realName || user?.username || '未登录';
|
||||
};
|
||||
|
||||
// 获取用户显示的角色(同步版本)
|
||||
// 角色名称:优先取用户 roles 数组的第一个角色名称
|
||||
const getRoleName = () => {
|
||||
if(hasRole('superAdmin')){
|
||||
return '超级管理员';
|
||||
}
|
||||
if(hasRole('admin')){
|
||||
return '管理员';
|
||||
}
|
||||
if(hasRole('staff')){
|
||||
return '员工';
|
||||
}
|
||||
if(hasRole('vip')){
|
||||
return 'VIP会员';
|
||||
}
|
||||
return '注册用户';
|
||||
return userInfo?.roles?.[0]?.roleName || userInfo?.roleName || '业务员'
|
||||
}
|
||||
|
||||
// 检查用户是否已实名认证
|
||||
const isCertified = () => {
|
||||
return user?.certification === true;
|
||||
|
||||
Reference in New Issue
Block a user