151 lines
5.5 KiB
TypeScript
151 lines
5.5 KiB
TypeScript
|
|
import React from 'react';
|
||
|
|
import { useNavigate } from 'react-router-dom';
|
||
|
|
import {
|
||
|
|
Form,
|
||
|
|
Input,
|
||
|
|
Button,
|
||
|
|
Checkbox,
|
||
|
|
Typography,
|
||
|
|
Space,
|
||
|
|
Card,
|
||
|
|
message
|
||
|
|
} from 'antd';
|
||
|
|
import {
|
||
|
|
UserOutlined,
|
||
|
|
LockOutlined,
|
||
|
|
RocketOutlined,
|
||
|
|
SafetyCertificateOutlined,
|
||
|
|
ArrowRightOutlined
|
||
|
|
} from '@ant-design/icons';
|
||
|
|
import { motion } from 'motion/react';
|
||
|
|
|
||
|
|
const { Text, Title } = Typography;
|
||
|
|
|
||
|
|
export default function Login() {
|
||
|
|
const navigate = useNavigate();
|
||
|
|
|
||
|
|
const onFinish = (values: any) => {
|
||
|
|
// 模拟登录逻辑
|
||
|
|
console.log('Login attempt:', values);
|
||
|
|
|
||
|
|
// 根据用户名模拟不同的角色用于演示
|
||
|
|
let role = 'viewer';
|
||
|
|
let name = '观察员';
|
||
|
|
|
||
|
|
if (values.username === 'admin') {
|
||
|
|
role = 'admin';
|
||
|
|
name = '系统管理员';
|
||
|
|
} else if (values.username === 'operator') {
|
||
|
|
role = 'operator';
|
||
|
|
name = '操作员';
|
||
|
|
}
|
||
|
|
|
||
|
|
// 存储用户信息
|
||
|
|
const userInfo = {
|
||
|
|
username: values.username,
|
||
|
|
name: name,
|
||
|
|
role: role,
|
||
|
|
avatar: `https://api.dicebear.com/7.x/avataaars/svg?seed=${values.username}`
|
||
|
|
};
|
||
|
|
|
||
|
|
localStorage.setItem('isAuthenticated', 'true');
|
||
|
|
localStorage.setItem('token', 'mock_token_' + Date.now()); // 模拟 Token
|
||
|
|
localStorage.setItem('user', JSON.stringify(userInfo));
|
||
|
|
|
||
|
|
message.success(`欢迎回来, ${name}`);
|
||
|
|
navigate('/');
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div className="min-h-screen bg-[#001529] flex items-center justify-center p-4 relative overflow-hidden">
|
||
|
|
{/* Background Decor */}
|
||
|
|
<div className="absolute inset-0 overflow-hidden pointer-events-none opacity-20">
|
||
|
|
<div className="absolute top-0 left-0 w-full h-full bg-[radial-gradient(circle_at_50%_50%,#1890ff_0%,transparent_50%)] opacity-20" />
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<motion.div
|
||
|
|
initial={{ opacity: 0, y: 20 }}
|
||
|
|
animate={{ opacity: 1, y: 0 }}
|
||
|
|
style={{ width: '100%', maxWidth: 400 }}
|
||
|
|
>
|
||
|
|
<Card
|
||
|
|
bordered={false}
|
||
|
|
className="shadow-2xl overflow-hidden"
|
||
|
|
styles={{ body: { padding: 0 } }}
|
||
|
|
>
|
||
|
|
{/* Header */}
|
||
|
|
<div className="bg-[#001529] p-8 text-center border-b border-white/10">
|
||
|
|
<div className="inline-flex items-center justify-center w-12 h-12 rounded bg-blue-500/10 text-[#1890ff] mb-4 border border-blue-500/20">
|
||
|
|
<RocketOutlined style={{ fontSize: 24 }} />
|
||
|
|
</div>
|
||
|
|
<Title level={4} style={{ color: '#fff', margin: 0, letterSpacing: 1 }}>RobotMaster AI</Title>
|
||
|
|
<Text style={{ color: 'rgba(255,255,255,0.45)', fontSize: 10, marginTop: 4, display: 'block', letterSpacing: 2 }}>机器人智慧服务系统</Text>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{/* Form */}
|
||
|
|
<div className="p-8">
|
||
|
|
<Form
|
||
|
|
name="login"
|
||
|
|
layout="vertical"
|
||
|
|
onFinish={onFinish}
|
||
|
|
autoComplete="off"
|
||
|
|
size="large"
|
||
|
|
>
|
||
|
|
<Form.Item
|
||
|
|
label={<Text strong type="secondary" style={{ fontSize: 11, textTransform: 'uppercase' }}><UserOutlined style={{ color: '#1890ff', marginRight: 8 }} />账号名称</Text>}
|
||
|
|
name="username"
|
||
|
|
rules={[{ required: true, message: '请输入管理员账号' }]}
|
||
|
|
>
|
||
|
|
<Input placeholder="请输入管理员账号" style={{ borderRadius: 2 }} />
|
||
|
|
</Form.Item>
|
||
|
|
|
||
|
|
<Form.Item
|
||
|
|
label={<Text strong type="secondary" style={{ fontSize: 11, textTransform: 'uppercase' }}><LockOutlined style={{ color: '#1890ff', marginRight: 8 }} />访问令牌 / 密码</Text>}
|
||
|
|
name="password"
|
||
|
|
rules={[{ required: true, message: '请输入密码' }]}
|
||
|
|
>
|
||
|
|
<Input.Password placeholder="••••••••" style={{ borderRadius: 2 }} />
|
||
|
|
</Form.Item>
|
||
|
|
|
||
|
|
<div className="flex items-center justify-between mb-6">
|
||
|
|
<Form.Item name="remember" valuePropName="checked" noStyle>
|
||
|
|
<Checkbox><Text type="secondary" style={{ fontSize: 12 }}>记住会话</Text></Checkbox>
|
||
|
|
</Form.Item>
|
||
|
|
<Button type="link" size="small" style={{ fontSize: 12 }}>找回凭据?</Button>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<Form.Item>
|
||
|
|
<Button
|
||
|
|
type="primary"
|
||
|
|
htmlType="submit"
|
||
|
|
block
|
||
|
|
icon={<SafetyCertificateOutlined />}
|
||
|
|
style={{ borderRadius: 2, height: 44, fontWeight: 'bold', fontSize: 14 }}
|
||
|
|
>
|
||
|
|
核验并进入系统 <ArrowRightOutlined />
|
||
|
|
</Button>
|
||
|
|
</Form.Item>
|
||
|
|
</Form>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{/* Footer */}
|
||
|
|
<div className="px-8 py-4 bg-gray-50 border-t border-gray-100 flex justify-between items-center">
|
||
|
|
<Text type="secondary" style={{ fontSize: 10, fontFamily: 'monospace' }}>System Version: v4.2.1-stable</Text>
|
||
|
|
<Space size={4}>
|
||
|
|
<div className="w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse" />
|
||
|
|
<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase' }}>Server Online</Text>
|
||
|
|
</Space>
|
||
|
|
</div>
|
||
|
|
</Card>
|
||
|
|
</motion.div>
|
||
|
|
|
||
|
|
{/* Security Notice */}
|
||
|
|
<div className="absolute bottom-8 text-center w-full px-4">
|
||
|
|
<Text strong style={{ color: 'rgba(255,255,255,0.2)', fontSize: 10, letterSpacing: 4 }}>
|
||
|
|
AUTHORIZED PERSONNEL ONLY | ENCRYPTED LINK | TRACE ENABLED
|
||
|
|
</Text>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|