|
|
@ -1,39 +1,38 @@ |
|
|
|
import { Layout, Input, Button, Typography, Row, Col, Form } from "antd"; |
|
|
|
import { LockOutlined, MailOutlined, SecurityScanOutlined } from "@ant-design/icons"; |
|
|
|
import {LockOutlined, MailOutlined, SecurityScanOutlined, UserOutlined} from "@ant-design/icons"; |
|
|
|
import { createFileRoute, useNavigate } from "@tanstack/react-router"; |
|
|
|
import { useAtom, useAtomValue } from "jotai"; |
|
|
|
import { useAtomValue } from "jotai"; |
|
|
|
import React, { memo, useEffect, useState } from "react"; |
|
|
|
import { emailCodeAtom, emailRegisterAtom } from "@/store/system/user.ts"; |
|
|
|
import { emailRegisterAtom } from "@/store/system/user.ts"; |
|
|
|
import { passwordRules } from "@/pages/use/useTools"; |
|
|
|
import systemServ from "@/service/system.ts"; |
|
|
|
const { Title, Text, Link } = Typography; |
|
|
|
|
|
|
|
const Register = memo(() => { |
|
|
|
const navigate = useNavigate(); |
|
|
|
const [registerForm] = Form.useForm(); |
|
|
|
const { mutate: emailRegisterMutate } = useAtomValue(emailRegisterAtom); |
|
|
|
const { mutateAsync: emailCodeMutate, data: emailData } = useAtomValue(emailCodeAtom); |
|
|
|
//const [{ mutate: emailCodeMutate, data: emailData }] = useAtom(emailCodeAtom);
|
|
|
|
//const [, mutate: emailCodeMutate] = useAtom(emailCodeAtom);
|
|
|
|
const [countdown, setCountdown] = useState(10); |
|
|
|
const [emailCodeData, setEmailCodeData] = useState({}); |
|
|
|
const [isButtonDisabled, setIsButtonDisabled] = useState<boolean>(false); |
|
|
|
|
|
|
|
const getEmailCode = () => { |
|
|
|
const email = registerForm.getFieldValue("email"); |
|
|
|
setCountdown(10); |
|
|
|
setIsButtonDisabled(true); |
|
|
|
const data = emailCodeMutate({ is_register: true, email }); |
|
|
|
console.log(data); |
|
|
|
setEmailCodeData(systemServ.emailCode({ is_register: true, email })); |
|
|
|
}; |
|
|
|
|
|
|
|
const emailRegisterSubmit = (values: any) => { |
|
|
|
emailRegisterMutate({ email: values.email, password: values.password, code: values.code }); |
|
|
|
}; |
|
|
|
|
|
|
|
const [countdown, setCountdown] = useState<number>(0); |
|
|
|
const [isButtonDisabled, setIsButtonDisabled] = useState<boolean>(false); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if ((emailData as any)?.countdown === -1) { |
|
|
|
if ((emailCodeData as any)?.countdown === -1) { |
|
|
|
setCountdown(0); |
|
|
|
setIsButtonDisabled(false); |
|
|
|
} |
|
|
|
}, [emailData]); |
|
|
|
}, [emailCodeData]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
let timer: number; |
|
|
@ -53,111 +52,111 @@ const Register = memo(() => { |
|
|
|
}, []); |
|
|
|
|
|
|
|
return ( |
|
|
|
<Layout |
|
|
|
style={{ |
|
|
|
height: "100vh", |
|
|
|
background: "url('https://placehold.co/1920x1080') no-repeat center center", |
|
|
|
backgroundSize: "cover", |
|
|
|
}} |
|
|
|
> |
|
|
|
<Row justify="center" align="middle" style={{ height: "100%" }}> |
|
|
|
<Col> |
|
|
|
<Row> |
|
|
|
<Col span={12} style={{ padding: "20px" }}> |
|
|
|
<Title level={3}>向量检索服务免费试用</Title> |
|
|
|
<Text>免费试用向量检索服务,玩转大模型生成式检索</Text> |
|
|
|
<br /> |
|
|
|
<Link href="#">查看详情 ></Link> |
|
|
|
</Col> |
|
|
|
<Col |
|
|
|
span={12} |
|
|
|
style={{ |
|
|
|
padding: "20px", |
|
|
|
background: "#fff", |
|
|
|
borderRadius: "8px", |
|
|
|
position: "relative", |
|
|
|
width: "500px", |
|
|
|
height: "500px", |
|
|
|
}} |
|
|
|
> |
|
|
|
<Form form={registerForm} onFinish={emailRegisterSubmit} style={{ marginTop: "50px" }}> |
|
|
|
<Form.Item name="email" rules={[{ required: true, message: "请输入邮箱" }]}> |
|
|
|
<Input |
|
|
|
size="large" |
|
|
|
placeholder="请输入邮箱" |
|
|
|
prefix={<MailOutlined />} |
|
|
|
addonAfter={ |
|
|
|
<Button onClick={getEmailCode} disabled={isButtonDisabled}> |
|
|
|
{isButtonDisabled ? `${countdown}秒后重试` : "获得验证码"} |
|
|
|
</Button> |
|
|
|
} |
|
|
|
/> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item name="code" rules={[{ required: true, message: "请输入验证码" }]}> |
|
|
|
<Input size="large" placeholder="请输入验证码" prefix={<SecurityScanOutlined />} autoComplete="off" /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item name="password" rules={passwordRules}> |
|
|
|
<Input.Password size="large" placeholder="请输入密码" prefix={<LockOutlined />} autoComplete="off" /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="confirmPassword" |
|
|
|
dependencies={["password"]} |
|
|
|
rules={[ |
|
|
|
{ required: true, message: "请确认密码" }, |
|
|
|
({ getFieldValue }) => ({ |
|
|
|
validator(_, value) { |
|
|
|
if (!value || getFieldValue("password") === value) { |
|
|
|
return Promise.resolve(); |
|
|
|
} |
|
|
|
return Promise.reject(new Error("两次输入的密码不一致")); |
|
|
|
}, |
|
|
|
}), |
|
|
|
]} |
|
|
|
> |
|
|
|
<Input.Password size="large" placeholder="请确认密码" prefix={<LockOutlined />} autoComplete="off" /> |
|
|
|
</Form.Item> |
|
|
|
<Button type="primary" htmlType="submit" style={{ width: "100%" }}> |
|
|
|
注册 |
|
|
|
</Button> |
|
|
|
</Form> |
|
|
|
<div |
|
|
|
style={{ |
|
|
|
position: "absolute", |
|
|
|
top: 0, |
|
|
|
right: 0, |
|
|
|
width: 0, |
|
|
|
height: 0, |
|
|
|
borderLeft: "80px solid transparent", |
|
|
|
borderTop: "80px solid #ff9800", |
|
|
|
textAlign: "center", |
|
|
|
}} |
|
|
|
> |
|
|
|
<span |
|
|
|
<Layout |
|
|
|
style={{ |
|
|
|
cursor: "pointer", // 设置手型光标
|
|
|
|
position: "absolute", |
|
|
|
top: "-70px", |
|
|
|
right: "0px", |
|
|
|
color: "#fff", |
|
|
|
fontSize: "16px", |
|
|
|
transform: "rotate(0deg)", |
|
|
|
textAlign: "center", |
|
|
|
width: "60px", |
|
|
|
display: "block", |
|
|
|
height: "100vh", |
|
|
|
background: "url('https://placehold.co/1920x1080') no-repeat center center", |
|
|
|
backgroundSize: "cover", |
|
|
|
}} |
|
|
|
onClick={() => navigate({ to: "/login" })} |
|
|
|
> |
|
|
|
<Row justify="center" align="middle" style={{ height: "100%" }}> |
|
|
|
<Col> |
|
|
|
<Row> |
|
|
|
<Col span={12} style={{ padding: "20px" }}> |
|
|
|
<Title level={3}>向量检索服务免费试用</Title> |
|
|
|
<Text>免费试用向量检索服务,玩转大模型生成式检索</Text> |
|
|
|
<br /> |
|
|
|
<Link href="#">查看详情 ></Link> |
|
|
|
</Col> |
|
|
|
<Col |
|
|
|
span={12} |
|
|
|
style={{ |
|
|
|
padding: "20px", |
|
|
|
background: "#fff", |
|
|
|
borderRadius: "8px", |
|
|
|
position: "relative", |
|
|
|
width: "500px", |
|
|
|
height: "500px", |
|
|
|
}} |
|
|
|
> |
|
|
|
<Form form={registerForm} onFinish={emailRegisterSubmit} style={{ marginTop: "50px" }}> |
|
|
|
<Form.Item name="email" rules={[{ required: true, message: "请输入邮箱" }]}> |
|
|
|
<Input |
|
|
|
size="large" |
|
|
|
placeholder="请输入邮箱" |
|
|
|
prefix={<MailOutlined />} |
|
|
|
addonAfter={ |
|
|
|
<Button onClick={getEmailCode} disabled={isButtonDisabled}> |
|
|
|
{isButtonDisabled ? `${countdown}秒后重试` : "获得验证码"} |
|
|
|
</Button> |
|
|
|
} |
|
|
|
/> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item name="code" rules={[{ required: true, message: "请输入验证码" }]}> |
|
|
|
<Input size="large" placeholder="请输入验证码" prefix={<SecurityScanOutlined />} autoComplete="off" /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item name="password" rules={passwordRules}> |
|
|
|
<Input.Password size="large" placeholder="请输入密码" prefix={<LockOutlined />} autoComplete="off" /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="confirmPassword" |
|
|
|
dependencies={["password"]} |
|
|
|
rules={[ |
|
|
|
{ required: true, message: "请确认密码" }, |
|
|
|
({ getFieldValue }) => ({ |
|
|
|
validator(_, value) { |
|
|
|
if (!value || getFieldValue("password") === value) { |
|
|
|
return Promise.resolve(); |
|
|
|
} |
|
|
|
return Promise.reject(new Error("两次输入的密码不一致")); |
|
|
|
}, |
|
|
|
}), |
|
|
|
]} |
|
|
|
> |
|
|
|
<Input.Password size="large" placeholder="请确认密码" prefix={<LockOutlined />} autoComplete="off" /> |
|
|
|
</Form.Item> |
|
|
|
<Button type="primary" htmlType="submit" style={{ width: "100%" }}> |
|
|
|
注册 |
|
|
|
</Button> |
|
|
|
</Form> |
|
|
|
<div |
|
|
|
style={{ |
|
|
|
position: "absolute", |
|
|
|
top: 0, |
|
|
|
right: 0, |
|
|
|
width: 0, |
|
|
|
height: 0, |
|
|
|
borderLeft: "80px solid transparent", |
|
|
|
borderTop: "80px solid #ff9800", |
|
|
|
textAlign: "center", |
|
|
|
}} |
|
|
|
> |
|
|
|
<span |
|
|
|
style={{ |
|
|
|
cursor: "pointer", |
|
|
|
position: "absolute", |
|
|
|
top: "-70px", |
|
|
|
right: "0px", |
|
|
|
color: "#fff", |
|
|
|
fontSize: "16px", |
|
|
|
transform: "rotate(0deg)", |
|
|
|
textAlign: "center", |
|
|
|
width: "60px", |
|
|
|
display: "block", |
|
|
|
}} |
|
|
|
onClick={() => navigate({ to: "/login" })} |
|
|
|
> |
|
|
|
登录 |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
<Row justify="space-between" style={{ marginTop: "10px" }}> |
|
|
|
<Link onClick={() => navigate({ to: "/login" })}>返回登录</Link> |
|
|
|
</Row> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Layout> |
|
|
|
</div> |
|
|
|
<Row justify="space-between" style={{ marginTop: "10px" }}> |
|
|
|
<Link onClick={() => navigate({ to: "/login" })}>返回登录</Link> |
|
|
|
</Row> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Layout> |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|