登录界面重构

This commit is contained in:
mmc
2026-04-21 09:44:39 +08:00
parent 713322659c
commit 1b67dce6d6
5 changed files with 102 additions and 87 deletions

BIN
src/assets/bgc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

BIN
src/assets/bgc1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

BIN
src/assets/bgc2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

BIN
src/assets/logincard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

View File

@@ -4,31 +4,28 @@ import {
Form,
Input,
Button,
Checkbox,
Typography,
Space,
Card,
message
message,
Checkbox,
} from 'antd';
import {
UserOutlined,
LockOutlined,
RocketOutlined,
SafetyCertificateOutlined,
ArrowRightOutlined
} from '@ant-design/icons';
import { motion } from 'motion/react';
import bgcImg from '../assets/bgc2.png';
import logincard from '../assets/logincard.png';
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 = '观察员';
@@ -40,16 +37,15 @@ export default function Login() {
name = '操作员';
}
// 存储用户信息
const userInfo = {
username: values.username,
name: name,
role: role,
avatar: `https://api.dicebear.com/7.x/avataaars/svg?seed=${values.username}`
avatar: `https://api.dicebear.com7.x/avataaars/svg?seed=${values.username}`
};
localStorage.setItem('isAuthenticated', 'true');
localStorage.setItem('token', 'mock_token_' + Date.now()); // 模拟 Token
localStorage.setItem('token', 'mock_token_' + Date.now());
localStorage.setItem('user', JSON.stringify(userInfo));
message.success(`欢迎回来, ${name}`);
@@ -57,94 +53,113 @@ export default function Login() {
};
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>
<div className="min-h-screen bg-[#F5F8FC] flex items-center justify-center p-4 relative overflow-hidden"
style={{
backgroundImage: `url(${bgcImg})`,
backgroundSize: 'cover',
backgroundPosition: 'center'
}}
>
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
style={{ width: '100%', maxWidth: 400 }}
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
transition={{ duration: 0.4 }}
className="w-full max-w-5xl"
>
<Card
bordered={false}
className="shadow-2xl overflow-hidden"
className="shadow-xl overflow-hidden rounded-2xl"
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 className="flex flex-col md:flex-row relative">
{/* 左侧:表单区域 */}
<div className="md:w-1/2 bg-white p-10 md:p-16 flex flex-col justify-center relative z-10">
<motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: 0.2 }}>
<Title level={2} style={{ marginBottom: 40, color: '#111', fontWeight: 700 }}>
机器人智慧服务系统
</Title>
<Form name="login" layout="vertical" onFinish={onFinish} autoComplete="off" size="large">
<Form.Item name="username" rules={[{ required: true, message: '请输入账号' }]}>
<Input
prefix={<UserOutlined style={{ color: '#999' }} />}
placeholder="请输入账号"
style={{ borderRadius: 8, height: 52, fontSize: 15, borderColor: '#e5e7eb' }}
/>
</Form.Item>
<Form.Item name="password" rules={[{ required: true, message: '请输入密码' }]}>
<Input.Password
prefix={<LockOutlined style={{ color: '#999' }} />}
placeholder="请输入密码"
style={{ borderRadius: 8, height: 52, fontSize: 15, borderColor: '#e5e7eb' }}
/>
</Form.Item>
{/* 记住密码 */}
<Form.Item name="remember" valuePropName="checked" noStyle>
<Checkbox>
<Text style={{ fontSize: 14, color: '#666' }}>记住密码</Text>
</Checkbox>
</Form.Item>
<Form.Item style={{ marginTop: 20 }}>
<Button
type="primary"
htmlType="submit"
block
style={{
borderRadius: 8,
height: 52,
fontWeight: 600,
fontSize: 16,
backgroundColor: '#1677ff',
borderColor: '#1677ff',
boxShadow: '0 4px 12px rgba(22, 119, 255, 0.25)'
}}
>
登录
</Button>
</Form.Item>
{/* 用户协议 */}
<Form.Item
name="agreement"
valuePropName="checked"
rules={[{ validator: (_, value) => value ? Promise.resolve() : Promise.reject(new Error('请阅读并同意用户协议')) }]}
>
<Checkbox>
<Text style={{ fontSize: 14, color: '#666' }}>
我已阅读并同意 <Text type="link" style={{ padding: 0, color: "#1677ff" }}>用户协议</Text> 和 <Text type="link" style={{ padding: 0, color: "#1677ff" }}>隐私政策</Text>
</Text>
</Checkbox>
</Form.Item>
</Form>
</motion.div>
</div>
<Title level={4} style={{ color: '#fff', margin: 0, letterSpacing: 1 }}>机器人智慧服务系统</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"
{/* 右侧:梯形斜切 + 图片铺满 */}
<div
className="md:w-1/2 relative min-h-[600px] overflow-hidden"
style={{
// 梯形斜切效果
clipPath: 'polygon(12% 0, 100% 0, 100% 100%, 0 100%)',
}}
>
<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
className="absolute inset-0 w-full h-full"
style={{
backgroundImage: `url(${logincard})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
}}
/>
</div>
</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>
);
}