From eb9b4b07ad94cc2378756e8eaba8a984b45ac61c Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Tue, 16 Jul 2024 15:48:56 +0800 Subject: [PATCH] feat: update register page --- web/src/components/RegisterForm.js | 217 +++++++++++++++-------------- 1 file changed, 113 insertions(+), 104 deletions(-) diff --git a/web/src/components/RegisterForm.js b/web/src/components/RegisterForm.js index fcd2638..5ff2588 100644 --- a/web/src/components/RegisterForm.js +++ b/web/src/components/RegisterForm.js @@ -1,16 +1,10 @@ import React, { useEffect, useState } from 'react'; -import { - Button, - Form, - Grid, - Header, - Image, - Message, - Segment, -} from 'semantic-ui-react'; import { Link, useNavigate } from 'react-router-dom'; import { API, getLogo, showError, showInfo, showSuccess } from '../helpers'; import Turnstile from 'react-turnstile'; +import { Button, Card, Form, Layout } from '@douyinfe/semi-ui'; +import Title from '@douyinfe/semi-ui/lib/es/typography/title'; +import Text from '@douyinfe/semi-ui/lib/es/typography/text'; const RegisterForm = () => { const [inputs, setInputs] = useState({ @@ -18,7 +12,7 @@ const RegisterForm = () => { password: '', password2: '', email: '', - verification_code: '', + verification_code: '' }); const { username, password, password2 } = inputs; const [showEmailVerification, setShowEmailVerification] = useState(false); @@ -46,9 +40,7 @@ const RegisterForm = () => { let navigate = useNavigate(); - function handleChange(e) { - const { name, value } = e.target; - console.log(name, value); + function handleChange(name, value) { setInputs((inputs) => ({ ...inputs, [name]: value })); } @@ -73,7 +65,7 @@ const RegisterForm = () => { inputs.aff_code = affCode; const res = await API.post( `/api/user/register?turnstile=${turnstileToken}`, - inputs, + inputs ); const { success, message } = res.data; if (success) { @@ -94,7 +86,7 @@ const RegisterForm = () => { } setLoading(true); const res = await API.get( - `/api/verification?email=${inputs.email}&turnstile=${turnstileToken}`, + `/api/verification?email=${inputs.email}&turnstile=${turnstileToken}` ); const { success, message } = res.data; if (success) { @@ -106,96 +98,113 @@ const RegisterForm = () => { }; return ( - - -
- 新用户注册 -
-
- - - - - {showEmailVerification ? ( - <> - - 获取验证码 - - } +
+ + + +
+
+ + + 新用户注册 + + + handleChange('username', value)} + /> + handleChange('password', value)} + /> + handleChange('password2', value)} + /> + {showEmailVerification ? ( + <> + handleChange('email', value)} + name="email" + type="email" + suffix={ + + } + /> + handleChange('verification_code', value)} + name="verification_code" + /> + + ) : ( + <> + )} + + +
+ + 已有账户? + + 点击登录 + + +
+
+ {turnstileEnabled ? ( + { + setTurnstileToken(token); + }} /> - - - ) : ( - <> - )} - {turnstileEnabled ? ( - { - setTurnstileToken(token); - }} - /> - ) : ( - <> - )} - - - - - 已有账户? - - 点击登录 - - - - + ) : ( + <> + )} +
+
+
+
+
); };