优化后台UI与开放文档排版设计
This commit is contained in:
@@ -1,66 +1,132 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Card, Form, Input, Button, Typography, message, Space } from 'antd'
|
||||
import { UserOutlined, LockOutlined } from '@ant-design/icons'
|
||||
import { Form, Input, Button, Typography, message, Space, Tag } from 'antd'
|
||||
import { UserOutlined, LockOutlined, RightOutlined } from '@ant-design/icons'
|
||||
import { useAuth } from '../store/auth'
|
||||
|
||||
export default function Login() {
|
||||
const { login } = useAuth()
|
||||
const navigate = useNavigate()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [form] = Form.useForm()
|
||||
|
||||
const onFinish = async (values: { username: string; password: string }) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
await login(values.username, values.password)
|
||||
message.success('登录成功')
|
||||
message.success('登录成功,欢迎回来!')
|
||||
navigate('/')
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '登录失败')
|
||||
message.error(e instanceof Error ? e.message : '登录失败,请检查账号密码')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const fillCredentials = (user: string, pass: string) => {
|
||||
form.setFieldsValue({ username: user, password: pass })
|
||||
message.info(`已填入账号: ${user}`)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
minHeight: '100vh',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
background: 'linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%)',
|
||||
}}
|
||||
>
|
||||
<Card style={{ width: 400, boxShadow: '0 8px 32px rgba(0,0,0,0.3)' }}>
|
||||
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
|
||||
<div className="login-wrapper">
|
||||
<div className="login-card">
|
||||
<Space direction="vertical" size="large" style={{ width: '100%' }}>
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<Typography.Title level={3} style={{ marginBottom: 4 }}>
|
||||
游戏皮肤供货平台
|
||||
<div className="login-logo">S</div>
|
||||
<Typography.Title level={3} style={{ margin: '0 0 6px 0', color: '#ffffff', fontWeight: 700 }}>
|
||||
Skin Hub 游戏皮肤分销平台
|
||||
</Typography.Title>
|
||||
<Typography.Text type="secondary">登录后台管理</Typography.Text>
|
||||
<Typography.Text style={{ color: '#94a3b8', fontSize: 13 }}>
|
||||
基于 Go + React 的高并发皮肤分发管理系统
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<Form layout="vertical" onFinish={onFinish} initialValues={{ username: 'admin', password: 'admin123' }}>
|
||||
<Form.Item name="username" rules={[{ required: true, message: '请输入用户名' }]}>
|
||||
<Input prefix={<UserOutlined />} placeholder="用户名" size="large" />
|
||||
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onFinish={onFinish}
|
||||
initialValues={{ username: 'admin', password: 'admin123' }}
|
||||
requiredMark={false}
|
||||
>
|
||||
<Form.Item
|
||||
name="username"
|
||||
rules={[{ required: true, message: '请输入用户名' }]}
|
||||
style={{ marginBottom: 18 }}
|
||||
>
|
||||
<Input
|
||||
prefix={<UserOutlined style={{ color: '#64748b' }} />}
|
||||
placeholder="用户名 / 手机号"
|
||||
size="large"
|
||||
style={{ borderRadius: 8 }}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="password" rules={[{ required: true, message: '请输入密码' }]}>
|
||||
<Input.Password prefix={<LockOutlined />} placeholder="密码" size="large" />
|
||||
|
||||
<Form.Item
|
||||
name="password"
|
||||
rules={[{ required: true, message: '请输入密码' }]}
|
||||
style={{ marginBottom: 24 }}
|
||||
>
|
||||
<Input.Password
|
||||
prefix={<LockOutlined style={{ color: '#64748b' }} />}
|
||||
placeholder="密码"
|
||||
size="large"
|
||||
style={{ borderRadius: 8 }}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type="primary" htmlType="submit" loading={loading} block size="large">
|
||||
登录
|
||||
|
||||
<Form.Item style={{ marginBottom: 12 }}>
|
||||
<Button
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
loading={loading}
|
||||
block
|
||||
size="large"
|
||||
icon={<RightOutlined />}
|
||||
style={{
|
||||
height: 46,
|
||||
borderRadius: 8,
|
||||
fontSize: 15,
|
||||
fontWeight: 600,
|
||||
background: 'linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%)',
|
||||
boxShadow: '0 4px 14px rgba(37, 99, 235, 0.4)',
|
||||
}}
|
||||
>
|
||||
安全登录
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Typography.Paragraph type="secondary" style={{ fontSize: 12, marginBottom: 0, textAlign: 'center' }}>
|
||||
商户账号请联系平台管理员创建
|
||||
</Typography.Paragraph>
|
||||
<Typography.Paragraph type="secondary" style={{ fontSize: 12, marginBottom: 0, textAlign: 'center' }}>
|
||||
默认管理员:admin / admin123
|
||||
|
||||
{/* 快捷测试账号填充 */}
|
||||
<div
|
||||
style={{
|
||||
padding: '12px 14px',
|
||||
borderRadius: 8,
|
||||
background: 'rgba(255, 255, 255, 0.04)',
|
||||
border: '1px solid rgba(255, 255, 255, 0.08)',
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: 12, color: '#94a3b8', marginBottom: 8, textAlign: 'center' }}>
|
||||
快速体验(演示账号列表):
|
||||
</div>
|
||||
<Space style={{ width: '100%', justifyContent: 'center' }} wrap>
|
||||
<Tag
|
||||
color="blue"
|
||||
style={{ cursor: 'pointer', padding: '4px 10px', borderRadius: 4 }}
|
||||
onClick={() => fillCredentials('admin', 'admin123')}
|
||||
>
|
||||
管理员 (admin)
|
||||
</Tag>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<Typography.Paragraph
|
||||
style={{ fontSize: 12, margin: 0, textAlign: 'center', color: '#64748b' }}
|
||||
>
|
||||
商户账号与成员密钥请联系平台管理员统一配置与创建
|
||||
</Typography.Paragraph>
|
||||
</Space>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user