diff --git a/src/pages/user-info/index.tsx b/src/pages/user-info/index.tsx new file mode 100644 index 0000000..15c49d4 --- /dev/null +++ b/src/pages/user-info/index.tsx @@ -0,0 +1,415 @@ +import React, { useState } from 'react'; +import { + Card, + Form, + Input, + Button, + Avatar, + Upload, + Space, + Typography, + Divider, + Grid, + Message, + Select, + DatePicker, + Radio, + Descriptions, + Tag, + Statistic, +} from '@arco-design/web-react'; +import { + IconUser, + IconEmail, + IconPhone, + IconLocation, + IconEdit, + IconCamera, + IconCheck, + IconClose, +} from '@arco-design/web-react/icon'; +import styles from './style/index.module.less'; + +const { Title, Paragraph, Text } = Typography; +const { Row, Col } = Grid; +const FormItem = Form.Item; +const Option = Select.Option; +const RadioGroup = Radio.Group; + +/** + * 个人信息页面 + */ +function UserInfo() { + const [form] = Form.useForm(); + const [isEditing, setIsEditing] = useState(false); + const [loading, setLoading] = useState(false); + + // 模拟用户数据 + const [userInfo, setUserInfo] = useState({ + avatar: + 'https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp', + name: '张三', + username: 'zhangsan', + email: 'zhangsan@example.com', + phone: '138****8888', + gender: 'male', + birthday: '1990-01-01', + department: '技术部', + position: '高级工程师', + location: '北京市朝阳区', + introduction: + '热爱技术,专注于前端开发领域,有丰富的 React 和 TypeScript 开发经验。', + joinDate: '2020-01-15', + employeeId: 'EMP001', + }); + + // 统计数据 + const statistics = { + projectCount: 28, + taskCompleted: 156, + contribution: 892, + teamSize: 12, + }; + + // 初始化表单值 + React.useEffect(() => { + form.setFieldsValue(userInfo); + }, [userInfo, form]); + + // 保存用户信息 + const handleSave = async () => { + try { + const values = await form.validate(); + setLoading(true); + + // 模拟保存 + await new Promise((resolve) => setTimeout(resolve, 1000)); + + setUserInfo({ ...userInfo, ...values }); + setIsEditing(false); + Message.success('保存成功'); + } catch (error) { + console.error('表单验证失败:', error); + } finally { + setLoading(false); + } + }; + + // 取消编辑 + const handleCancel = () => { + form.setFieldsValue(userInfo); + setIsEditing(false); + }; + + // 上传头像 + const handleAvatarChange = (fileList) => { + if (fileList && fileList.length > 0) { + const file = fileList[0]; + if (file.originFile) { + const reader = new FileReader(); + reader.onload = (e) => { + setUserInfo({ ...userInfo, avatar: e.target?.result as string }); + Message.success('头像上传成功'); + }; + reader.readAsDataURL(file.originFile); + } + } + }; + + return ( +
+ {/* 顶部信息卡片 */} + + + {/* 左侧头像区域 */} + +
+
+ + avatar + + {isEditing && ( + +
+ +
更换头像
+
+
+ )} +
+ + {userInfo.name} + + + {userInfo.position} + +
+ {userInfo.department} +
+
+ + + {/* 右侧统计信息 */} + +
+ + + + + + + + + + + + + + + + + + +
+ +
+
+ + {/* 详细信息卡片 */} + } + onClick={() => setIsEditing(true)} + > + 编辑资料 + + ) : ( + + + + + ) + } + > +
+ + + + } + disabled={!isEditing} + /> + + + + + } + disabled={!isEditing} + /> + + + + + } + disabled={!isEditing} + /> + + + + + } + disabled={!isEditing} + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + disabled={!isEditing} + /> + + + + + + + + +
+
+ + {/* 账号安全卡片 */} + + + 当前密码强度:强 + + + ), + }, + { + label: '密保手机', + value: ( + + {userInfo.phone} + + + ), + }, + { + label: '密保邮箱', + value: ( + + {userInfo.email} + + + ), + }, + ]} + /> + +
+ ); +} + +export default UserInfo; diff --git a/src/pages/user-info/style/index.module.less b/src/pages/user-info/style/index.module.less new file mode 100644 index 0000000..e8b8e59 --- /dev/null +++ b/src/pages/user-info/style/index.module.less @@ -0,0 +1,81 @@ +.container { + padding: 20px; + background: var(--color-bg-2); + min-height: calc(100vh - 60px); +} + +.profile-card { + :global(.arco-card-body) { + padding: 32px; + } +} + +.avatar-section { + display: flex; + flex-direction: column; + align-items: center; +} + +.avatar-wrapper { + position: relative; + display: inline-block; + + .avatar { + border: 4px solid var(--color-border-2); + box-shadow: 0 2px 12px rgba(0, 0, 0, 10%); + + img { + width: 100%; + height: 100%; + object-fit: cover; + } + } + + .avatar-upload { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 50%); + border-radius: 50%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + color: #fff; + cursor: pointer; + opacity: 0; + transition: opacity 0.3s; + font-size: 12px; + + &:hover { + opacity: 1; + } + } +} + +.stats-section { + :global(.arco-statistic-title) { + color: var(--color-text-3); + font-size: 14px; + } + + :global(.arco-statistic-value) { + color: var(--color-text-1); + font-weight: 600; + } +} + +// 响应式布局 +@media (max-width: 768px) { + .container { + padding: 12px; + } + + .profile-card { + :global(.arco-card-body) { + padding: 16px; + } + } +}