生产管理系统 - 拦截器业务逻辑增强
This commit is contained in:
@@ -13,28 +13,31 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { UserProfile, PasswordChange } from '@/types/profile';
|
||||
import { User, Mail, Phone, Building, Briefcase, Lock, Save, Shield } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import { useAuth } from '@/components/auth/AuthContext';
|
||||
|
||||
export default function PersonalInfo() {
|
||||
const { user } = useAuth();
|
||||
|
||||
const [profile, setProfile] = useState<UserProfile>({
|
||||
id: 'user-1',
|
||||
username: 'admin',
|
||||
name: '系统管理员',
|
||||
email: 'admin@smart-agriculture.com',
|
||||
phone: '13800138000',
|
||||
id: user?.id || '',
|
||||
username: user?.username || '',
|
||||
name: user?.realName || '',
|
||||
email: user?.email || '',
|
||||
phone: user?.phone || '',
|
||||
avatar: '',
|
||||
gender: 'male',
|
||||
birthday: '1990-01-01',
|
||||
department: '技术部',
|
||||
position: '系统管理员',
|
||||
enterpriseId: 'ent-1',
|
||||
enterpriseName: '智慧农业科技有限公司',
|
||||
roleIds: ['role-1'],
|
||||
roleNames: ['超级管理员'],
|
||||
bio: '负责系统整体架构和技术管理',
|
||||
address: '北京市海淀区中关村大街1号',
|
||||
createdAt: '2024-01-01T00:00:00',
|
||||
lastLoginTime: '2024-10-14T09:30:00',
|
||||
lastLoginIp: '192.168.1.100',
|
||||
gender: '',
|
||||
birthday: '',
|
||||
department: '',
|
||||
position: '',
|
||||
enterpriseId: user?.enterpriseId || '',
|
||||
enterpriseName: user?.enterpriseName || '',
|
||||
roleIds: [],
|
||||
roleNames: user?.is_superuser ? ['超级管理员'] : ['普通用户'],
|
||||
bio: '',
|
||||
address: '',
|
||||
createdAt: user?.createdAt || '',
|
||||
lastLoginTime: '',
|
||||
lastLoginIp: '',
|
||||
});
|
||||
|
||||
const [showPasswordDialog, setShowPasswordDialog] = useState(false);
|
||||
@@ -50,6 +53,24 @@ export default function PersonalInfo() {
|
||||
loadProfile();
|
||||
}, []);
|
||||
|
||||
// 当用户信息变化时,更新 profile 状态
|
||||
useEffect(() => {
|
||||
if (user) {
|
||||
setProfile(prev => ({
|
||||
...prev,
|
||||
id: user.id || '',
|
||||
username: user.username || '',
|
||||
name: user.realName || '',
|
||||
email: user.email || '',
|
||||
phone: user.phone || '',
|
||||
enterpriseId: user.enterpriseId || '',
|
||||
enterpriseName: user.enterpriseName || '',
|
||||
roleNames: user.is_superuser ? ['超级管理员'] : ['普通用户'],
|
||||
createdAt: user.createdAt || '',
|
||||
}));
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
const loadProfile = () => {
|
||||
const data = localStorage.getItem('smart_agriculture_user_profile');
|
||||
if (data) {
|
||||
|
||||
Reference in New Issue
Block a user