Compare commits

..

2 Commits

2 changed files with 134 additions and 70 deletions

View File

@@ -67,14 +67,6 @@ function AdminLayout() {
label: '用户资料',
onClick: () => navigate('/admin/profile'),
},
{
key: 'changePassword',
icon: <LockOutlined />,
label: '修改密码',
onClick: () => {
message.info('修改密码功能即将上线');
},
},
{
type: 'divider' as const,
},
@@ -96,6 +88,15 @@ function AdminLayout() {
return 'dashboard';
};
const getTitle = () => {
const path = location.pathname;
if (path.includes('/dashboard')) return '控制台';
if (path.includes('/generate')) return '生成二维码';
if (path.includes('/manage')) return '企业管理';
if (path.includes('/profile')) return '用户资料';
return '控制台';
};
return (
<Layout className="admin-layout">
<Sider
@@ -117,7 +118,7 @@ function AdminLayout() {
<Layout>
<Header className="admin-header">
<div className="header-title">
{menuItems.find((item) => item.key === getSelectedKey())?.label}
{getTitle()}
</div>
<div className="header-right">
<Dropdown menu={{ items: userMenuItems }} placement="bottomRight">

View File

@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { Form, Input, Button, Card, message, Avatar, Descriptions, Space, Modal } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import { Form, Input, Button, Card, message, Avatar, Descriptions, Space, Modal, Row, Col } from 'antd';
import { UserOutlined, LockOutlined, SafetyOutlined, KeyOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import { authApi } from '@/services/api';
import type { User } from '@/types';
@@ -60,77 +60,140 @@ function ProfilePage() {
};
return (
<div style={{ maxWidth: '800px', margin: '0 auto' }}>
<div>
<Card
title={
<span>
<UserOutlined />
</span>
}
style={{ marginBottom: '24px' }}
bordered={false}
>
{user && (
<Descriptions column={1} bordered style={{ marginBottom: '24px' }}>
<Descriptions.Item label="头像">
<Avatar icon={<UserOutlined />} size={64} />
</Descriptions.Item>
<Descriptions.Item label="用户名">{user.username}</Descriptions.Item>
<Descriptions.Item label="姓名">{user.name}</Descriptions.Item>
<Descriptions.Item label="邮箱">{user.email || '-'}</Descriptions.Item>
<Descriptions.Item label="角色">{user.role}</Descriptions.Item>
<Descriptions.Item label="创建时间">
{new Date(user.createdAt).toLocaleString('zh-CN')}
</Descriptions.Item>
</Descriptions>
)}
<Row gutter={24}>
<Col span={12}>
{user && (
<Descriptions column={1} bordered>
<Descriptions.Item label="头像">
<Avatar icon={<UserOutlined />} size={64} />
</Descriptions.Item>
<Descriptions.Item label="用户名">{user.username}</Descriptions.Item>
<Descriptions.Item label="姓名">{user.name}</Descriptions.Item>
<Descriptions.Item label="邮箱">{user.email || '-'}</Descriptions.Item>
<Descriptions.Item label="角色">{user.role}</Descriptions.Item>
<Descriptions.Item label="创建时间">
{new Date(user.createdAt).toLocaleString('zh-CN')}
</Descriptions.Item>
</Descriptions>
)}
</Col>
<Form
form={profileForm}
onFinish={handleUpdateProfile}
layout="vertical"
>
<Form.Item
label="姓名"
name="name"
rules={[{ required: true, message: '请输入姓名' }]}
>
<Input />
</Form.Item>
<Col span={12}>
<div style={{ marginBottom: '16px', fontSize: '16px', fontWeight: 'bold' }}>
</div>
<Form
form={profileForm}
onFinish={handleUpdateProfile}
layout="vertical"
>
<Form.Item
label="姓名"
name="name"
rules={[{ required: true, message: '请输入姓名' }]}
>
<Input />
</Form.Item>
<Form.Item
label="邮箱"
name="email"
rules={[{ type: 'email', message: '请输入有效的邮箱地址' }]}
>
<Input />
</Form.Item>
<Form.Item
label="邮箱"
name="email"
rules={[{ type: 'email', message: '请输入有效的邮箱地址' }]}
>
<Input />
</Form.Item>
<Form.Item>
<Space>
<Button type="primary" htmlType="submit" loading={loading}>
</Button>
<Button onClick={loadUserProfile}>
</Button>
</Space>
</Form.Item>
</Form>
<Form.Item>
<Space>
<Button type="primary" htmlType="submit" loading={loading}>
</Button>
<Button onClick={loadUserProfile}>
</Button>
</Space>
</Form.Item>
</Form>
<div style={{ marginTop: '24px', marginBottom: '16px', fontSize: '16px', fontWeight: 'bold' }}>
</div>
<Card
size="small"
bordered={false}
style={{ backgroundColor: '#fafafa' }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space>
<LockOutlined />
<span></span>
</Space>
<Button type="primary" onClick={() => setPasswordModalVisible(true)}>
</Button>
</div>
</Card>
<Card
size="small"
bordered={false}
style={{ marginTop: '16px', backgroundColor: '#fafafa' }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space>
<SafetyOutlined />
<span>TOTP</span>
</Space>
<Button type="default">
</Button>
</div>
</Card>
<Card
size="small"
bordered={false}
style={{ marginTop: '16px', backgroundColor: '#fafafa' }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space>
<KeyOutlined />
<span>Passkey</span>
</Space>
<Button type="default">
</Button>
</div>
</Card>
<Card
size="small"
bordered={false}
style={{ marginTop: '16px', backgroundColor: '#fafafa' }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space>
<ExclamationCircleOutlined />
<span></span>
</Space>
<Button danger>
</Button>
</div>
</Card>
</Col>
</Row>
</Card>
<Card
title={
<span>
<LockOutlined />
</span>
}
extra={
<Button type="primary" onClick={() => setPasswordModalVisible(true)}>
</Button>
}
/>
<Modal
title="修改密码"
open={passwordModalVisible}