2023-04-22 20:39:27 +08:00
|
|
|
|
import React, { useEffect, useState } from 'react';
|
2025-06-04 00:42:06 +08:00
|
|
|
|
import { API, getLogo, showError, showInfo, showSuccess, getSystemName } from '../../helpers';
|
2023-04-22 20:39:27 +08:00
|
|
|
|
import Turnstile from 'react-turnstile';
|
2025-05-20 11:02:20 +08:00
|
|
|
|
import { Button, Card, Form, Typography } from '@douyinfe/semi-ui';
|
|
|
|
|
|
import { IconMail } from '@douyinfe/semi-icons';
|
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
|
|
|
|
const { Text, Title } = Typography;
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
|
|
|
|
|
const PasswordResetForm = () => {
|
2025-05-20 11:02:20 +08:00
|
|
|
|
const { t } = useTranslation();
|
2023-04-22 20:39:27 +08:00
|
|
|
|
const [inputs, setInputs] = useState({
|
2024-03-23 21:24:39 +08:00
|
|
|
|
email: '',
|
2023-04-22 20:39:27 +08:00
|
|
|
|
});
|
|
|
|
|
|
const { email } = inputs;
|
|
|
|
|
|
|
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
|
const [turnstileEnabled, setTurnstileEnabled] = useState(false);
|
|
|
|
|
|
const [turnstileSiteKey, setTurnstileSiteKey] = useState('');
|
|
|
|
|
|
const [turnstileToken, setTurnstileToken] = useState('');
|
2023-07-23 13:25:28 +08:00
|
|
|
|
const [disableButton, setDisableButton] = useState(false);
|
|
|
|
|
|
const [countdown, setCountdown] = useState(30);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
2025-05-20 11:02:20 +08:00
|
|
|
|
const logo = getLogo();
|
|
|
|
|
|
const systemName = getSystemName();
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
let status = localStorage.getItem('status');
|
|
|
|
|
|
if (status) {
|
|
|
|
|
|
status = JSON.parse(status);
|
|
|
|
|
|
if (status.turnstile_check) {
|
|
|
|
|
|
setTurnstileEnabled(true);
|
|
|
|
|
|
setTurnstileSiteKey(status.turnstile_site_key);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
2023-04-22 20:39:27 +08:00
|
|
|
|
useEffect(() => {
|
2023-07-23 13:25:28 +08:00
|
|
|
|
let countdownInterval = null;
|
|
|
|
|
|
if (disableButton && countdown > 0) {
|
|
|
|
|
|
countdownInterval = setInterval(() => {
|
|
|
|
|
|
setCountdown(countdown - 1);
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
} else if (countdown === 0) {
|
|
|
|
|
|
setDisableButton(false);
|
|
|
|
|
|
setCountdown(30);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
}
|
2023-07-23 13:25:28 +08:00
|
|
|
|
return () => clearInterval(countdownInterval);
|
|
|
|
|
|
}, [disableButton, countdown]);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
2025-05-20 11:02:20 +08:00
|
|
|
|
function handleChange(value) {
|
|
|
|
|
|
setInputs((inputs) => ({ ...inputs, email: value }));
|
2023-04-22 20:39:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function handleSubmit(e) {
|
2025-06-08 01:08:03 +08:00
|
|
|
|
if (!email) {
|
|
|
|
|
|
showError(t('请输入邮箱地址'));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-04-22 20:39:27 +08:00
|
|
|
|
if (turnstileEnabled && turnstileToken === '') {
|
2025-05-20 11:02:20 +08:00
|
|
|
|
showInfo(t('请稍后几秒重试,Turnstile 正在检查用户环境!'));
|
2023-04-22 20:39:27 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-05-20 11:02:20 +08:00
|
|
|
|
setDisableButton(true);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
setLoading(true);
|
|
|
|
|
|
const res = await API.get(
|
2024-03-23 21:24:39 +08:00
|
|
|
|
`/api/reset_password?email=${email}&turnstile=${turnstileToken}`,
|
2023-04-22 20:39:27 +08:00
|
|
|
|
);
|
|
|
|
|
|
const { success, message } = res.data;
|
|
|
|
|
|
if (success) {
|
2025-05-20 11:02:20 +08:00
|
|
|
|
showSuccess(t('重置邮件发送成功,请检查邮箱!'));
|
2023-04-22 20:39:27 +08:00
|
|
|
|
setInputs({ ...inputs, email: '' });
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showError(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2025-06-25 22:57:04 +08:00
|
|
|
|
<div className="relative overflow-hidden bg-gray-100 flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
|
|
|
|
|
{/* 背景模糊晕染球 */}
|
|
|
|
|
|
<div className="blur-ball blur-ball-indigo" style={{ top: '-80px', right: '-80px', transform: 'none' }} />
|
|
|
|
|
|
<div className="blur-ball blur-ball-teal" style={{ top: '50%', left: '-120px' }} />
|
🎨 refactor(ui): scope table scrolling to console cards & refine overall layout
Summary
Implement a dedicated, reusable scrolling mechanism for all console-table pages while keeping header and sidebar fixed, plus related layout improvements.
Key Changes
• Added `.table-scroll-card` utility class
– Provides flex column layout and internal vertical scrolling
– Desktop height: `calc(100vh - 110px)`; Mobile (<768 px) height: `calc(100vh - 77px)`
– Hides scrollbars cross-browser (`-ms-overflow-style`, `scrollbar-width`, `::-webkit-scrollbar`)
• Replaced global `.semi-card` scrolling rules with `.table-scroll-card` to avoid affecting non-table cards
• Updated table components (Channels, Tokens, Users, Logs, MjLogs, TaskLogs, Redemptions) to use the new class
• PageLayout
– Footer is now suppressed for all `/console` routes
– Confirmed only central content area scrolls; header & sidebar remain fixed
• Restored hidden scrollbar rules for `.semi-layout-content` and removed unnecessary global overrides
• Minor CSS cleanup & comment improvements for readability
Result
Console table pages now fill the viewport with smooth, internal scrolling and no visible scrollbars, while other cards and pages remain unaffected.
2025-07-18 01:06:18 +08:00
|
|
|
|
<div className="w-full max-w-sm mt-[60px]">
|
2025-05-20 11:02:20 +08:00
|
|
|
|
<div className="flex flex-col items-center">
|
|
|
|
|
|
<div className="w-full max-w-md">
|
|
|
|
|
|
<div className="flex items-center justify-center mb-6 gap-2">
|
|
|
|
|
|
<img src={logo} alt="Logo" className="h-10 rounded-full" />
|
2025-06-09 00:14:35 +08:00
|
|
|
|
<Title heading={3} className='!text-gray-800'>{systemName}</Title>
|
2025-05-20 11:02:20 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<Card className="shadow-xl border-0 !rounded-2xl overflow-hidden">
|
|
|
|
|
|
<div className="flex justify-center pt-6 pb-2">
|
|
|
|
|
|
<Title heading={3} className="text-gray-800 dark:text-gray-200">{t('密码重置')}</Title>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="px-2 py-8">
|
|
|
|
|
|
<Form className="space-y-3">
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field="email"
|
|
|
|
|
|
label={t('邮箱')}
|
|
|
|
|
|
placeholder={t('请输入您的邮箱地址')}
|
|
|
|
|
|
name="email"
|
|
|
|
|
|
size="large"
|
|
|
|
|
|
value={email}
|
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
|
prefix={<IconMail />}
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="space-y-2 pt-2">
|
|
|
|
|
|
<Button
|
|
|
|
|
|
theme="solid"
|
|
|
|
|
|
className="w-full !rounded-full"
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
htmlType="submit"
|
|
|
|
|
|
size="large"
|
|
|
|
|
|
onClick={handleSubmit}
|
|
|
|
|
|
loading={loading}
|
|
|
|
|
|
disabled={disableButton}
|
|
|
|
|
|
>
|
|
|
|
|
|
{disableButton ? `${t('重试')} (${countdown})` : t('提交')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="mt-6 text-center text-sm">
|
|
|
|
|
|
<Text>{t('想起来了?')} <Link to="/login" className="text-blue-600 hover:text-blue-800 font-medium">{t('登录')}</Link></Text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
|
|
{turnstileEnabled && (
|
|
|
|
|
|
<div className="flex justify-center mt-6">
|
|
|
|
|
|
<Turnstile
|
|
|
|
|
|
sitekey={turnstileSiteKey}
|
|
|
|
|
|
onVerify={(token) => {
|
|
|
|
|
|
setTurnstileToken(token);
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2023-04-22 20:39:27 +08:00
|
|
|
|
)}
|
2025-05-20 11:02:20 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2023-04-22 20:39:27 +08:00
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default PasswordResetForm;
|