Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Sparkles } from 'lucide-react';
|
||||
|
||||
/**
|
||||
* 登录/注册/企业登录页卡片顶部的「品牌 Logo + 标题 + 副标题」头部。
|
||||
*
|
||||
* 这一段(Logo 光环 + 白底圆角 + 右上角 Sparkles + h4 标题 + p 副标题)原本在
|
||||
* LoginForm / RegisterForm / OrgLogin 中重复了 5 份,抽到这里统一维护,避免日后样式漂移。
|
||||
*
|
||||
* - logoNode:自定义 Logo 节点(如企业 Avatar);不传则用 logo(src) 渲染平台 <img>。
|
||||
* - wrapperClassName / logoWrapperClassName:保留各页面原有的间距微调(mb-*)。
|
||||
* - Sparkles 统一用 motion-safe:animate-pulse,遵循 prefers-reduced-motion。
|
||||
*/
|
||||
const AuthCardHeader = ({
|
||||
title,
|
||||
subtitle,
|
||||
logo,
|
||||
logoNode,
|
||||
wrapperClassName = 'mb-5',
|
||||
logoWrapperClassName = 'mb-3',
|
||||
}) => (
|
||||
<div
|
||||
className={`flex flex-col items-center justify-center ${wrapperClassName}`}
|
||||
>
|
||||
<div className={`relative ${logoWrapperClassName}`}>
|
||||
{/* Logo 光环 */}
|
||||
<div className='absolute -inset-1.5 bg-gradient-to-r from-brand-from/30 to-brand-to/30 rounded-xl blur-md opacity-60' />
|
||||
<div className='relative p-2 bg-white dark:bg-neutral-800 rounded-xl shadow-md'>
|
||||
{logoNode || (
|
||||
<img
|
||||
src={logo}
|
||||
alt='Logo'
|
||||
className='h-10 w-10 rounded-lg object-cover'
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<Sparkles
|
||||
size={14}
|
||||
className='absolute -top-0.5 -right-0.5 text-amber-400 motion-safe:animate-pulse'
|
||||
/>
|
||||
</div>
|
||||
<h4 className='text-xl font-bold text-gray-800 dark:text-white tracking-tight mb-0.5'>
|
||||
{title}
|
||||
</h4>
|
||||
<p className='text-gray-500 dark:text-gray-400 text-xs'>{subtitle}</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default AuthCardHeader;
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Avatar } from '@douyinfe/semi-ui';
|
||||
import { MessageCircle, ScanLine } from 'lucide-react';
|
||||
import { API } from '../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
/**
|
||||
* 登录/注册页面的客服浮窗
|
||||
* 右上角固定展示客服二维码,始终可见
|
||||
*/
|
||||
const AuthCustomerServiceFloat = () => {
|
||||
const { t } = useTranslation();
|
||||
const [agent, setAgent] = useState(null);
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [qrcodeError, setQrcodeError] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAgent = async () => {
|
||||
try {
|
||||
const configRes = await API.get('/api/customer-service/config');
|
||||
if (!configRes.data.success || !configRes.data.data?.enabled) return;
|
||||
|
||||
const agentRes = await API.get('/api/customer-service/display');
|
||||
if (agentRes.data.success && agentRes.data.data) {
|
||||
const data = agentRes.data.data;
|
||||
if (data.qrcode_url || data.wecom_url) {
|
||||
setAgent(data);
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// 静默处理,不影响登录页
|
||||
}
|
||||
};
|
||||
fetchAgent();
|
||||
}, []);
|
||||
|
||||
if (!visible || !agent) return null;
|
||||
|
||||
const hasQrcode = agent.qrcode_url && !qrcodeError;
|
||||
|
||||
return (
|
||||
<div className='fixed top-28 right-5 z-[200] w-52'>
|
||||
<style>{`
|
||||
.auth-cs-glass-card {
|
||||
box-shadow:
|
||||
0 20px 45px -15px rgba(15, 42, 80, 0.25),
|
||||
0 8px 20px -8px rgb(var(--brand-primary-rgb) / 0.18),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.7),
|
||||
inset 0 -1px 0 rgba(255, 255, 255, 0.18);
|
||||
}
|
||||
.dark .auth-cs-glass-card {
|
||||
box-shadow:
|
||||
0 20px 45px -15px rgba(0, 0, 0, 0.6),
|
||||
0 10px 24px -8px rgb(var(--brand-primary-rgb) / 0.22),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.1),
|
||||
inset 0 -1px 0 rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
.auth-cs-aurora {
|
||||
top: -30%;
|
||||
left: -20%;
|
||||
width: 90%;
|
||||
height: 90%;
|
||||
background: radial-gradient(ellipse at center, rgb(var(--brand-primary-rgb) / 0.18) 0%, transparent 70%);
|
||||
animation: authCsAurora 18s ease-in-out infinite;
|
||||
}
|
||||
.dark .auth-cs-aurora {
|
||||
background: radial-gradient(ellipse at center, rgb(var(--brand-primary-rgb) / 0.22) 0%, transparent 70%);
|
||||
}
|
||||
@keyframes authCsAurora {
|
||||
0%, 100% { transform: translate(0%, 0%); }
|
||||
50% { transform: translate(20%, 18%); }
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.auth-cs-glass-card {
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.auth-cs-aurora,
|
||||
.auth-cs-glass-card { animation: none; transition: none; }
|
||||
}
|
||||
`}</style>
|
||||
{/* 外层柔光晕 - 增强浮空立体感 */}
|
||||
<div className='absolute -inset-3 bg-gradient-to-br from-brand-from/15 via-brand-via/10 to-brand-to/15 rounded-3xl blur-xl opacity-80 pointer-events-none' />
|
||||
|
||||
{/* 展示面板 - 玻璃拟态立体效果 */}
|
||||
<div
|
||||
className='
|
||||
auth-cs-glass-card relative isolate
|
||||
backdrop-blur-2xl rounded-xl overflow-hidden
|
||||
ring-1 ring-white/50 dark:ring-white/[0.06]
|
||||
border border-white/30 dark:border-white/[0.05]
|
||||
bg-white/55 dark:bg-neutral-900/55
|
||||
transition-[transform,box-shadow] duration-500 ease-out
|
||||
hover:scale-[1.01]
|
||||
'
|
||||
>
|
||||
{/* 内层 aurora - 缓慢漂移品牌色辉光 */}
|
||||
<div className='auth-cs-aurora absolute -z-10 pointer-events-none' />
|
||||
|
||||
{/* 顶部渐变装饰线 */}
|
||||
<div className='h-0.5 bg-gradient-to-r from-brand-from via-brand-via to-brand-to' />
|
||||
|
||||
{/* 顶部高光反射 - 位于装饰线下方,模拟玻璃反光 */}
|
||||
<div className='absolute top-0.5 left-[15%] right-[15%] h-px bg-gradient-to-r from-transparent via-white/90 dark:via-white/40 to-transparent pointer-events-none' />
|
||||
|
||||
<div className='p-3'>
|
||||
{/* 客服信息 */}
|
||||
<div className='flex items-center gap-2 mb-2.5'>
|
||||
{agent.avatar ? (
|
||||
<Avatar
|
||||
src={agent.avatar}
|
||||
size='extra-small'
|
||||
className='!w-7 !h-7 flex-shrink-0'
|
||||
/>
|
||||
) : (
|
||||
<div className='w-7 h-7 rounded-full bg-gradient-to-br from-brand-from to-brand-to flex items-center justify-center flex-shrink-0'>
|
||||
<MessageCircle size={13} className='text-white' />
|
||||
</div>
|
||||
)}
|
||||
<div className='flex-1 min-w-0'>
|
||||
<div className='flex items-center gap-1'>
|
||||
<span className='text-xs font-semibold text-gray-800 dark:text-white truncate'>
|
||||
{agent.name || t('在线客服')}
|
||||
</span>
|
||||
<span className='inline-flex items-center gap-0.5 px-1 py-px bg-emerald-50 dark:bg-emerald-900/30 rounded-full flex-shrink-0'>
|
||||
<span className='w-1 h-1 bg-emerald-500 rounded-full animate-pulse' />
|
||||
<span className='text-[9px] text-emerald-600 dark:text-emerald-400 font-medium'>
|
||||
{t('在线')}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 提示文案 */}
|
||||
<p className='text-[11px] text-gray-500 dark:text-gray-400 mb-2.5 leading-relaxed'>
|
||||
{t('登录遇到问题?扫码咨询客服解决')}
|
||||
</p>
|
||||
|
||||
{/* 二维码 - 始终展示 */}
|
||||
{hasQrcode ? (
|
||||
<div className='flex flex-col items-center'>
|
||||
<div className='w-full p-2 bg-white dark:bg-neutral-800/60 rounded-lg border border-gray-100 dark:border-neutral-700/50'>
|
||||
<img
|
||||
src={agent.qrcode_url}
|
||||
alt={t('客服二维码')}
|
||||
className='w-full aspect-square object-contain rounded'
|
||||
onError={() => setQrcodeError(true)}
|
||||
/>
|
||||
</div>
|
||||
<div className='mt-2 flex items-center gap-1 text-[10px] text-brand-deep dark:text-brand-from font-medium'>
|
||||
<ScanLine size={10} />
|
||||
<span>{t('微信扫码添加客服')}</span>
|
||||
</div>
|
||||
</div>
|
||||
) : agent.wecom_url ? (
|
||||
<button
|
||||
onClick={() => window.open(agent.wecom_url, '_blank')}
|
||||
className='w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-gradient-to-r from-brand-from to-brand-to hover:from-brand-from hover:to-brand-to text-white text-xs font-medium rounded-lg transition-colors'
|
||||
>
|
||||
<MessageCircle size={12} />
|
||||
{t('联系客服')}
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AuthCustomerServiceFloat;
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
/**
|
||||
* 认证页「个人 / 企业」分段切换控件(登录与注册两种模式)。
|
||||
* 跨页跳转:mode='login' 在 /login 与 /org/login 间切换;
|
||||
* mode='register' 在 /register 与 /org/register 间切换。四页共用,保持对称的信息架构。
|
||||
* active:当前页归属('personal' | 'enterprise'),高亮且不重复跳转。
|
||||
*
|
||||
* 浮于玻璃卡片之外、之上:自带玻璃壳(backdrop-blur + 半透白底 + ring/border),
|
||||
* 在背景上保持可读并与下方卡片呼应;激活态用品牌渐变强化「当前入口」的辨识度。
|
||||
*/
|
||||
const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
// 企业入口置于左侧首位:本产品主推企业用户,企业登录/注册是默认入口
|
||||
const tabs =
|
||||
mode === 'register'
|
||||
? [
|
||||
{ key: 'enterprise', label: t('企业注册'), to: '/org/register' },
|
||||
{ key: 'personal', label: t('个人注册'), to: '/register' },
|
||||
]
|
||||
: [
|
||||
{ key: 'enterprise', label: t('企业登录'), to: '/org/login' },
|
||||
{ key: 'personal', label: t('个人登录'), to: '/login' },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='relative z-20 flex p-1 gap-1 rounded-2xl backdrop-blur-2xl bg-white/45 dark:bg-neutral-900/55 ring-1 ring-white/50 dark:ring-white/[0.06] border border-white/30 dark:border-white/[0.05] shadow-[0_12px_32px_-16px_rgb(var(--brand-primary-rgb)/0.45)]'>
|
||||
{tabs.map((tab) => {
|
||||
const isActive = tab.key === active;
|
||||
return (
|
||||
<button
|
||||
key={tab.key}
|
||||
type='button'
|
||||
aria-pressed={isActive}
|
||||
onClick={() => {
|
||||
if (!isActive) navigate(tab.to);
|
||||
}}
|
||||
className={`flex-1 h-10 rounded-xl text-sm font-medium transition-all duration-200 ${
|
||||
isActive
|
||||
? 'bg-gradient-to-r from-brand-from to-brand-to text-white shadow-md shadow-brand/25'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-white/40 dark:hover:bg-white/[0.05]'
|
||||
}`}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AuthLoginTabs;
|
||||
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
/**
|
||||
* 玻璃卡片所需的动画与阴影样式(浮动 / 角落脉动 / aurora / 多层阴影)。
|
||||
* 内置于 GlassCard,任何使用本卡片的页面(登录、注册、企业登录…)都会自动获得,
|
||||
* 无需各自再注入一份 <style>。类名全局唯一,多处渲染重复定义亦无副作用。
|
||||
*/
|
||||
export const GlassCardStyles = () => (
|
||||
<style>{`
|
||||
@keyframes loginHaloPulse {
|
||||
0%, 100% { opacity: 0.55; transform: scale(1); }
|
||||
50% { opacity: 0.9; transform: scale(1.08); }
|
||||
}
|
||||
@keyframes loginCardFloat {
|
||||
0%, 100% { transform: translateY(0); }
|
||||
50% { transform: translateY(-4px); }
|
||||
}
|
||||
@keyframes loginAurora {
|
||||
0%, 100% { transform: translate(0%, 0%); }
|
||||
50% { transform: translate(18%, 12%); }
|
||||
}
|
||||
.login-card-float { animation: loginCardFloat 7s ease-in-out infinite; will-change: transform; }
|
||||
.login-halo-pulse { animation: loginHaloPulse 6s ease-in-out infinite; }
|
||||
.login-halo-pulse-delayed { animation: loginHaloPulse 6s ease-in-out infinite; animation-delay: 3s; }
|
||||
.login-glass-aurora {
|
||||
top: -25%;
|
||||
left: -15%;
|
||||
width: 80%;
|
||||
height: 85%;
|
||||
background: radial-gradient(ellipse at center, rgb(var(--brand-primary-rgb) / 0.16) 0%, transparent 70%);
|
||||
animation: loginAurora 22s ease-in-out infinite;
|
||||
}
|
||||
.dark .login-glass-aurora {
|
||||
background: radial-gradient(ellipse at center, rgb(var(--brand-primary-rgb) / 0.22) 0%, transparent 70%);
|
||||
}
|
||||
.login-glass-card {
|
||||
box-shadow:
|
||||
0 30px 70px -20px rgba(15, 42, 80, 0.28),
|
||||
0 12px 28px -10px rgb(var(--brand-primary-rgb) / 0.20),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.65),
|
||||
inset 0 -1px 0 rgba(255, 255, 255, 0.18);
|
||||
}
|
||||
.dark .login-glass-card {
|
||||
box-shadow:
|
||||
0 30px 70px -18px rgba(0, 0, 0, 0.65),
|
||||
0 14px 32px -10px rgb(var(--brand-primary-rgb) / 0.25),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.12),
|
||||
inset 0 -1px 0 rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
/* 卡片 hover 与内部按钮 hover 联动时,避免抖动 */
|
||||
.login-glass-card:hover { box-shadow:
|
||||
0 36px 80px -18px rgba(15, 42, 80, 0.32),
|
||||
0 14px 32px -10px rgb(var(--brand-primary-rgb) / 0.26),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.7),
|
||||
inset 0 -1px 0 rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
.dark .login-glass-card:hover { box-shadow:
|
||||
0 36px 80px -16px rgba(0, 0, 0, 0.7),
|
||||
0 16px 36px -10px rgb(var(--brand-primary-rgb) / 0.3),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.14),
|
||||
inset 0 -1px 0 rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
/* 认证页 Semi 输入框玻璃风格:容器挂 .auth-glass-form 后,四个认证页
|
||||
(登录/注册/企业登录/企业注册)的输入框共享同一套观感 ——
|
||||
半透白玻璃底 + 圆角、hover 提亮、聚焦品牌色边框 + 柔和光环、错误态沿用语义色 */
|
||||
.auth-glass-form .semi-input-wrapper {
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
border: 1px solid rgba(229, 231, 235, 0.8);
|
||||
border-radius: 0.75rem;
|
||||
backdrop-filter: blur(4px);
|
||||
-webkit-backdrop-filter: blur(4px);
|
||||
transition:
|
||||
border-color 0.2s ease,
|
||||
background-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
.auth-glass-form .semi-input-wrapper:hover {
|
||||
background: rgba(255, 255, 255, 0.78);
|
||||
border-color: rgba(209, 213, 219, 1);
|
||||
}
|
||||
.auth-glass-form .semi-input-wrapper-focus,
|
||||
.auth-glass-form .semi-input-wrapper-focus:hover {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border-color: rgb(var(--brand-primary-rgb));
|
||||
box-shadow: 0 0 0 3px rgb(var(--brand-primary-rgb) / 0.14);
|
||||
}
|
||||
.dark .auth-glass-form .semi-input-wrapper {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border-color: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
.dark .auth-glass-form .semi-input-wrapper:hover {
|
||||
background: rgba(255, 255, 255, 0.09);
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
.dark .auth-glass-form .semi-input-wrapper-focus,
|
||||
.dark .auth-glass-form .semi-input-wrapper-focus:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-color: rgb(var(--brand-primary-rgb));
|
||||
box-shadow: 0 0 0 3px rgb(var(--brand-primary-rgb) / 0.22);
|
||||
}
|
||||
/* 校验失败:边框与光环改用语义 danger 色,保持玻璃底不变 */
|
||||
.auth-glass-form .semi-input-wrapper-error,
|
||||
.auth-glass-form .semi-input-wrapper-error:hover,
|
||||
.auth-glass-form .semi-input-wrapper-error.semi-input-wrapper-focus {
|
||||
border-color: var(--semi-color-danger);
|
||||
box-shadow: none;
|
||||
}
|
||||
/* 前缀图标与内建功能钮(密码眼睛/清除)默认弱化;
|
||||
只针对这三处染色,避免误染 suffix 里自定义按钮(如「获取验证码」)的 loading 图标 */
|
||||
.auth-glass-form .semi-input-wrapper .semi-input-prefix .semi-icon,
|
||||
.auth-glass-form .semi-input-wrapper .semi-input-clearbtn .semi-icon,
|
||||
.auth-glass-form .semi-input-wrapper .semi-input-modebtn .semi-icon {
|
||||
color: rgba(156, 163, 175, 1);
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
.dark .auth-glass-form .semi-input-wrapper .semi-input-prefix .semi-icon,
|
||||
.dark .auth-glass-form .semi-input-wrapper .semi-input-clearbtn .semi-icon,
|
||||
.dark .auth-glass-form .semi-input-wrapper .semi-input-modebtn .semi-icon {
|
||||
color: rgba(107, 114, 128, 1);
|
||||
}
|
||||
/* 密码眼睛/清除按钮 hover 加深,给出可点击反馈 */
|
||||
.auth-glass-form .semi-input-wrapper .semi-input-clearbtn:hover .semi-icon,
|
||||
.auth-glass-form .semi-input-wrapper .semi-input-modebtn:hover .semi-icon {
|
||||
color: rgba(75, 85, 99, 1);
|
||||
}
|
||||
.dark .auth-glass-form .semi-input-wrapper .semi-input-clearbtn:hover .semi-icon,
|
||||
.dark .auth-glass-form .semi-input-wrapper .semi-input-modebtn:hover .semi-icon {
|
||||
color: rgba(209, 213, 219, 1);
|
||||
}
|
||||
/* 聚焦时前缀图标点亮为品牌色,给出清晰的焦点反馈 */
|
||||
.auth-glass-form .semi-input-wrapper-focus .semi-input-prefix .semi-icon {
|
||||
color: rgb(var(--brand-primary-rgb));
|
||||
}
|
||||
.dark .auth-glass-form .semi-input::placeholder {
|
||||
color: rgba(255, 255, 255, 0.35);
|
||||
}
|
||||
/* 移动端降级 backdrop-filter,减轻 GPU 负担 */
|
||||
@media (max-width: 640px) {
|
||||
.login-glass-card {
|
||||
backdrop-filter: blur(24px);
|
||||
-webkit-backdrop-filter: blur(24px);
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.login-card-float,
|
||||
.login-halo-pulse,
|
||||
.login-halo-pulse-delayed,
|
||||
.login-glass-aurora { animation: none; }
|
||||
.login-glass-card { transition: none; }
|
||||
}
|
||||
`}</style>
|
||||
);
|
||||
|
||||
/**
|
||||
* 登录/注册页通用的玻璃拟态卡片壳
|
||||
*
|
||||
* 视觉层(由后到前):
|
||||
* 1. 外环柔光晕(品牌渐变 + 模糊)
|
||||
* 2. 左上 / 右下角脉动光晕(可选,withCornerHalos)
|
||||
* 3. 内层 aurora(缓慢漂移的品牌色径向辉光)
|
||||
* 4. 卡片主体(高透白 + 强 backdrop-blur + ring/border 双层玻璃边)
|
||||
* 5. 顶部品牌渐变线 + 1px 白色反光(玻璃顶面反光)
|
||||
* 6. 用户传入的 children
|
||||
*
|
||||
* 交互:
|
||||
* - 整卡浮动动画(translateY,7s 缓慢呼吸)
|
||||
* - 角落光晕轻微缩放脉动(6s)
|
||||
* - 卡片 hover 微抬升(scale 1.008,500ms 缓动)
|
||||
*
|
||||
* 性能:
|
||||
* - 移动端自动降级 backdrop-filter 模糊半径(@media (max-width: 640px))
|
||||
* - aurora 单层 GPU 合成
|
||||
* - 全部动画在 prefers-reduced-motion 下关闭
|
||||
* - 阴影、aurora 颜色均使用 var(--brand-primary-rgb),跟随主题预设
|
||||
*/
|
||||
const GlassCard = ({
|
||||
children,
|
||||
withCornerHalos = true,
|
||||
withAurora = true,
|
||||
className = '',
|
||||
}) => {
|
||||
return (
|
||||
<div className={`w-full max-w-sm relative login-card-float ${className}`}>
|
||||
<GlassCardStyles />
|
||||
{/* 外环柔光晕 */}
|
||||
<div className='absolute -inset-6 bg-gradient-to-br from-brand-from/15 via-brand-via/10 to-brand-to/15 rounded-[2rem] blur-2xl opacity-80 pointer-events-none' />
|
||||
|
||||
{/* 左上 / 右下脉动光晕 */}
|
||||
{withCornerHalos && (
|
||||
<>
|
||||
<div className='absolute -top-20 -left-20 w-44 h-44 bg-brand-from/25 dark:bg-brand-from/20 rounded-full blur-3xl pointer-events-none login-halo-pulse' />
|
||||
<div className='absolute -bottom-20 -right-20 w-44 h-44 bg-brand-to/25 dark:bg-brand-to/15 rounded-full blur-3xl pointer-events-none login-halo-pulse-delayed' />
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 卡片主体 */}
|
||||
<div className='login-glass-card relative isolate backdrop-blur-2xl bg-white/45 dark:bg-neutral-900/55 rounded-2xl ring-1 ring-white/50 dark:ring-white/[0.06] border border-white/30 dark:border-white/[0.05] px-6 py-5 overflow-hidden transition-[transform,box-shadow] duration-500 ease-out hover:scale-[1.008]'>
|
||||
{/* 内层 aurora - 缓慢漂移,z-index 负值避免遮挡内容 */}
|
||||
{withAurora && (
|
||||
<div className='login-glass-aurora absolute -z-10 pointer-events-none' />
|
||||
)}
|
||||
|
||||
{/* 顶部品牌渐变线 */}
|
||||
<div className='absolute top-0 left-0 right-0 h-0.5 bg-gradient-to-r from-brand-from via-brand-via to-brand-to opacity-90' />
|
||||
|
||||
{/* 顶部 1px 白色反光 - 紧贴品牌线下方 */}
|
||||
<div className='absolute top-0.5 left-[15%] right-[15%] h-px bg-gradient-to-r from-transparent via-white/90 dark:via-white/40 to-transparent pointer-events-none' />
|
||||
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default GlassCard;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
API,
|
||||
showError,
|
||||
showSuccess,
|
||||
updateAPI,
|
||||
clearUserData,
|
||||
finishLogin as runLoginFlow,
|
||||
} from '../../helpers';
|
||||
import { UserContext } from '../../context/User';
|
||||
import Loading from '../common/ui/Loading';
|
||||
|
||||
const OAuth2Callback = (props) => {
|
||||
const { t } = useTranslation();
|
||||
const [searchParams] = useSearchParams();
|
||||
const [, userDispatch] = useContext(UserContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
// 最大重试次数
|
||||
const MAX_RETRIES = 3;
|
||||
|
||||
const sendCode = async (code, state, retry = 0) => {
|
||||
try {
|
||||
const { data: resData } = await API.get(
|
||||
`/api/oauth/${props.type}?code=${code}&state=${state}`,
|
||||
);
|
||||
|
||||
const { success, message, data } = resData;
|
||||
|
||||
if (!success) {
|
||||
throw new Error(message || 'OAuth2 callback error');
|
||||
}
|
||||
|
||||
if (message === 'bind') {
|
||||
showSuccess(t('绑定成功!'));
|
||||
navigate('/console/personal');
|
||||
return;
|
||||
}
|
||||
|
||||
// OAuth code is single-use; if finishLogin reports the session cookie
|
||||
// wasn't persisted, retrying the same code can't fix it — fall through
|
||||
// to the login page (finishLogin already surfaced the error toast).
|
||||
const loggedIn = await runLoginFlow({
|
||||
data,
|
||||
userDispatch,
|
||||
navigate,
|
||||
t,
|
||||
});
|
||||
if (!loggedIn) {
|
||||
navigate('/login');
|
||||
}
|
||||
} catch (error) {
|
||||
if (retry < MAX_RETRIES) {
|
||||
// 递增的退避等待
|
||||
await new Promise((resolve) => setTimeout(resolve, (retry + 1) * 2000));
|
||||
return sendCode(code, state, retry + 1);
|
||||
}
|
||||
|
||||
// 重试次数耗尽,提示错误并返回登录页面
|
||||
clearUserData();
|
||||
updateAPI();
|
||||
showError(error.message || t('授权失败'));
|
||||
navigate('/login');
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const code = searchParams.get('code');
|
||||
const state = searchParams.get('state');
|
||||
|
||||
// 参数缺失直接返回
|
||||
if (!code) {
|
||||
showError(t('未获取到授权码'));
|
||||
navigate('/console/personal');
|
||||
return;
|
||||
}
|
||||
|
||||
sendCode(code, state);
|
||||
}, []);
|
||||
|
||||
return <Loading />;
|
||||
};
|
||||
|
||||
export default OAuth2Callback;
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Toast, Banner } from '@douyinfe/semi-ui';
|
||||
import { Copy } from 'lucide-react';
|
||||
|
||||
/**
|
||||
* 企业建号一次性凭证展示面板(注册自助建号 / 管理员建号复用)。
|
||||
* props:
|
||||
* creds: { status?, org_code, org_name, owner_login_name, initial_password }
|
||||
* onLogin?: () => void 存在时展示「立即登录」按钮
|
||||
*/
|
||||
const OrgCredentialResult = ({ creds, onLogin }) => {
|
||||
const { t } = useTranslation();
|
||||
if (!creds) return null;
|
||||
|
||||
const isPending = creds.status === 'pending';
|
||||
|
||||
const copy = (val) => {
|
||||
navigator.clipboard
|
||||
.writeText(val)
|
||||
.then(() => Toast.success(t('已复制到剪贴板')))
|
||||
.catch(() => Toast.error(t('复制失败,请手动复制')));
|
||||
};
|
||||
|
||||
// 四项凭证拼成带标签的文本块一次复制,避免逐项复制的遗漏(如只记了密码没记企业代码)
|
||||
const copyAll = () => {
|
||||
copy(
|
||||
[
|
||||
`${t('企业代码')}: ${creds.org_code}`,
|
||||
`${t('企业名称')}: ${creds.org_name}`,
|
||||
`${t('登录名')}: ${creds.owner_login_name}`,
|
||||
`${t('初始密码')}: ${creds.initial_password}`,
|
||||
].join('\n'),
|
||||
);
|
||||
};
|
||||
|
||||
const Row = ({ label, value, mono }) => (
|
||||
<div className='flex items-center justify-between gap-2 py-2 border-b border-gray-100 dark:border-white/[0.06] last:border-0'>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 shrink-0'>
|
||||
{label}
|
||||
</span>
|
||||
<div className='flex items-center gap-1.5 min-w-0'>
|
||||
<span
|
||||
className={`truncate text-sm text-gray-800 dark:text-gray-100 ${mono ? 'font-mono' : ''}`}
|
||||
>
|
||||
{value}
|
||||
</span>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<Copy size={14} />}
|
||||
onClick={() => copy(value)}
|
||||
aria-label={t('复制')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='flex flex-col gap-3'>
|
||||
<Banner
|
||||
type={isPending ? 'info' : 'warning'}
|
||||
closeIcon={null}
|
||||
description={
|
||||
isPending
|
||||
? t(
|
||||
'企业已提交,待平台审核通过后即可用以下凭证登录。请立即保存初始密码,此信息仅显示一次。',
|
||||
)
|
||||
: t(
|
||||
'请立即保存以下凭证并交付管理员。初始密码仅显示一次,关闭后无法再次查看。',
|
||||
)
|
||||
}
|
||||
/>
|
||||
<div className='rounded-xl border border-gray-200/80 dark:border-white/[0.1] bg-white/60 dark:bg-white/[0.04] px-4'>
|
||||
<Row label={t('企业代码')} value={creds.org_code} mono />
|
||||
<Row label={t('企业名称')} value={creds.org_name} />
|
||||
<Row label={t('登录名')} value={creds.owner_login_name} mono />
|
||||
<Row label={t('初始密码')} value={creds.initial_password} mono />
|
||||
</div>
|
||||
<Button
|
||||
size='large'
|
||||
block
|
||||
icon={<Copy size={14} />}
|
||||
onClick={copyAll}
|
||||
>
|
||||
{t('复制全部凭证')}
|
||||
</Button>
|
||||
{onLogin && (
|
||||
<Button
|
||||
theme='solid'
|
||||
size='large'
|
||||
block
|
||||
onClick={onLogin}
|
||||
disabled={isPending}
|
||||
>
|
||||
{isPending ? t('待审核通过后可登录') : t('立即登录')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OrgCredentialResult;
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
API,
|
||||
copy,
|
||||
showError,
|
||||
showNotice,
|
||||
getLogo,
|
||||
getSystemName,
|
||||
} from '../../helpers';
|
||||
import { useSearchParams, Link } from 'react-router-dom';
|
||||
import { Button, Card, Form, Typography, Banner } from '@douyinfe/semi-ui';
|
||||
import { IconMail, IconLock, IconCopy } from '@douyinfe/semi-icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
const PasswordResetConfirm = () => {
|
||||
const { t } = useTranslation();
|
||||
const [inputs, setInputs] = useState({
|
||||
email: '',
|
||||
token: '',
|
||||
});
|
||||
const { email, token } = inputs;
|
||||
const isValidResetLink = email && token;
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [disableButton, setDisableButton] = useState(false);
|
||||
const [countdown, setCountdown] = useState(30);
|
||||
const [newPassword, setNewPassword] = useState('');
|
||||
const [searchParams] = useSearchParams();
|
||||
const [formApi, setFormApi] = useState(null);
|
||||
|
||||
const logo = getLogo();
|
||||
const systemName = getSystemName();
|
||||
|
||||
useEffect(() => {
|
||||
let token = searchParams.get('token');
|
||||
let email = searchParams.get('email');
|
||||
setInputs({
|
||||
token: token || '',
|
||||
email: email || '',
|
||||
});
|
||||
if (formApi) {
|
||||
formApi.setValues({
|
||||
email: email || '',
|
||||
newPassword: newPassword || '',
|
||||
});
|
||||
}
|
||||
}, [searchParams, newPassword, formApi]);
|
||||
|
||||
useEffect(() => {
|
||||
let countdownInterval = null;
|
||||
if (disableButton && countdown > 0) {
|
||||
countdownInterval = setInterval(() => {
|
||||
setCountdown(countdown - 1);
|
||||
}, 1000);
|
||||
} else if (countdown === 0) {
|
||||
setDisableButton(false);
|
||||
setCountdown(30);
|
||||
}
|
||||
return () => clearInterval(countdownInterval);
|
||||
}, [disableButton, countdown]);
|
||||
|
||||
async function handleSubmit(e) {
|
||||
if (!email || !token) {
|
||||
showError(t('无效的重置链接,请重新发起密码重置请求'));
|
||||
return;
|
||||
}
|
||||
setDisableButton(true);
|
||||
setLoading(true);
|
||||
const res = await API.post(`/api/user/reset`, {
|
||||
email,
|
||||
token,
|
||||
});
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
let password = res.data.data;
|
||||
setNewPassword(password);
|
||||
await copy(password);
|
||||
showNotice(`${t('密码已重置并已复制到剪贴板:')} ${password}`);
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
return (
|
||||
<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' }}
|
||||
/>
|
||||
<div className='w-full max-w-sm mt-[60px]'>
|
||||
<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' />
|
||||
<Title heading={3} className='!text-gray-800'>
|
||||
{systemName}
|
||||
</Title>
|
||||
</div>
|
||||
|
||||
<Card className='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'>
|
||||
{!isValidResetLink && (
|
||||
<Banner
|
||||
type='danger'
|
||||
description={t('无效的重置链接,请重新发起密码重置请求')}
|
||||
className='mb-4 !rounded-lg'
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
<Form
|
||||
getFormApi={(api) => setFormApi(api)}
|
||||
initValues={{
|
||||
email: email || '',
|
||||
newPassword: newPassword || '',
|
||||
}}
|
||||
className='space-y-4'
|
||||
>
|
||||
<Form.Input
|
||||
field='email'
|
||||
label={t('邮箱')}
|
||||
name='email'
|
||||
disabled={true}
|
||||
prefix={<IconMail />}
|
||||
placeholder={email ? '' : t('等待获取邮箱信息...')}
|
||||
/>
|
||||
|
||||
{newPassword && (
|
||||
<Form.Input
|
||||
field='newPassword'
|
||||
label={t('新密码')}
|
||||
name='newPassword'
|
||||
disabled={true}
|
||||
prefix={<IconLock />}
|
||||
suffix={
|
||||
<Button
|
||||
icon={<IconCopy />}
|
||||
type='tertiary'
|
||||
theme='borderless'
|
||||
onClick={async () => {
|
||||
await copy(newPassword);
|
||||
showNotice(`${t('密码已复制到剪贴板:')} ${newPassword}`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<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 || newPassword || !isValidResetLink
|
||||
}
|
||||
>
|
||||
{newPassword ? t('密码重置完成') : t('确认重置密码')}
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
|
||||
<div className='mt-6 text-center text-sm'>
|
||||
<Text>
|
||||
<Link
|
||||
to='/login'
|
||||
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-medium transition-colors'
|
||||
>
|
||||
{t('返回登录')}
|
||||
</Link>
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PasswordResetConfirm;
|
||||
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
API,
|
||||
getLogo,
|
||||
showError,
|
||||
showInfo,
|
||||
showSuccess,
|
||||
getSystemName,
|
||||
} from '../../helpers';
|
||||
import Turnstile from 'react-turnstile';
|
||||
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;
|
||||
|
||||
const PasswordResetForm = () => {
|
||||
const { t } = useTranslation();
|
||||
const [inputs, setInputs] = useState({
|
||||
email: '',
|
||||
});
|
||||
const { email } = inputs;
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [turnstileEnabled, setTurnstileEnabled] = useState(false);
|
||||
const [turnstileSiteKey, setTurnstileSiteKey] = useState('');
|
||||
const [turnstileToken, setTurnstileToken] = useState('');
|
||||
const [disableButton, setDisableButton] = useState(false);
|
||||
const [countdown, setCountdown] = useState(30);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
let countdownInterval = null;
|
||||
if (disableButton && countdown > 0) {
|
||||
countdownInterval = setInterval(() => {
|
||||
setCountdown(countdown - 1);
|
||||
}, 1000);
|
||||
} else if (countdown === 0) {
|
||||
setDisableButton(false);
|
||||
setCountdown(30);
|
||||
}
|
||||
return () => clearInterval(countdownInterval);
|
||||
}, [disableButton, countdown]);
|
||||
|
||||
function handleChange(value) {
|
||||
setInputs((inputs) => ({ ...inputs, email: value }));
|
||||
}
|
||||
|
||||
async function handleSubmit(e) {
|
||||
if (!email) {
|
||||
showError(t('请输入邮箱地址'));
|
||||
return;
|
||||
}
|
||||
if (turnstileEnabled && turnstileToken === '') {
|
||||
showInfo(t('请稍后几秒重试,Turnstile 正在检查用户环境!'));
|
||||
return;
|
||||
}
|
||||
setDisableButton(true);
|
||||
setLoading(true);
|
||||
const res = await API.get(
|
||||
`/api/reset_password?email=${encodeURIComponent(email)}&turnstile=${turnstileToken}`,
|
||||
);
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
showSuccess(t('重置邮件发送成功,请检查邮箱!'));
|
||||
setInputs({ ...inputs, email: '' });
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
return (
|
||||
<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' }}
|
||||
/>
|
||||
<div className='w-full max-w-sm mt-[60px]'>
|
||||
<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' />
|
||||
<Title heading={3} className='!text-gray-800'>
|
||||
{systemName}
|
||||
</Title>
|
||||
</div>
|
||||
|
||||
<Card className='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'
|
||||
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-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-medium transition-colors'
|
||||
>
|
||||
{t('登录')}
|
||||
</Link>
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{turnstileEnabled && (
|
||||
<div className='flex justify-center mt-6'>
|
||||
<Turnstile
|
||||
sitekey={turnstileSiteKey}
|
||||
onVerify={(token) => {
|
||||
setTurnstileToken(token);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PasswordResetForm;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
import React from 'react';
|
||||
import TelegramLoginButton from 'react-telegram-login';
|
||||
|
||||
const TelegramLogin = ({ botName, onAuth }) => {
|
||||
return (
|
||||
<div className='flex justify-center my-2'>
|
||||
<TelegramLoginButton dataOnauth={onAuth} botName={botName} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TelegramLogin;
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
import { API, showError, showSuccess } from '../../helpers';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Divider,
|
||||
Form,
|
||||
Typography,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { Title, Text, Paragraph } = Typography;
|
||||
|
||||
const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [useBackupCode, setUseBackupCode] = useState(false);
|
||||
const [verificationCode, setVerificationCode] = useState('');
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!verificationCode) {
|
||||
showError(t('请输入验证码'));
|
||||
return;
|
||||
}
|
||||
// Validate code format
|
||||
if (useBackupCode && verificationCode.length !== 8) {
|
||||
showError(t('备用码必须是8位'));
|
||||
return;
|
||||
} else if (!useBackupCode && !/^\d{6}$/.test(verificationCode)) {
|
||||
showError(t('验证码必须是6位数字'));
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await API.post('/api/user/login/2fa', {
|
||||
code: verificationCode,
|
||||
});
|
||||
|
||||
if (res.data.success) {
|
||||
showSuccess(t('登录成功'));
|
||||
if (onSuccess) {
|
||||
onSuccess(res.data.data);
|
||||
}
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
showError(t('验证失败,请重试'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyPress = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
handleSubmit();
|
||||
}
|
||||
};
|
||||
|
||||
if (isModal) {
|
||||
return (
|
||||
<div className='space-y-4'>
|
||||
<Paragraph className='text-gray-600 dark:text-gray-300'>
|
||||
{t('请输入认证器应用显示的验证码完成登录')}
|
||||
</Paragraph>
|
||||
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<Form.Input
|
||||
field='code'
|
||||
label={useBackupCode ? t('备用码') : t('验证码')}
|
||||
placeholder={
|
||||
useBackupCode ? t('请输入8位备用码') : t('请输入6位验证码')
|
||||
}
|
||||
value={verificationCode}
|
||||
onChange={setVerificationCode}
|
||||
onKeyPress={handleKeyPress}
|
||||
size='large'
|
||||
style={{ marginBottom: 16 }}
|
||||
autoFocus
|
||||
/>
|
||||
|
||||
<Button
|
||||
htmlType='submit'
|
||||
type='primary'
|
||||
loading={loading}
|
||||
block
|
||||
size='large'
|
||||
style={{ marginBottom: 16 }}
|
||||
>
|
||||
{t('验证并登录')}
|
||||
</Button>
|
||||
</Form>
|
||||
|
||||
<Divider />
|
||||
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<Button
|
||||
theme='borderless'
|
||||
type='tertiary'
|
||||
onClick={() => {
|
||||
setUseBackupCode(!useBackupCode);
|
||||
setVerificationCode('');
|
||||
}}
|
||||
style={{ marginRight: 16, color: '#1890ff', padding: 0 }}
|
||||
>
|
||||
{useBackupCode ? t('使用认证器验证码') : t('使用备用码')}
|
||||
</Button>
|
||||
|
||||
{onBack && (
|
||||
<Button
|
||||
theme='borderless'
|
||||
type='tertiary'
|
||||
onClick={onBack}
|
||||
style={{ color: '#1890ff', padding: 0 }}
|
||||
>
|
||||
{t('返回登录')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className='bg-gray-50 dark:bg-gray-800 rounded-lg p-3'>
|
||||
<Text size='small' type='secondary'>
|
||||
<strong>{t('提示:')}</strong>
|
||||
<br />• {t('验证码每30秒更新一次')}
|
||||
<br />• {t('如果无法获取验证码,请使用备用码')}
|
||||
<br />• {t('每个备用码只能使用一次')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
minHeight: '60vh',
|
||||
}}
|
||||
>
|
||||
<Card style={{ width: 400, padding: 24 }}>
|
||||
<div style={{ textAlign: 'center', marginBottom: 24 }}>
|
||||
<Title heading={3}>{t('两步验证')}</Title>
|
||||
<Paragraph type='secondary'>
|
||||
{t('请输入认证器应用显示的验证码完成登录')}
|
||||
</Paragraph>
|
||||
</div>
|
||||
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<Form.Input
|
||||
field='code'
|
||||
label={useBackupCode ? t('备用码') : t('验证码')}
|
||||
placeholder={
|
||||
useBackupCode ? t('请输入8位备用码') : t('请输入6位验证码')
|
||||
}
|
||||
value={verificationCode}
|
||||
onChange={setVerificationCode}
|
||||
onKeyPress={handleKeyPress}
|
||||
size='large'
|
||||
style={{ marginBottom: 16 }}
|
||||
autoFocus
|
||||
/>
|
||||
|
||||
<Button
|
||||
htmlType='submit'
|
||||
type='primary'
|
||||
loading={loading}
|
||||
block
|
||||
size='large'
|
||||
style={{ marginBottom: 16 }}
|
||||
>
|
||||
{t('验证并登录')}
|
||||
</Button>
|
||||
</Form>
|
||||
|
||||
<Divider />
|
||||
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<Button
|
||||
theme='borderless'
|
||||
type='tertiary'
|
||||
onClick={() => {
|
||||
setUseBackupCode(!useBackupCode);
|
||||
setVerificationCode('');
|
||||
}}
|
||||
style={{ marginRight: 16, color: '#1890ff', padding: 0 }}
|
||||
>
|
||||
{useBackupCode ? t('使用认证器验证码') : t('使用备用码')}
|
||||
</Button>
|
||||
|
||||
{onBack && (
|
||||
<Button
|
||||
theme='borderless'
|
||||
type='tertiary'
|
||||
onClick={onBack}
|
||||
style={{ color: '#1890ff', padding: 0 }}
|
||||
>
|
||||
{t('返回登录')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
marginTop: 24,
|
||||
padding: 16,
|
||||
background: '#f6f8fa',
|
||||
borderRadius: 6,
|
||||
}}
|
||||
>
|
||||
<Text size='small' type='secondary'>
|
||||
<strong>{t('提示:')}</strong>
|
||||
<br />• {t('验证码每30秒更新一次')}
|
||||
<br />• {t('如果无法获取验证码,请使用备用码')}
|
||||
<br />• {t('每个备用码只能使用一次')}
|
||||
</Text>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TwoFAVerification;
|
||||
Reference in New Issue
Block a user