2025-07-19 03:30:44 +08:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (C) 2025 QuantumNous
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
For commercial licensing, please contact support@quantumnous.com
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
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>
|
|
|
|
|
|
|
🎛️ refactor: HeaderBar into modular components, add shared skeletons, and primary-colored nav hover
Summary
- Split HeaderBar into maintainable components and hooks
- Centralized skeleton loading UI via a reusable SkeletonWrapper
- Improved navigation UX with primary-colored hover indication
- Preserved API surface and passed linters
Why
- Improve readability, reusability, and testability of the header
- Remove duplicated skeleton logic across files
- Provide clearer hover feedback consistent with the theme
What’s changed
- Components (web/src/components/layout/HeaderBar/)
- New container: index.js
- New UI components: HeaderLogo.js, Navigation.js, ActionButtons.js, UserArea.js, MobileMenuButton.js, NewYearButton.js, NotificationButton.js, ThemeToggle.js, LanguageSelector.js
- New shared skeleton: SkeletonWrapper.js
- Updated entry: HeaderBar.js now re-exports ./HeaderBar/index.js
- Hooks (web/src/hooks/common/)
- New: useHeaderBar.js (state and actions for header)
- New: useNotifications.js (announcements state, unread calc, open/close)
- New: useNavigation.js (main nav link config)
- Skeleton refactor
- Navigation.js: replaced inline skeletons with <SkeletonWrapper type="navigation" .../>
- UserArea.js: replaced inline skeletons with <SkeletonWrapper type="userArea" .../>
- HeaderLogo.js: replaced image/title skeletons with <SkeletonWrapper type="image"/>, <SkeletonWrapper type="title"/>
- Navigation hover UX
- Added primary-colored hover to nav items for clearer pointer feedback
- Final hover style: hover:text-semi-color-primary (kept rounded + transition classes)
Non-functional
- No breaking API changes; HeaderBar usage stays the same
- All modified files pass lint checks
Notes for future work
- SkeletonWrapper is extensible: add new cases (e.g., card) in one place
- Components are small and test-friendly; unit tests can be added per component
Affected files (key)
- web/src/components/layout/HeaderBar.js
- web/src/components/layout/HeaderBar/index.js
- web/src/components/layout/HeaderBar/Navigation.js
- web/src/components/layout/HeaderBar/UserArea.js
- web/src/components/layout/HeaderBar/HeaderLogo.js
- web/src/components/layout/HeaderBar/ActionButtons.js
- web/src/components/layout/HeaderBar/MobileMenuButton.js
- web/src/components/layout/HeaderBar/NewYearButton.js
- web/src/components/layout/HeaderBar/NotificationButton.js
- web/src/components/layout/HeaderBar/ThemeToggle.js
- web/src/components/layout/HeaderBar/LanguageSelector.js
- web/src/components/layout/HeaderBar/SkeletonWrapper.js
- web/src/hooks/common/useHeaderBar.js
- web/src/hooks/common/useNotifications.js
- web/src/hooks/common/useNavigation.js
2025-08-18 03:20:56 +08:00
|
|
|
|
<Card className="border-0 !rounded-2xl overflow-hidden">
|
2025-05-20 11:02:20 +08:00
|
|
|
|
<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"
|
|
|
|
|
|
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"
|
|
|
|
|
|
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;
|