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, copy, showError, showNotice, getLogo, getSystemName } from '../../helpers';
|
2025-05-20 11:02:20 +08:00
|
|
|
import { useSearchParams, Link } from 'react-router-dom';
|
2025-06-08 01:44:38 +08:00
|
|
|
import { Button, Card, Form, Typography, Banner } from '@douyinfe/semi-ui';
|
2025-06-08 02:23:47 +08:00
|
|
|
import { IconMail, IconLock, IconCopy } from '@douyinfe/semi-icons';
|
2025-05-20 11:02:20 +08:00
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
|
|
const { Text, Title } = Typography;
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
|
|
|
const PasswordResetConfirm = () => {
|
2025-05-20 11:02:20 +08:00
|
|
|
const { t } = useTranslation();
|
2023-04-22 20:39:27 +08:00
|
|
|
const [inputs, setInputs] = useState({
|
|
|
|
|
email: '',
|
2024-03-23 21:24:39 +08:00
|
|
|
token: '',
|
2023-04-22 20:39:27 +08:00
|
|
|
});
|
|
|
|
|
const { email, token } = inputs;
|
2025-06-08 01:08:03 +08:00
|
|
|
const isValidResetLink = email && token;
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
2023-07-23 13:25:28 +08:00
|
|
|
const [disableButton, setDisableButton] = useState(false);
|
|
|
|
|
const [countdown, setCountdown] = useState(30);
|
|
|
|
|
const [newPassword, setNewPassword] = useState('');
|
2023-04-22 20:39:27 +08:00
|
|
|
const [searchParams, setSearchParams] = useSearchParams();
|
2025-06-08 01:44:38 +08:00
|
|
|
const [formApi, setFormApi] = useState(null);
|
2025-05-20 11:02:20 +08:00
|
|
|
|
|
|
|
|
const logo = getLogo();
|
|
|
|
|
const systemName = getSystemName();
|
|
|
|
|
|
2023-04-22 20:39:27 +08:00
|
|
|
useEffect(() => {
|
|
|
|
|
let token = searchParams.get('token');
|
|
|
|
|
let email = searchParams.get('email');
|
|
|
|
|
setInputs({
|
2025-06-08 01:08:03 +08:00
|
|
|
token: token || '',
|
|
|
|
|
email: email || '',
|
2023-04-22 20:39:27 +08:00
|
|
|
});
|
2025-06-08 01:44:38 +08:00
|
|
|
if (formApi) {
|
|
|
|
|
formApi.setValues({
|
|
|
|
|
email: email || '',
|
|
|
|
|
newPassword: newPassword || ''
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [searchParams, newPassword, formApi]);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
2023-07-23 13:25:28 +08:00
|
|
|
useEffect(() => {
|
|
|
|
|
let countdownInterval = null;
|
|
|
|
|
if (disableButton && countdown > 0) {
|
|
|
|
|
countdownInterval = setInterval(() => {
|
|
|
|
|
setCountdown(countdown - 1);
|
|
|
|
|
}, 1000);
|
|
|
|
|
} else if (countdown === 0) {
|
|
|
|
|
setDisableButton(false);
|
|
|
|
|
setCountdown(30);
|
|
|
|
|
}
|
2024-03-15 16:05:33 +08:00
|
|
|
return () => clearInterval(countdownInterval);
|
2023-07-23 13:25:28 +08:00
|
|
|
}, [disableButton, countdown]);
|
|
|
|
|
|
2023-04-22 20:39:27 +08:00
|
|
|
async function handleSubmit(e) {
|
2025-06-08 01:08:03 +08:00
|
|
|
if (!email || !token) {
|
|
|
|
|
showError(t('无效的重置链接,请重新发起密码重置请求'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-07-23 13:25:28 +08:00
|
|
|
setDisableButton(true);
|
2023-04-22 20:39:27 +08:00
|
|
|
setLoading(true);
|
|
|
|
|
const res = await API.post(`/api/user/reset`, {
|
|
|
|
|
email,
|
2024-03-23 21:24:39 +08:00
|
|
|
token,
|
2023-04-22 20:39:27 +08:00
|
|
|
});
|
|
|
|
|
const { success, message } = res.data;
|
|
|
|
|
if (success) {
|
|
|
|
|
let password = res.data.data;
|
2023-07-23 13:25:28 +08:00
|
|
|
setNewPassword(password);
|
2023-04-22 20:39:27 +08:00
|
|
|
await copy(password);
|
2025-06-08 02:23:47 +08:00
|
|
|
showNotice(`${t('密码已重置并已复制到剪贴板:')} ${password}`);
|
2023-04-22 20:39:27 +08:00
|
|
|
} else {
|
|
|
|
|
showError(message);
|
|
|
|
|
}
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
2024-03-15 16:05:33 +08:00
|
|
|
|
2023-04-22 20:39:27 +08:00
|
|
|
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">
|
2025-06-08 01:08:03 +08:00
|
|
|
{!isValidResetLink && (
|
2025-06-08 01:44:38 +08:00
|
|
|
<Banner
|
|
|
|
|
type="danger"
|
|
|
|
|
description={t('无效的重置链接,请重新发起密码重置请求')}
|
|
|
|
|
className="mb-4 !rounded-lg"
|
|
|
|
|
closeIcon={null}
|
|
|
|
|
/>
|
2025-06-08 01:08:03 +08:00
|
|
|
)}
|
2025-06-08 01:44:38 +08:00
|
|
|
<Form
|
|
|
|
|
getFormApi={(api) => setFormApi(api)}
|
|
|
|
|
initValues={{ email: email || '', newPassword: newPassword || '' }}
|
|
|
|
|
className="space-y-4"
|
|
|
|
|
>
|
2025-05-20 11:02:20 +08:00
|
|
|
<Form.Input
|
|
|
|
|
field="email"
|
|
|
|
|
label={t('邮箱')}
|
|
|
|
|
name="email"
|
|
|
|
|
size="large"
|
2025-06-08 01:08:03 +08:00
|
|
|
disabled={true}
|
2025-05-20 11:02:20 +08:00
|
|
|
prefix={<IconMail />}
|
2025-06-08 01:08:03 +08:00
|
|
|
placeholder={email ? '' : t('等待获取邮箱信息...')}
|
2025-05-20 11:02:20 +08:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{newPassword && (
|
|
|
|
|
<Form.Input
|
|
|
|
|
field="newPassword"
|
|
|
|
|
label={t('新密码')}
|
|
|
|
|
name="newPassword"
|
|
|
|
|
size="large"
|
2025-06-08 01:08:03 +08:00
|
|
|
disabled={true}
|
2025-05-20 11:02:20 +08:00
|
|
|
prefix={<IconLock />}
|
2025-06-08 02:23:47 +08:00
|
|
|
suffix={
|
|
|
|
|
<Button
|
|
|
|
|
icon={<IconCopy />}
|
|
|
|
|
type="tertiary"
|
|
|
|
|
theme="borderless"
|
|
|
|
|
onClick={async () => {
|
|
|
|
|
await copy(newPassword);
|
|
|
|
|
showNotice(`${t('密码已复制到剪贴板:')} ${newPassword}`);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{t('复制')}
|
|
|
|
|
</Button>
|
|
|
|
|
}
|
2025-05-20 11:02:20 +08:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<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}
|
2025-06-08 01:08:03 +08:00
|
|
|
disabled={disableButton || newPassword || !isValidResetLink}
|
2025-05-20 11:02:20 +08:00
|
|
|
>
|
2025-06-08 01:08:03 +08:00
|
|
|
{newPassword ? t('密码重置完成') : t('确认重置密码')}
|
2025-05-20 11:02:20 +08:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
|
|
<div className="mt-6 text-center text-sm">
|
|
|
|
|
<Text><Link to="/login" className="text-blue-600 hover:text-blue-800 font-medium">{t('返回登录')}</Link></Text>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-03-15 16:05:33 +08:00
|
|
|
);
|
2023-04-22 20:39:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default PasswordResetConfirm;
|