2026-04-17 17:20:41 +08:00
|
|
|
|
import React from 'react';
|
|
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
2026-04-21 08:51:57 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Form,
|
|
|
|
|
|
Input,
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Typography,
|
|
|
|
|
|
Card,
|
2026-04-21 09:44:39 +08:00
|
|
|
|
message,
|
|
|
|
|
|
Checkbox,
|
2026-04-21 14:57:52 +08:00
|
|
|
|
App,
|
2026-04-17 17:20:41 +08:00
|
|
|
|
} from 'antd';
|
2026-04-21 08:51:57 +08:00
|
|
|
|
import {
|
|
|
|
|
|
UserOutlined,
|
|
|
|
|
|
LockOutlined,
|
2026-04-17 17:20:41 +08:00
|
|
|
|
} from '@ant-design/icons';
|
|
|
|
|
|
import { motion } from 'motion/react';
|
2026-04-21 09:44:39 +08:00
|
|
|
|
import bgcImg from '../assets/bgc2.png';
|
|
|
|
|
|
import logincard from '../assets/logincard.png';
|
2026-04-22 09:43:55 +08:00
|
|
|
|
import { userLogin } from '../store/userSlice';
|
2026-04-21 14:57:52 +08:00
|
|
|
|
import { useAppDispatch } from '../store';
|
2026-04-22 09:43:55 +08:00
|
|
|
|
import Cookies from 'js-cookie';
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
|
|
|
|
|
const { Text, Title } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
export default function Login() {
|
2026-04-21 08:51:57 +08:00
|
|
|
|
const navigate = useNavigate();
|
2026-04-21 14:57:52 +08:00
|
|
|
|
const dispatch = useAppDispatch();
|
2026-04-22 09:43:55 +08:00
|
|
|
|
const { message, } = App.useApp();
|
2026-04-21 08:51:57 +08:00
|
|
|
|
|
2026-04-21 09:44:39 +08:00
|
|
|
|
// 账号密码登录
|
2026-04-21 14:57:52 +08:00
|
|
|
|
const onFinish = async (values: any) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 👇 调用 dispatch,并用 unwrap() 拿到 return 的数据
|
|
|
|
|
|
const loginResult = await dispatch(userLogin(values)).unwrap();
|
2026-04-21 08:51:57 +08:00
|
|
|
|
|
2026-04-21 14:57:52 +08:00
|
|
|
|
// loginResult 就是你 userLogin 里 return 的 res
|
|
|
|
|
|
console.log("登录成功返回的数据:", loginResult);
|
2026-04-21 08:51:57 +08:00
|
|
|
|
|
2026-04-21 14:57:52 +08:00
|
|
|
|
if (loginResult.code == 200) {
|
|
|
|
|
|
//dispatch(setUserInfo(loginResult))
|
2026-04-22 09:43:55 +08:00
|
|
|
|
const searchParams = new URLSearchParams(window.location.search);
|
|
|
|
|
|
const goRemote = searchParams.get('goRemote');
|
|
|
|
|
|
if (Number(goRemote) == 1) {
|
|
|
|
|
|
const rawUserId = Cookies.get("userId"); // 比如 "32434"
|
|
|
|
|
|
|
|
|
|
|
|
const encodedUserId = btoa(unescape(encodeURIComponent(rawUserId)));
|
|
|
|
|
|
window.location.href = `https://ai.satabot.com/?userId=${encodedUserId}`;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-21 14:57:52 +08:00
|
|
|
|
|
|
|
|
|
|
message.success(`登录成功`);
|
2026-04-22 09:43:55 +08:00
|
|
|
|
navigate('/', { replace: true });
|
2026-04-21 14:57:52 +08:00
|
|
|
|
} else {
|
2026-04-21 08:51:57 +08:00
|
|
|
|
|
2026-04-21 14:57:52 +08:00
|
|
|
|
message.error("登录失败:" + loginResult.msg);
|
2026-04-21 08:51:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
2026-04-21 14:57:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 登录成功后跳转
|
|
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
2026-04-22 09:43:55 +08:00
|
|
|
|
message.error("登录失败:" + err.toString());
|
|
|
|
|
|
|
2026-04-21 14:57:52 +08:00
|
|
|
|
}
|
2026-04-21 10:33:48 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2026-04-21 09:44:39 +08:00
|
|
|
|
<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'
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<motion.div
|
2026-04-21 09:44:39 +08:00
|
|
|
|
initial={{ opacity: 0, scale: 0.95 }}
|
|
|
|
|
|
animate={{ opacity: 1, scale: 1 }}
|
|
|
|
|
|
transition={{ duration: 0.4 }}
|
|
|
|
|
|
className="w-full max-w-5xl"
|
2026-04-21 08:51:57 +08:00
|
|
|
|
>
|
|
|
|
|
|
<Card
|
|
|
|
|
|
bordered={false}
|
2026-04-21 09:44:39 +08:00
|
|
|
|
className="shadow-xl overflow-hidden rounded-2xl"
|
2026-04-21 08:51:57 +08:00
|
|
|
|
styles={{ body: { padding: 0 } }}
|
|
|
|
|
|
>
|
2026-04-21 09:44:39 +08:00
|
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
|
|
{/* 记住密码 */}
|
2026-04-22 09:43:55 +08:00
|
|
|
|
{/*<Form.Item name="remember" valuePropName="checked" noStyle>
|
2026-04-21 09:44:39 +08:00
|
|
|
|
<Checkbox>
|
|
|
|
|
|
<Text style={{ fontSize: 14, color: '#666' }}>记住密码</Text>
|
|
|
|
|
|
</Checkbox>
|
2026-04-22 09:43:55 +08:00
|
|
|
|
</Form.Item>*/}
|
2026-04-21 09:44:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-04-21 09:44:39 +08:00
|
|
|
|
{/* 右侧:梯形斜切 + 图片铺满 */}
|
|
|
|
|
|
<div
|
|
|
|
|
|
className="md:w-1/2 relative min-h-[600px] overflow-hidden"
|
|
|
|
|
|
style={{
|
|
|
|
|
|
// 梯形斜切效果
|
|
|
|
|
|
clipPath: 'polygon(12% 0, 100% 0, 100% 100%, 0 100%)',
|
|
|
|
|
|
}}
|
2026-04-21 08:51:57 +08:00
|
|
|
|
>
|
2026-04-21 09:44:39 +08:00
|
|
|
|
<div
|
|
|
|
|
|
className="absolute inset-0 w-full h-full"
|
|
|
|
|
|
style={{
|
|
|
|
|
|
backgroundImage: `url(${logincard})`,
|
|
|
|
|
|
backgroundSize: 'cover',
|
|
|
|
|
|
backgroundPosition: 'center',
|
|
|
|
|
|
backgroundRepeat: 'no-repeat',
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
2026-04-17 17:20:41 +08:00
|
|
|
|
}
|