feat: 1.统一右侧抽屉关闭按钮布局 2.统一 UI 组件为 Ant Design 移除 radix-ui、floating-ui 组件 3. 修复 ESLint 文件格式错误的问题

This commit is contained in:
zhanjunhao
2026-11-10 14:08:10 +08:00
parent 5c0849e82b
commit 85214b308a
202 changed files with 29195 additions and 12732 deletions
+5 -2
View File
@@ -177,7 +177,10 @@ const LoginForm = () => {
// 使用 StatusContext 获取最新状态,而不是从 localStorage 读取
const [statusState] = useContext(StatusContext);
const status = statusState?.status || {};
const status = React.useMemo(
() => statusState?.status || {},
[statusState?.status],
);
const statusLoaded = statusState?.status !== undefined;
// affCode 只需在挂载时提取一次,避免每次渲染都执行
@@ -222,7 +225,7 @@ const LoginForm = () => {
nextParams.delete('expired');
setSearchParams(nextParams, { replace: true });
}
}, []);
}, [searchParams, setSearchParams, t]);
const finishLogin = useCallback(
(data, successMessage) =>
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useContext, useEffect } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
@@ -85,7 +86,7 @@ const OAuth2Callback = (props) => {
}
};
useEffect(() => {
const onMount = useEffectEvent(() => {
const code = searchParams.get('code');
const state = searchParams.get('state');
@@ -97,7 +98,8 @@ const OAuth2Callback = (props) => {
}
sendCode(code, state);
}, []);
});
useEffect(() => onMount(), [onMount]);
return <Loading />;
};
+369 -366
View File
@@ -148,7 +148,10 @@ const RegisterForm = () => {
// 使用 StatusContext 获取最新状态,而不是从 localStorage 读取
const [statusState] = useContext(StatusContext);
const status = statusState?.status || {};
const status = React.useMemo(
() => statusState?.status || {},
[statusState?.status],
);
const statusLoaded = statusState?.status !== undefined;
const [showEmailVerification, setShowEmailVerification] = useState(() => {
@@ -493,136 +496,301 @@ const RegisterForm = () => {
const renderOAuthOptions = () => {
return (
<GlassCard>
<AuthCardHeader
logo={logo}
title={systemName}
subtitle={t('创建您的账户')}
/>
<AuthCardHeader
logo={logo}
title={systemName}
subtitle={t('创建您的账户')}
/>
<div className='space-y-2'>
{status.wechat_login && (
<OAuthButton
icon={<Icon svg={<WeChatIcon />} />}
iconColor='#07C160'
onClick={onWeChatLoginClicked}
loading={wechatLoading}
>
{t('使用 微信 继续')}
</OAuthButton>
)}
{status.wechat_open_oauth && (
<OAuthButton
icon={<Icon svg={<WeChatIcon />} />}
iconColor='#07C160'
onClick={handleWeChatOpenClick}
loading={wechatOpenLoading}
>
{t('使用 微信扫码 注册')}
</OAuthButton>
)}
{status.github_oauth && (
<OAuthButton
icon={<IconGithubLogo size='large' />}
onClick={handleGitHubClick}
loading={githubLoading}
disabled={githubButtonDisabled}
>
{githubButtonText}
</OAuthButton>
)}
{status.discord_oauth && (
<OAuthButton
icon={<DiscordIcon />}
iconColor='#5865F2'
onClick={handleDiscordClick}
loading={discordLoading}
>
{t('使用 Discord 继续')}
</OAuthButton>
)}
{status.oidc_enabled && (
<OAuthButton
icon={<OIDCIcon />}
iconColor='#1877F2'
onClick={handleOIDCClick}
loading={oidcLoading}
>
{t('使用 OIDC 继续')}
</OAuthButton>
)}
{status.linuxdo_oauth && (
<OAuthButton
icon={<LinuxDoIcon style={{ width: '20px', height: '20px' }} />}
iconColor='#E95420'
onClick={handleLinuxDOClick}
loading={linuxdoLoading}
>
{t('使用 LinuxDO 继续')}
</OAuthButton>
)}
{status.telegram_oauth && (
<Suspense
fallback={
<div className='flex justify-center my-2 h-10 items-center text-gray-400 text-xs'>
Loading...
</div>
}
>
<TelegramLogin
onAuth={onTelegramLoginClicked}
botName={status.telegram_bot_name}
/>
</Suspense>
)}
{/* 分隔线 */}
<div className='relative py-3'>
<div className='absolute inset-0 flex items-center'>
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
</div>
<div className='relative flex justify-center'>
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
{t('或')}
</span>
</div>
</div>
{/* 用户名注册按钮 */}
<button
onClick={handleEmailRegisterClick}
disabled={emailRegisterLoading}
className='group relative w-full h-10 flex items-center justify-center gap-2 bg-gradient-to-r from-brand-from to-brand-to hover:from-brand-from hover:to-brand-to text-white rounded-xl shadow-md shadow-brand/25 dark:shadow-brand/15 hover:shadow-lg hover:shadow-brand/30 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-200 overflow-hidden'
<div className='space-y-2'>
{status.wechat_login && (
<OAuthButton
icon={<Icon svg={<WeChatIcon />} />}
iconColor='#07C160'
onClick={onWeChatLoginClicked}
loading={wechatLoading}
>
{/* 闪光效果 */}
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
{t('使用 微信 继续')}
</OAuthButton>
)}
<IconMail className='relative z-10' />
<span className='relative z-10 font-medium text-sm'>
{t('使用 用户名 注册')}
</span>
<ArrowRight
size={16}
className='relative z-10 group-hover:translate-x-1 transition-transform'
{status.wechat_open_oauth && (
<OAuthButton
icon={<Icon svg={<WeChatIcon />} />}
iconColor='#07C160'
onClick={handleWeChatOpenClick}
loading={wechatOpenLoading}
>
{t('使用 微信扫码 注册')}
</OAuthButton>
)}
{status.github_oauth && (
<OAuthButton
icon={<IconGithubLogo size='large' />}
onClick={handleGitHubClick}
loading={githubLoading}
disabled={githubButtonDisabled}
>
{githubButtonText}
</OAuthButton>
)}
{status.discord_oauth && (
<OAuthButton
icon={<DiscordIcon />}
iconColor='#5865F2'
onClick={handleDiscordClick}
loading={discordLoading}
>
{t('使用 Discord 继续')}
</OAuthButton>
)}
{status.oidc_enabled && (
<OAuthButton
icon={<OIDCIcon />}
iconColor='#1877F2'
onClick={handleOIDCClick}
loading={oidcLoading}
>
{t('使用 OIDC 继续')}
</OAuthButton>
)}
{status.linuxdo_oauth && (
<OAuthButton
icon={<LinuxDoIcon style={{ width: '20px', height: '20px' }} />}
iconColor='#E95420'
onClick={handleLinuxDOClick}
loading={linuxdoLoading}
>
{t('使用 LinuxDO 继续')}
</OAuthButton>
)}
{status.telegram_oauth && (
<Suspense
fallback={
<div className='flex justify-center my-2 h-10 items-center text-gray-400 text-xs'>
Loading...
</div>
}
>
<TelegramLogin
onAuth={onTelegramLoginClicked}
botName={status.telegram_bot_name}
/>
</button>
</Suspense>
)}
{/* 分隔线 */}
<div className='relative py-3'>
<div className='absolute inset-0 flex items-center'>
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
</div>
<div className='relative flex justify-center'>
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
{t('或')}
</span>
</div>
</div>
{/* 用户名注册按钮 */}
<button
onClick={handleEmailRegisterClick}
disabled={emailRegisterLoading}
className='group relative w-full h-10 flex items-center justify-center gap-2 bg-gradient-to-r from-brand-from to-brand-to hover:from-brand-from hover:to-brand-to text-white rounded-xl shadow-md shadow-brand/25 dark:shadow-brand/15 hover:shadow-lg hover:shadow-brand/30 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-200 overflow-hidden'
>
{/* 闪光效果 */}
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
<IconMail className='relative z-10' />
<span className='relative z-10 font-medium text-sm'>
{t('使用 用户名 注册')}
</span>
<ArrowRight
size={16}
className='relative z-10 group-hover:translate-x-1 transition-transform'
/>
</button>
</div>
{(hasUserAgreement || hasPrivacyPolicy) && (
<div className='mt-4 flex justify-center'>
<Checkbox
checked={agreedToTerms}
onChange={(e) => setAgreedToTerms(e.target.checked)}
>
<Text
size='small'
className='text-gray-500 dark:text-gray-400 text-xs'
>
{t('我已阅读并同意')}
{hasUserAgreement && (
<a
href='/user-agreement'
target='_blank'
rel='noopener noreferrer'
onClick={(e) => openAgreement(e, 'agreement')}
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from mx-1 font-medium transition-colors'
>
{t('用户协议')}
</a>
)}
{hasUserAgreement && hasPrivacyPolicy && t('和')}
{hasPrivacyPolicy && (
<a
href='/privacy-policy'
target='_blank'
rel='noopener noreferrer'
onClick={(e) => openAgreement(e, 'privacy')}
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from mx-1 font-medium transition-colors'
>
{t('隐私政策')}
</a>
)}
</Text>
</Checkbox>
</div>
)}
<div className='mt-4 text-center'>
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
{t('已有账户?')}{' '}
<Link
to='/login'
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-semibold transition-colors'
>
{t('登录')}
</Link>
</Text>
</div>
{/* 安全提示 */}
<div className='mt-4 flex items-center justify-center gap-1.5 text-[10px] text-gray-400 dark:text-gray-500'>
<Shield size={12} />
<span>{t('安全注册')}</span>
</div>
</GlassCard>
);
};
const renderEmailRegisterForm = () => {
return (
<GlassCard>
<AuthCardHeader
logo={logo}
title={systemName}
subtitle={t('创建您的账户')}
wrapperClassName='mb-4'
logoWrapperClassName='mb-2'
/>
<Form className='register-compact-form auth-glass-form'>
{/* 用户名输入框 —— 玻璃观感统一由 .auth-glass-form(GlassCard 内置样式)驱动 */}
<Form.Input
field='username'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('用户名')}
</span>
}
placeholder={t('请输入用户名')}
name='username'
size='large'
autoComplete='username'
onChange={(value) => handleChange('username', value)}
prefix={<IconUser size='small' />}
/>
{/* 密码输入框 */}
<Form.Input
field='password'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('密码')}
</span>
}
placeholder={t('输入密码,最短 8 位,最长 20 位')}
name='password'
mode='password'
size='large'
autoComplete='new-password'
onChange={(value) => handleChange('password', value)}
prefix={<IconLock size='small' />}
/>
{/* 确认密码输入框 */}
<Form.Input
field='password2'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('确认密码')}
</span>
}
placeholder={t('确认密码')}
name='password2'
mode='password'
size='large'
autoComplete='new-password'
onChange={(value) => handleChange('password2', value)}
prefix={<IconLock size='small' />}
/>
{showEmailVerification && (
<>
<Form.Input
field='email'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('邮箱')}
</span>
}
placeholder={t('输入邮箱地址')}
name='email'
type='email'
size='large'
autoComplete='email'
onChange={(value) => handleChange('email', value)}
prefix={<IconMail size='small' />}
suffix={
<Button
size='small'
onClick={sendVerificationCode}
loading={verificationCodeLoading}
disabled={disableButton || verificationCodeLoading}
className='!rounded-lg'
>
{disableButton
? `${t('重新发送')} (${countdown})`
: t('获取验证码')}
</Button>
}
/>
<Form.Input
field='verification_code'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('验证码')}
</span>
}
placeholder={t('输入验证码')}
name='verification_code'
size='large'
onChange={(value) => handleChange('verification_code', value)}
prefix={<IconKey size='small' />}
/>
</>
)}
{(hasUserAgreement || hasPrivacyPolicy) && (
<div className='mt-4 flex justify-center'>
<div className='flex items-center mt-3'>
<Checkbox
checked={agreedToTerms}
onChange={(e) => setAgreedToTerms(e.target.checked)}
>
<Text
size='small'
className='text-gray-500 dark:text-gray-400 text-xs'
>
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
{t('我已阅读并同意')}
{hasUserAgreement && (
<a
@@ -630,7 +798,7 @@ const RegisterForm = () => {
target='_blank'
rel='noopener noreferrer'
onClick={(e) => openAgreement(e, 'agreement')}
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from mx-1 font-medium transition-colors'
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from mx-0.5 font-medium transition-colors'
>
{t('用户协议')}
</a>
@@ -642,7 +810,7 @@ const RegisterForm = () => {
target='_blank'
rel='noopener noreferrer'
onClick={(e) => openAgreement(e, 'privacy')}
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from mx-1 font-medium transition-colors'
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from mx-0.5 font-medium transition-colors'
>
{t('隐私政策')}
</a>
@@ -652,248 +820,83 @@ const RegisterForm = () => {
</div>
)}
<div className='mt-4 text-center'>
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
{t('已有账户?')}{' '}
<Link
to='/login'
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-semibold transition-colors'
>
{t('登录')}
</Link>
</Text>
</div>
{/* 安全提示 */}
<div className='mt-4 flex items-center justify-center gap-1.5 text-[10px] text-gray-400 dark:text-gray-500'>
<Shield size={12} />
<span>{t('安全注册')}</span>
</div>
</GlassCard>
);
};
const renderEmailRegisterForm = () => {
return (
<GlassCard>
<AuthCardHeader
logo={logo}
title={systemName}
subtitle={t('创建您的账户')}
wrapperClassName='mb-4'
logoWrapperClassName='mb-2'
/>
<Form className='register-compact-form auth-glass-form'>
{/* 用户名输入框 —— 玻璃观感统一由 .auth-glass-form(GlassCard 内置样式)驱动 */}
<Form.Input
field='username'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('用户名')}
</span>
<div className='space-y-2 mt-3'>
{/* 注册按钮 */}
<button
type='submit'
onClick={handleSubmit}
disabled={
registerLoading ||
((hasUserAgreement || hasPrivacyPolicy) && !agreedToTerms)
}
placeholder={t('请输入用户名')}
name='username'
size='large'
autoComplete='username'
onChange={(value) => handleChange('username', value)}
prefix={<IconUser size='small' />}
/>
className='group relative w-full h-10 flex items-center justify-center gap-2 bg-gradient-to-r from-brand-from to-brand-to hover:from-brand-from hover:to-brand-to disabled:from-gray-400 disabled:to-gray-500 text-white rounded-xl shadow-md shadow-brand/25 dark:shadow-brand/15 hover:shadow-lg hover:shadow-brand/30 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-200 disabled:cursor-not-allowed disabled:hover:translate-y-0 overflow-hidden'
>
{/* 闪光效果 */}
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
{/* 密码输入框 */}
<Form.Input
field='password'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('密码')}
</span>
}
placeholder={t('输入密码,最短 8 位,最长 20 位')}
name='password'
mode='password'
size='large'
autoComplete='new-password'
onChange={(value) => handleChange('password', value)}
prefix={<IconLock size='small' />}
/>
{/* 确认密码输入框 */}
<Form.Input
field='password2'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('确认密码')}
</span>
}
placeholder={t('确认密码')}
name='password2'
mode='password'
size='large'
autoComplete='new-password'
onChange={(value) => handleChange('password2', value)}
prefix={<IconLock size='small' />}
/>
{showEmailVerification && (
<>
<Form.Input
field='email'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('邮箱')}
</span>
}
placeholder={t('输入邮箱地址')}
name='email'
type='email'
size='large'
autoComplete='email'
onChange={(value) => handleChange('email', value)}
prefix={<IconMail size='small' />}
suffix={
<Button
size='small'
onClick={sendVerificationCode}
loading={verificationCodeLoading}
disabled={disableButton || verificationCodeLoading}
className='!rounded-lg'
>
{disableButton
? `${t('重新发送')} (${countdown})`
: t('获取验证码')}
</Button>
}
/>
<Form.Input
field='verification_code'
label={
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
{t('验证码')}
</span>
}
placeholder={t('输入验证码')}
name='verification_code'
size='large'
onChange={(value) => handleChange('verification_code', value)}
prefix={<IconKey size='small' />}
/>
</>
)}
{(hasUserAgreement || hasPrivacyPolicy) && (
<div className='flex items-center mt-3'>
<Checkbox
checked={agreedToTerms}
onChange={(e) => setAgreedToTerms(e.target.checked)}
>
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
{t('我已阅读并同意')}
{hasUserAgreement && (
<a
href='/user-agreement'
target='_blank'
rel='noopener noreferrer'
onClick={(e) => openAgreement(e, 'agreement')}
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from mx-0.5 font-medium transition-colors'
>
{t('用户协议')}
</a>
)}
{hasUserAgreement && hasPrivacyPolicy && t('和')}
{hasPrivacyPolicy && (
<a
href='/privacy-policy'
target='_blank'
rel='noopener noreferrer'
onClick={(e) => openAgreement(e, 'privacy')}
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from mx-0.5 font-medium transition-colors'
>
{t('隐私政策')}
</a>
)}
</Text>
</Checkbox>
</div>
)}
<div className='space-y-2 mt-3'>
{/* 注册按钮 */}
<button
type='submit'
onClick={handleSubmit}
disabled={
registerLoading ||
((hasUserAgreement || hasPrivacyPolicy) && !agreedToTerms)
}
className='group relative w-full h-10 flex items-center justify-center gap-2 bg-gradient-to-r from-brand-from to-brand-to hover:from-brand-from hover:to-brand-to disabled:from-gray-400 disabled:to-gray-500 text-white rounded-xl shadow-md shadow-brand/25 dark:shadow-brand/15 hover:shadow-lg hover:shadow-brand/30 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-200 disabled:cursor-not-allowed disabled:hover:translate-y-0 overflow-hidden'
>
{/* 闪光效果 */}
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
{registerLoading ? (
<div className='w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin' />
) : (
<>
<span className='relative z-10 font-semibold'>
{t('注 册')}
</span>
<ArrowRight
size={16}
className='relative z-10 group-hover:translate-x-1 transition-transform'
/>
</>
)}
</button>
</div>
</Form>
{(status.github_oauth ||
status.discord_oauth ||
status.oidc_enabled ||
status.wechat_login ||
status.wechat_open_oauth ||
status.linuxdo_oauth ||
status.telegram_oauth) && (
<div className='mt-2'>
<div className='relative py-3'>
<div className='absolute inset-0 flex items-center'>
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
</div>
<div className='relative flex justify-center'>
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
{t('或')}
{registerLoading ? (
<div className='w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin' />
) : (
<>
<span className='relative z-10 font-semibold'>
{t('注 册')}
</span>
</div>
<ArrowRight
size={16}
className='relative z-10 group-hover:translate-x-1 transition-transform'
/>
</>
)}
</button>
</div>
</Form>
{(status.github_oauth ||
status.discord_oauth ||
status.oidc_enabled ||
status.wechat_login ||
status.wechat_open_oauth ||
status.linuxdo_oauth ||
status.telegram_oauth) && (
<div className='mt-2'>
<div className='relative py-3'>
<div className='absolute inset-0 flex items-center'>
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
</div>
<div className='relative flex justify-center'>
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
{t('或')}
</span>
</div>
<button
onClick={handleOtherRegisterOptionsClick}
disabled={otherRegisterOptionsLoading}
className='w-full h-9 flex items-center justify-center gap-2 text-sm text-gray-600 dark:text-gray-300 border border-gray-200/80 dark:border-white/[0.12] rounded-lg hover:bg-gray-50 dark:hover:bg-white/[0.06] hover:border-gray-300 dark:hover:border-white/20 transition-all'
>
{t('其他注册选项')}
</button>
</div>
)}
<div className='mt-4 text-center'>
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
{t('已有账户?')}{' '}
<Link
to='/login'
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-semibold transition-colors'
>
{t('登录')}
</Link>
</Text>
<button
onClick={handleOtherRegisterOptionsClick}
disabled={otherRegisterOptionsLoading}
className='w-full h-9 flex items-center justify-center gap-2 text-sm text-gray-600 dark:text-gray-300 border border-gray-200/80 dark:border-white/[0.12] rounded-lg hover:bg-gray-50 dark:hover:bg-white/[0.06] hover:border-gray-300 dark:hover:border-white/20 transition-all'
>
{t('其他注册选项')}
</button>
</div>
)}
{/* 安全提示 */}
<div className='mt-4 flex items-center justify-center gap-1.5 text-[10px] text-gray-400 dark:text-gray-500'>
<Shield size={12} />
<span>{t('安全注册')}</span>
</div>
<div className='mt-4 text-center'>
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
{t('已有账户?')}{' '}
<Link
to='/login'
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-semibold transition-colors'
>
{t('登录')}
</Link>
</Text>
</div>
{/* 安全提示 */}
<div className='mt-4 flex items-center justify-center gap-1.5 text-[10px] text-gray-400 dark:text-gray-500'>
<Shield size={12} />
<span>{t('安全注册')}</span>
</div>
</GlassCard>
);
};
@@ -1063,16 +1066,16 @@ const RegisterForm = () => {
const renderSkeleton = () => {
return (
<GlassCard withCornerHalos={false} withAurora={false}>
<div className='flex flex-col items-center justify-center mb-5'>
<div className='w-14 h-14 rounded-xl bg-gray-200/60 dark:bg-white/10 animate-pulse mb-3' />
<div className='w-24 h-5 rounded bg-gray-200/60 dark:bg-white/10 animate-pulse mb-1' />
<div className='w-32 h-3 rounded bg-gray-100/80 dark:bg-white/5 animate-pulse' />
</div>
<div className='space-y-2'>
<div className='w-full h-10 rounded-xl bg-gray-200/60 dark:bg-white/10 animate-pulse' />
<div className='w-full h-10 rounded-xl bg-gray-200/60 dark:bg-white/10 animate-pulse' />
<div className='w-full h-10 rounded-xl bg-gray-200/60 dark:bg-white/10 animate-pulse' />
</div>
<div className='flex flex-col items-center justify-center mb-5'>
<div className='w-14 h-14 rounded-xl bg-gray-200/60 dark:bg-white/10 animate-pulse mb-3' />
<div className='w-24 h-5 rounded bg-gray-200/60 dark:bg-white/10 animate-pulse mb-1' />
<div className='w-32 h-3 rounded bg-gray-100/80 dark:bg-white/5 animate-pulse' />
</div>
<div className='space-y-2'>
<div className='w-full h-10 rounded-xl bg-gray-200/60 dark:bg-white/10 animate-pulse' />
<div className='w-full h-10 rounded-xl bg-gray-200/60 dark:bg-white/10 animate-pulse' />
<div className='w-full h-10 rounded-xl bg-gray-200/60 dark:bg-white/10 animate-pulse' />
</div>
</GlassCard>
);
};
+1 -7
View File
@@ -17,13 +17,7 @@ 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 '@/components/ui';
import { Button, Card, Divider, Form, Typography } from '@/components/ui';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -102,7 +102,10 @@ const AgreementModal = ({ visible, type, onClose }) => {
{/* 头部 */}
<div className='relative flex items-center justify-between px-5 sm:px-6 h-14 border-b border-gray-200/80 dark:border-gray-800/80 flex-shrink-0 bg-white/95 dark:bg-gray-900/95 backdrop-blur-md'>
{/* 头部环境光 */}
<div className='pointer-events-none absolute inset-0 overflow-hidden' aria-hidden>
<div
className='pointer-events-none absolute inset-0 overflow-hidden'
aria-hidden
>
<div className='absolute -top-12 left-8 w-48 h-24 bg-gradient-to-br from-brand-from/15 to-brand-to/10 dark:from-brand-from/15 dark:to-brand-to/10 blur-3xl rounded-full' />
</div>
@@ -126,7 +129,10 @@ const AgreementModal = ({ visible, type, onClose }) => {
className='group inline-flex items-center gap-1 px-2 py-1.5 text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from hover:bg-gray-100/80 dark:hover:bg-gray-800/80 rounded-md transition-colors'
title={t('在新标签页打开')}
>
<ExternalLink size={12} className='transition-transform group-hover:translate-x-0.5 group-hover:-translate-y-0.5' />
<ExternalLink
size={12}
className='transition-transform group-hover:translate-x-0.5 group-hover:-translate-y-0.5'
/>
<span className='hidden sm:inline'>{t('完整页面')}</span>
</a>
<button
+32 -30
View File
@@ -17,39 +17,41 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import {
OpenAI,
Claude,
Gemini,
Moonshot,
Zhipu,
Qwen,
DeepSeek,
Minimax,
Wenxin,
Spark,
Midjourney,
Hunyuan,
Cohere,
Cloudflare,
Ai360,
Yi,
Jina,
Mistral,
XAI,
Ollama,
Doubao,
Suno,
Xinference,
OpenRouter,
Dify,
Coze,
SiliconCloud,
Kling,
Perplexity,
Replicate,
} from '@/assets/brand-icons/lobehub';
import React from 'react';
import { Avatar } from '@/components/ui';
import { Bot as FastGPT, Image as Jimeng } from 'lucide-react';
import OpenAI from '@lobehub/icons/es/OpenAI';
import Claude from '@lobehub/icons/es/Claude';
import Gemini from '@lobehub/icons/es/Gemini';
import Moonshot from '@lobehub/icons/es/Moonshot';
import Zhipu from '@lobehub/icons/es/Zhipu';
import Qwen from '@lobehub/icons/es/Qwen';
import DeepSeek from '@lobehub/icons/es/DeepSeek';
import Minimax from '@lobehub/icons/es/Minimax';
import Wenxin from '@lobehub/icons/es/Wenxin';
import Spark from '@lobehub/icons/es/Spark';
import Midjourney from '@lobehub/icons/es/Midjourney';
import Hunyuan from '@lobehub/icons/es/Hunyuan';
import Cohere from '@lobehub/icons/es/Cohere';
import Cloudflare from '@lobehub/icons/es/Cloudflare';
import Ai360 from '@lobehub/icons/es/Ai360';
import Yi from '@lobehub/icons/es/Yi';
import Jina from '@lobehub/icons/es/Jina';
import Mistral from '@lobehub/icons/es/Mistral';
import XAI from '@lobehub/icons/es/XAI';
import Ollama from '@lobehub/icons/es/Ollama';
import Doubao from '@lobehub/icons/es/Doubao';
import Suno from '@lobehub/icons/es/Suno';
import Xinference from '@lobehub/icons/es/Xinference';
import OpenRouter from '@lobehub/icons/es/OpenRouter';
import Dify from '@lobehub/icons/es/Dify';
import Coze from '@lobehub/icons/es/Coze';
import SiliconCloud from '@lobehub/icons/es/SiliconCloud';
import Kling from '@lobehub/icons/es/Kling';
import Perplexity from '@lobehub/icons/es/Perplexity';
import Replicate from '@lobehub/icons/es/Replicate';
const LobeIconsMap = {
OpenAI,
+2 -2
View File
@@ -41,8 +41,8 @@ runInNewContext(code, {
if (name === 'react') return React;
if (name === '@/components/ui') return { Avatar: 'avatar' };
if (name === 'lucide-react') return { Bot: Mono, Image: Mono };
assert.ok(name.startsWith('@lobehub/icons/es/'), name);
return Object.assign(Mono, { Color, Avatar });
assert.equal(name, '@/assets/brand-icons/lobehub');
return new Proxy({}, { get: () => Object.assign(Mono, { Color, Avatar }) });
},
});
const render = module.exports.default;
+1 -8
View File
@@ -18,14 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React, { useEffect, useRef } from 'react';
import {
Select,
Spin,
Typography,
Empty,
Tag,
Tooltip,
} from '@/components/ui';
import { Select, Spin, Typography, Empty, Tag, Tooltip } from '@/components/ui';
import { Lock } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useModelSelector } from '../../hooks/models/useModelSelector';
+77 -19
View File
@@ -50,7 +50,11 @@ import React, { useEffect, useRef } from 'react';
const hexToRgb = (hex) => {
if (!hex) return { r: 99, g: 102, b: 241 }; // brand-primary 兜底
let h = hex.replace('#', '').trim();
if (h.length === 3) h = h.split('').map((c) => c + c).join('');
if (h.length === 3)
h = h
.split('')
.map((c) => c + c)
.join('');
if (h.length === 8) h = h.slice(0, 6); // 忽略 alpha
if (!/^[0-9a-fA-F]{6}$/.test(h)) return { r: 99, g: 102, b: 241 };
const num = parseInt(h, 16);
@@ -62,7 +66,12 @@ const easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
// 三阶 Bezier 求 t 处坐标(给触手沿曲线放置吸盘用)
const bezierPoint = (p0, p1, p2, p3, t) => {
const mt = 1 - t;
return mt * mt * mt * p0 + 3 * mt * mt * t * p1 + 3 * mt * t * t * p2 + t * t * t * p3;
return (
mt * mt * mt * p0 +
3 * mt * mt * t * p1 +
3 * mt * t * t * p2 +
t * t * t * p3
);
};
// ─── 粒子类 ──────────────────────────────────────────────────
@@ -74,7 +83,11 @@ class Plankton {
}
reset(randomY = false) {
this.x = Math.random() * this.w;
this.y = randomY ? Math.random() * this.h : Math.random() < 0.5 ? -10 : this.h + 10;
this.y = randomY
? Math.random() * this.h
: Math.random() < 0.5
? -10
: this.h + 10;
this.size = Math.random() * 1.5 + 0.5;
this.vx = (Math.random() - 0.5) * 0.2;
this.vy = (Math.random() - 0.5) * 0.15;
@@ -85,7 +98,13 @@ class Plankton {
this.x += this.vx;
this.y += this.vy + Math.sin(this.phase) * 0.15;
this.phase += 0.015;
if (this.x < -20 || this.x > this.w + 20 || this.y < -20 || this.y > this.h + 20) this.reset();
if (
this.x < -20 ||
this.x > this.w + 20 ||
this.y < -20 ||
this.y > this.h + 20
)
this.reset();
}
resize(w, h) {
this.w = w;
@@ -153,7 +172,13 @@ class Bubble {
ctx.stroke();
ctx.fillStyle = `rgba(255, 255, 255, ${this.alpha * 0.5})`;
ctx.beginPath();
ctx.arc(x - this.size * 0.3, y - this.size * 0.3, this.size * 0.28, 0, Math.PI * 2);
ctx.arc(
x - this.size * 0.3,
y - this.size * 0.3,
this.size * 0.28,
0,
Math.PI * 2,
);
ctx.fill();
}
}
@@ -287,10 +312,19 @@ class LifePulse {
// 从屏幕外随机一侧触发
const side = Math.floor(Math.random() * 4);
const m = 100;
if (side === 0) { this.ox = Math.random() * this.w; this.oy = -m; }
else if (side === 1) { this.ox = this.w + m; this.oy = Math.random() * this.h; }
else if (side === 2) { this.ox = Math.random() * this.w; this.oy = this.h + m; }
else { this.ox = -m; this.oy = Math.random() * this.h; }
if (side === 0) {
this.ox = Math.random() * this.w;
this.oy = -m;
} else if (side === 1) {
this.ox = this.w + m;
this.oy = Math.random() * this.h;
} else if (side === 2) {
this.ox = Math.random() * this.w;
this.oy = this.h + m;
} else {
this.ox = -m;
this.oy = Math.random() * this.h;
}
this.active = true;
this.startT = now;
this.maxR = Math.hypot(this.w, this.h) * 0.7;
@@ -307,7 +341,14 @@ class LifePulse {
const alpha = p < 0.5 ? p * 2 * 0.35 : (1 - p) * 2 * 0.35;
const inner = Math.max(0, radius - 50);
const outer = radius + 50;
const grad = ctx.createRadialGradient(this.ox, this.oy, inner, this.ox, this.oy, outer);
const grad = ctx.createRadialGradient(
this.ox,
this.oy,
inner,
this.ox,
this.oy,
outer,
);
grad.addColorStop(0, rgba(color, 0));
grad.addColorStop(0.5, rgba(color, alpha));
grad.addColorStop(1, rgba(color, 0));
@@ -330,7 +371,8 @@ const readTheme = () => {
};
const detectDark = () => {
if (document.documentElement.classList.contains('dark')) return true;
if (document.body && document.body.getAttribute('theme-mode') === 'dark') return true;
if (document.body && document.body.getAttribute('theme-mode') === 'dark')
return true;
// ThemeContext 在浅色模式会移除上面两个标记,此时必须先看用户显式选择,
// 否则"强制浅色 + 系统深色"会被 prefers-color-scheme 兜底误判成暗色
try {
@@ -340,7 +382,10 @@ const detectDark = () => {
} catch {
// localStorage 不可用(隐私模式等)时继续走系统偏好
}
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
return (
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches
);
};
// ─── 组件 ─────────────────────────────────────────────────
@@ -359,9 +404,10 @@ const OceanBackground = () => {
const dpr = Math.min(window.devicePixelRatio || 1, 1.5); // 上限避免移动端开销
// 设备 / 偏好检测
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent,
);
const isMobile =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent,
);
const reducedMotion =
window.matchMedia &&
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -393,9 +439,18 @@ const OceanBackground = () => {
};
// 实例化
const plankton = Array.from({ length: COUNT.plankton }, () => new Plankton(width, height));
const sparkles = Array.from({ length: COUNT.sparkle }, () => new Sparkle(width, height));
const bubbles = Array.from({ length: COUNT.bubble }, () => new Bubble(width, height));
const plankton = Array.from(
{ length: COUNT.plankton },
() => new Plankton(width, height),
);
const sparkles = Array.from(
{ length: COUNT.sparkle },
() => new Sparkle(width, height),
);
const bubbles = Array.from(
{ length: COUNT.bubble },
() => new Bubble(width, height),
);
const pillars = Array.from(
{ length: COUNT.pillar },
(_, i) => new LightPillar(width, i, COUNT.pillar || 1),
@@ -445,7 +500,10 @@ const OceanBackground = () => {
const r1 = Math.max(width, height) * 0.75;
const vig = ctx.createRadialGradient(cx, cy, r0, cx, cy, r1);
vig.addColorStop(0, 'rgba(0, 0, 0, 0)');
vig.addColorStop(1, isDark ? 'rgba(0, 0, 0, 0.55)' : 'rgba(0, 10, 25, 0.35)');
vig.addColorStop(
1,
isDark ? 'rgba(0, 0, 0, 0.55)' : 'rgba(0, 10, 25, 0.35)',
);
ctx.fillStyle = vig;
ctx.fillRect(0, 0, width, height);
};
@@ -14,11 +14,7 @@
var(--ui-color-primary) 14%,
transparent
);
--pg-tint-line: color-mix(
in srgb,
var(--ui-color-primary) 28%,
transparent
);
--pg-tint-line: color-mix(in srgb, var(--ui-color-primary) 28%, transparent);
--pg-ok: var(--ui-color-success);
--pg-ok-tint: color-mix(in srgb, var(--ui-color-success) 14%, transparent);
}
@@ -0,0 +1,72 @@
/*
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, { forwardRef } from 'react';
import { Avatar, theme } from 'antd';
// Keep the upstream brand sizing contract; the container uses the app's Ant theme.
export default forwardRef(function IconAvatar(
{
shape = 'circle',
color,
background,
size,
style,
iconMultiple = 0.75,
Icon,
iconStyle,
iconClassName,
...props
},
ref,
) {
const { token } = theme.useToken();
const scaled = size * iconMultiple;
const iconSize = scaled % 2 === 0 ? scaled : scaled - 1;
const foreground = color ?? token.colorWhite;
return (
<Avatar
{...props}
ref={ref}
size={size}
shape={shape}
style={{
flex: 'none',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
background,
color: foreground,
border: 0,
borderRadius: shape === 'circle' ? '50%' : Math.floor(size * 0.1),
...style,
}}
icon={
Icon && (
<Icon
className={iconClassName}
color={foreground}
size={iconSize}
style={iconStyle}
/>
)
}
/>
);
});
@@ -0,0 +1,92 @@
/*
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, { forwardRef } from 'react';
export default forwardRef(function IconCombine(
{
Icon,
Text,
color,
size = 24,
spaceMultiple = 1,
textMultiple = 1,
extra,
extraStyle,
showText = true,
showLogo = true,
extraClassName,
iconProps,
inverse,
style,
...props
},
ref,
) {
const logo = Icon && showLogo && (
<Icon
size={size}
{...iconProps}
style={{
[inverse ? 'marginLeft' : 'marginRight']: size * spaceMultiple,
...iconProps?.style,
}}
/>
);
const text = showText && Text && <Text size={size * textMultiple} />;
return (
<div
{...props}
ref={ref}
style={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
flex: 'none',
color,
...style,
}}
>
{inverse ? (
<>
{text}
{logo}
</>
) : (
<>
{logo}
{text}
</>
)}
{extra && (
<span
className={extraClassName}
style={{
fontSize: size * textMultiple * 0.95,
lineHeight: 1,
...extraStyle,
}}
>
{extra}
</span>
)}
</div>
);
});
@@ -0,0 +1,25 @@
/*
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 { useActualTheme } from '../../../context/Theme';
// Dify and Moonshot variants read the existing app theme without a second provider.
export function useThemeMode() {
return { isDarkMode: useActualTheme() === 'dark' };
}
+153 -30
View File
@@ -33,8 +33,14 @@ export const IllustrationNoResult = ({ style = {} }) => (
<stop offset='100%' stopColor='var(--brand-gradient-via)' />
</linearGradient>
<linearGradient id='noResultGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
<stop offset='0%' stopColor='color-mix(in srgb, var(--brand-primary) 12%, #fff)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-primary) 20%, #fff)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--brand-primary) 12%, #fff)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--brand-primary) 20%, #fff)'
/>
</linearGradient>
<filter id='noResultShadow' x='-20%' y='-20%' width='140%' height='140%'>
<feDropShadow
@@ -99,7 +105,13 @@ export const IllustrationNoResult = ({ style = {} }) => (
repeatCount='indefinite'
/>
</circle>
<circle cx='160' cy='50' r='3' fill='var(--brand-gradient-via)' opacity='0.5'>
<circle
cx='160'
cy='50'
r='3'
fill='var(--brand-gradient-via)'
opacity='0.5'
>
<animate
attributeName='opacity'
values='0.5;1;0.5'
@@ -107,7 +119,13 @@ export const IllustrationNoResult = ({ style = {} }) => (
repeatCount='indefinite'
/>
</circle>
<circle cx='155' cy='140' r='5' fill='var(--brand-gradient-to)' opacity='0.3'>
<circle
cx='155'
cy='140'
r='5'
fill='var(--brand-gradient-to)'
opacity='0.3'
>
<animate
attributeName='opacity'
values='0.3;0.7;0.3'
@@ -143,8 +161,14 @@ export const IllustrationNoResultDark = ({ style = {} }) => (
x2='100%'
y2='100%'
>
<stop offset='0%' stopColor='color-mix(in srgb, var(--brand-primary) 25%, #000)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--brand-primary) 25%, #000)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)'
/>
</linearGradient>
</defs>
<circle
@@ -200,7 +224,13 @@ export const IllustrationNoResultDark = ({ style = {} }) => (
strokeLinecap='round'
/>
</g>
<circle cx='45' cy='60' r='4' fill='var(--brand-gradient-from)' opacity='0.5'>
<circle
cx='45'
cy='60'
r='4'
fill='var(--brand-gradient-from)'
opacity='0.5'
>
<animate
attributeName='opacity'
values='0.5;1;0.5'
@@ -208,7 +238,13 @@ export const IllustrationNoResultDark = ({ style = {} }) => (
repeatCount='indefinite'
/>
</circle>
<circle cx='160' cy='50' r='3' fill='var(--brand-gradient-to)' opacity='0.6'>
<circle
cx='160'
cy='50'
r='3'
fill='var(--brand-gradient-to)'
opacity='0.6'
>
<animate
attributeName='opacity'
values='0.6;1;0.6'
@@ -216,7 +252,13 @@ export const IllustrationNoResultDark = ({ style = {} }) => (
repeatCount='indefinite'
/>
</circle>
<circle cx='155' cy='140' r='5' fill='var(--brand-primary-hover)' opacity='0.4'>
<circle
cx='155'
cy='140'
r='5'
fill='var(--brand-primary-hover)'
opacity='0.4'
>
<animate
attributeName='opacity'
values='0.4;0.8;0.4'
@@ -241,8 +283,14 @@ export const IllustrationNotFound = ({ style = {} }) => (
<stop offset='100%' stopColor='var(--ui-color-danger)' />
</linearGradient>
<linearGradient id='notFoundGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
<stop offset='0%' stopColor='color-mix(in srgb, var(--ui-color-warning) 15%, #fff)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--ui-color-danger) 25%, #fff)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--ui-color-warning) 15%, #fff)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--ui-color-danger) 25%, #fff)'
/>
</linearGradient>
</defs>
{/* 背景 */}
@@ -330,8 +378,14 @@ export const IllustrationNotFoundDark = ({ style = {} }) => (
x2='100%'
y2='100%'
>
<stop offset='0%' stopColor='color-mix(in srgb, var(--ui-color-warning) 30%, #000)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--ui-color-danger) 30%, #000)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--ui-color-warning) 30%, #000)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--ui-color-danger) 30%, #000)'
/>
</linearGradient>
</defs>
<circle
@@ -410,7 +464,10 @@ export const IllustrationNoAccess = ({ style = {} }) => (
</linearGradient>
<linearGradient id='noAccessGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
<stop offset='0%' stopColor='#fce7f3' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 10%, #fff)' />
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--brand-gradient-via) 10%, #fff)'
/>
</linearGradient>
</defs>
{/* 背景 */}
@@ -444,7 +501,13 @@ export const IllustrationNoAccess = ({ style = {} }) => (
repeatCount='indefinite'
/>
</circle>
<circle cx='160' cy='130' r='5' fill='var(--brand-gradient-via)' opacity='0.4'>
<circle
cx='160'
cy='130'
r='5'
fill='var(--brand-gradient-via)'
opacity='0.4'
>
<animate
attributeName='r'
values='5;7;5'
@@ -480,8 +543,14 @@ export const IllustrationNoAccessDark = ({ style = {} }) => (
x2='100%'
y2='100%'
>
<stop offset='0%' stopColor='color-mix(in srgb, var(--ui-color-danger) 30%, #000)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--ui-color-danger) 30%, #000)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)'
/>
</linearGradient>
</defs>
<circle
@@ -499,8 +568,20 @@ export const IllustrationNoAccessDark = ({ style = {} }) => (
rx='8'
fill='url(#noAccessGradDark1)'
/>
<circle cx='100' cy='112' r='8' fill='color-mix(in srgb, var(--brand-primary) 15%, #000)' />
<rect x='96' y='112' width='8' height='18' rx='2' fill='color-mix(in srgb, var(--brand-primary) 15%, #000)' />
<circle
cx='100'
cy='112'
r='8'
fill='color-mix(in srgb, var(--brand-primary) 15%, #000)'
/>
<rect
x='96'
y='112'
width='8'
height='18'
rx='2'
fill='color-mix(in srgb, var(--brand-primary) 15%, #000)'
/>
<path
d='M75 90 V70 C75 55 85 45 100 45 C115 45 125 55 125 70 V90'
stroke='url(#noAccessGradDark1)'
@@ -516,7 +597,13 @@ export const IllustrationNoAccessDark = ({ style = {} }) => (
repeatCount='indefinite'
/>
</circle>
<circle cx='160' cy='130' r='5' fill='var(--brand-gradient-to)' opacity='0.5'>
<circle
cx='160'
cy='130'
r='5'
fill='var(--brand-gradient-to)'
opacity='0.5'
>
<animate
attributeName='r'
values='5;7;5'
@@ -541,8 +628,14 @@ export const IllustrationConstruction = ({ style = {} }) => (
<stop offset='100%' stopColor='var(--accent-teal)' />
</linearGradient>
<linearGradient id='constructGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
<stop offset='0%' stopColor='color-mix(in srgb, var(--ui-color-success) 15%, #fff)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--accent-teal) 15%, #fff)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--ui-color-success) 15%, #fff)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--accent-teal) 15%, #fff)'
/>
</linearGradient>
</defs>
{/* 背景 */}
@@ -670,8 +763,14 @@ export const IllustrationConstructionDark = ({ style = {} }) => (
x2='100%'
y2='100%'
>
<stop offset='0%' stopColor='color-mix(in srgb, var(--ui-color-success) 25%, #000)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--accent-teal) 25%, #000)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--ui-color-success) 25%, #000)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--accent-teal) 25%, #000)'
/>
</linearGradient>
</defs>
<circle
@@ -783,8 +882,14 @@ export const IllustrationNoContent = ({ style = {} }) => (
<stop offset='100%' stopColor='var(--brand-gradient-via)' />
</linearGradient>
<linearGradient id='noContentGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
<stop offset='0%' stopColor='color-mix(in srgb, var(--accent-blue) 12%, #fff)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 10%, #fff)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--accent-blue) 12%, #fff)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--brand-gradient-via) 10%, #fff)'
/>
</linearGradient>
</defs>
{/* 背景 */}
@@ -846,7 +951,13 @@ export const IllustrationNoContent = ({ style = {} }) => (
repeatCount='indefinite'
/>
</circle>
<circle cx='40' cy='145' r='3' fill='var(--brand-gradient-via)' opacity='0.4'>
<circle
cx='40'
cy='145'
r='3'
fill='var(--brand-gradient-via)'
opacity='0.4'
>
<animate
attributeName='opacity'
values='0.4;0.8;0.4'
@@ -882,8 +993,14 @@ export const IllustrationNoContentDark = ({ style = {} }) => (
x2='100%'
y2='100%'
>
<stop offset='0%' stopColor='color-mix(in srgb, var(--accent-blue) 25%, #000)' />
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)' />
<stop
offset='0%'
stopColor='color-mix(in srgb, var(--accent-blue) 25%, #000)'
/>
<stop
offset='100%'
stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)'
/>
</linearGradient>
</defs>
<circle
@@ -941,7 +1058,13 @@ export const IllustrationNoContentDark = ({ style = {} }) => (
repeatCount='indefinite'
/>
</circle>
<circle cx='40' cy='145' r='3' fill='var(--brand-gradient-to)' opacity='0.5'>
<circle
cx='40'
cy='145'
r='3'
fill='var(--brand-gradient-to)'
opacity='0.5'
>
<animate
attributeName='opacity'
values='0.5;0.9;0.5'
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import ReactMarkdown from 'react-markdown';
import 'katex/dist/katex.min.css';
import 'highlight.js/styles/github.css';
@@ -26,13 +27,7 @@ import RemarkBreaks from 'remark-breaks';
import RehypeKatex from 'rehype-katex';
import RemarkGfm from 'remark-gfm';
import RehypeHighlight from 'rehype-highlight';
import {
useRef,
useState,
useEffect,
useMemo,
useId,
} from 'react';
import { useRef, useState, useEffect, useMemo, useId } from 'react';
import React from 'react';
import { useDebouncedCallback } from 'use-debounce';
import clsx from 'clsx';
@@ -199,7 +194,7 @@ export function PreCode(props) {
}, 600);
// 处理代码块的换行
useEffect(() => {
const onMount = useEffectEvent(() => {
if (ref.current) {
const codeElements = ref.current.querySelectorAll('code');
const wrapLanguages = [
@@ -221,7 +216,8 @@ export function PreCode(props) {
});
setTimeout(renderArtifacts, 1);
}
}, []);
});
useEffect(() => onMount(), [onMount]);
return (
<>
@@ -509,9 +505,7 @@ function MarkdownContentImpl(props) {
{...aProps}
target={target}
style={{
color: isUserMessage
? '#87CEEB'
: 'var(--ui-color-primary)',
color: isUserMessage ? '#87CEEB' : 'var(--ui-color-primary)',
textDecoration: 'none',
}}
onMouseEnter={(e) => {
@@ -18,13 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React, { useState, useEffect, useContext } from 'react';
import {
Modal,
RadioGroup,
Radio,
Button,
Typography,
} from '@/components/ui';
import { Modal, RadioGroup, Radio, Button, Typography } from '@/components/ui';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import {
+7 -5
View File
@@ -161,16 +161,18 @@ const JSONEditor = ({
}
// 只在外部值真正改变时更新,避免循环更新
const currentObj = keyValueArrayToObject(keyValuePairs);
if (JSON.stringify(parsed) !== JSON.stringify(currentObj)) {
setKeyValuePairs(objectToKeyValueArray(parsed, keyValuePairs));
}
setKeyValuePairs((previous) => {
const currentObj = keyValueArrayToObject(previous);
return JSON.stringify(parsed) === JSON.stringify(currentObj)
? previous
: objectToKeyValueArray(parsed, previous);
});
setJsonError('');
} catch (error) {
console.log('JSON解析失败:', error.message);
setJsonError(error.message);
}
}, [value]);
}, [value, keyValueArrayToObject, objectToKeyValueArray]);
// 外部 value 变化时,若不在手动模式,则同步手动文本
useEffect(() => {
+4 -1
View File
@@ -38,7 +38,10 @@ const readBrand = (key, windowKey) => {
// 加载文案根据浏览器语言决定,避免 i18n 还没初始化时硬编码中文。
const getLoadingText = () => {
const lang = ((typeof navigator !== 'undefined' && navigator.language) || 'zh').toLowerCase();
const lang = (
(typeof navigator !== 'undefined' && navigator.language) ||
'zh'
).toLowerCase();
return lang.startsWith('zh') ? '加载中...' : 'Loading...';
};
@@ -47,6 +47,29 @@ import { IconChevronDown, IconChevronUp } from '@/components/ui/icons';
* @param {boolean} withCheckbox 是否启用前缀 Checkbox 来控制激活状态
* @param {boolean} loading 是否处于加载状态
*/
const ConditionalTooltipText = ({ text, containerWidth }) => {
const textRef = useRef(null);
const [isOverflowing, setIsOverflowing] = useState(false);
useEffect(() => {
const el = textRef.current;
if (!el) return;
setIsOverflowing(el.scrollWidth > el.clientWidth);
}, [text, containerWidth]);
const textElement = (
<span ref={textRef} className='sbg-ellipsis'>
{text}
</span>
);
return isOverflowing ? (
<Tooltip content={text}>{textElement}</Tooltip>
) : (
textElement
);
};
const SelectableButtonGroup = ({
title,
items = [],
@@ -63,29 +86,6 @@ const SelectableButtonGroup = ({
const [skeletonCount] = useState(12);
const [containerRef, containerWidth] = useContainerWidth();
const ConditionalTooltipText = ({ text }) => {
const textRef = useRef(null);
const [isOverflowing, setIsOverflowing] = useState(false);
useEffect(() => {
const el = textRef.current;
if (!el) return;
setIsOverflowing(el.scrollWidth > el.clientWidth);
}, [text, containerWidth]);
const textElement = (
<span ref={textRef} className='sbg-ellipsis'>
{text}
</span>
);
return isOverflowing ? (
<Tooltip content={text}>{textElement}</Tooltip>
) : (
textElement
);
};
// 基于容器宽度计算响应式列数和标签显示策略
const getResponsiveConfig = () => {
if (containerWidth <= 280) return { columns: 1, showTags: true }; // 极窄:1列+标签
@@ -207,7 +207,10 @@ const SelectableButtonGroup = ({
>
<div className='sbg-content'>
{item.icon && <span className='sbg-icon'>{item.icon}</span>}
<ConditionalTooltipText text={item.label} />
<ConditionalTooltipText
text={item.label}
containerWidth={containerWidth}
/>
{item.tagCount !== undefined && shouldShowTags && (
<Tag
className='sbg-tag'
@@ -236,7 +239,10 @@ const SelectableButtonGroup = ({
>
<div className='sbg-content'>
{item.icon && <span className='sbg-icon'>{item.icon}</span>}
<ConditionalTooltipText text={item.label} />
<ConditionalTooltipText
text={item.label}
containerWidth={containerWidth}
/>
{item.tagCount !== undefined && shouldShowTags && (
<Tag
className='sbg-tag'
-7
View File
@@ -437,10 +437,3 @@
grid-column: auto;
}
}
.console-overlay .console-detail-header .ant-drawer-header-title {
flex-direction: row-reverse;
}
.console-overlay .console-detail-header .ant-drawer-close {
margin-inline: 12px 0;
}
@@ -150,31 +150,11 @@
grid-template-columns: minmax(0, 1fr);
}
}
.console-model-drawer .prefill-management-header .ant-drawer-header-title {
flex-direction: row-reverse;
}
.console-model-drawer .prefill-management-header .ant-drawer-close {
margin-inline: 12px 0;
}
.console-model-drawer .console-model-editor-header .ant-drawer-header-title,
.console-channel-drawer
.console-channel-editor-header
.ant-drawer-header-title {
flex-direction: row-reverse;
}
.console-model-drawer .console-model-editor-header .ant-drawer-title,
.console-channel-drawer .console-channel-editor-header .ant-drawer-title {
text-align: start;
}
.console-model-drawer .console-model-editor-header .ant-drawer-close,
.console-channel-drawer .console-channel-editor-header .ant-drawer-close {
margin-inline: 12px 0;
}
.console-model-drawer .console-model-tag-presets {
margin-top: 10px;
}
+1 -9
View File
@@ -18,15 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
Card,
Button,
Spin,
Tabs,
TabPane,
Tag,
Empty,
} from '@/components/ui';
import { Card, Button, Spin, Tabs, TabPane, Tag, Empty } from '@/components/ui';
import { Gauge, RefreshCw } from 'lucide-react';
import {
IllustrationConstruction,
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useContext, useEffect } from 'react';
import { getRelativeTime } from '../../helpers';
import { UserContext } from '../../context/User';
@@ -134,9 +135,10 @@ const Dashboard = () => {
);
// ========== Effects ==========
useEffect(() => {
const onMount = useEffectEvent(() => {
initChart();
}, []);
});
useEffect(() => onMount(), [onMount]);
return (
<div className='h-full'>
+10 -2
View File
@@ -106,9 +106,17 @@ const ImageGenerationParams = ({
newParams.n = modelCapabilities.maxImages;
}
return newParams;
return newParams.size === prev.size &&
newParams.quality === prev.quality &&
newParams.n === prev.n
? prev
: newParams;
});
}, [modelInfo]);
}, [
modelCapabilities.sizes,
modelCapabilities.supportsQuality,
modelCapabilities.maxImages,
]);
// 参数更新函数
const updateParam = useCallback(
+5 -3
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import { Layout } from '@/components/ui';
import App from '../../App';
import React, {
@@ -301,9 +302,9 @@ const PageLayout = () => {
setShowGiftModal(true);
}
}
}, [userState?.user?.id]);
}, [userState?.user?.id, userState?.user?.username, userState?.user?.quota]);
useEffect(() => {
const onBootstrap = useEffectEvent(() => {
if (!authBootstrappedRef.current) {
authBootstrappedRef.current = true;
loadUser();
@@ -325,7 +326,8 @@ const PageLayout = () => {
}
}
// 界面语言已由 i18n/bootstrap.js 在渲染前判定,这里不再读取语言缓存
}, [i18n]);
});
useEffect(() => onBootstrap(), [onBootstrap, i18n]);
return (
<Layout
+8 -20
View File
@@ -76,16 +76,16 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
const location = useLocation();
const [routerMapState, setRouterMapState] = useState(routerMap);
const dataExportFlag = localStorage.getItem('enable_data_export');
const drawingFlag = localStorage.getItem('enable_drawing');
const taskFlag = localStorage.getItem('enable_task');
const workspaceItems = useMemo(() => {
const items = [
{
text: t('数据看板'),
itemKey: 'detail',
to: '/detail',
className:
localStorage.getItem('enable_data_export') === 'true'
? ''
: 'tableHiddle',
className: dataExportFlag === 'true' ? '' : 'tableHiddle',
},
{
text: t('密钥管理'),
@@ -101,17 +101,13 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
text: t('绘图日志'),
itemKey: 'midjourney',
to: '/midjourney',
className:
localStorage.getItem('enable_drawing') === 'true'
? ''
: 'tableHiddle',
className: drawingFlag === 'true' ? '' : 'tableHiddle',
},
{
text: t('任务日志'),
itemKey: 'task',
to: '/task',
className:
localStorage.getItem('enable_task') === 'true' ? '' : 'tableHiddle',
className: taskFlag === 'true' ? '' : 'tableHiddle',
},
{
text: t('监控中心'),
@@ -127,13 +123,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
});
return filteredItems;
}, [
localStorage.getItem('enable_data_export'),
localStorage.getItem('enable_drawing'),
localStorage.getItem('enable_task'),
t,
isModuleVisible,
]);
}, [dataExportFlag, drawingFlag, taskFlag, t, isModuleVisible]);
const financeItems = useMemo(() => {
const items = [
@@ -296,8 +286,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
return filteredItems;
}, [
isAdmin(),
isRoot(),
t,
isModuleVisible,
canAccessSetting,
@@ -375,7 +363,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
showError(t('聊天数据解析失败'));
}
}
}, []);
}, [t]);
// 根据当前路径设置选中的菜单项
useEffect(() => {
@@ -17,13 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, {
useState,
useEffect,
useCallback,
useRef,
useMemo,
} from 'react';
import React, { useState, useEffect, useCallback, useRef } from 'react';
import { Empty as AntEmpty, Tag as AntTag } from 'antd';
import { Modal, Table, Typography, Pagination, Toast } from '@/components/ui';
import { API, renderQuota } from '../../helpers';
@@ -161,81 +155,78 @@ export const MembershipHistoryContent = ({ visible, t, inline = false }) => {
};
// 表格列定义(使用 useCallback 的格式化函数作为依赖)
const columns = useMemo(
() => [
{
title: t('方案名称'),
dataIndex: 'plan_name',
key: 'plan_name',
width: 180,
render: (text, record) => (
<div>
<Text>{text || '-'}</Text>
<Text type='tertiary' size='small' className='block'>
{PLAN_TYPE_MAP[record.plan_type] || record.plan_type} ·{' '}
{TIER_MAP[record.tier] || record.tier}
</Text>
</div>
),
const columns = [
{
title: t('方案名称'),
dataIndex: 'plan_name',
key: 'plan_name',
width: 180,
render: (text, record) => (
<div>
<Text>{text || '-'}</Text>
<Text type='tertiary' size='small' className='block'>
{PLAN_TYPE_MAP[record.plan_type] || record.plan_type} ·{' '}
{TIER_MAP[record.tier] || record.tier}
</Text>
</div>
),
},
{
title: t('每日额度'),
dataIndex: 'daily_quota',
key: 'daily_quota',
width: 120,
render: (quota) => renderQuota(quota),
},
{
title: t('天数'),
key: 'duration_days',
width: 80,
align: 'center',
render: (_, record) => {
// duration_days 不在 UserMembership 模型中,需从 end_date - start_date 计算
const days =
record.end_date && record.start_date
? Math.round((record.end_date - record.start_date) / 86400)
: '-';
return `${days} ${t('天')}`;
},
{
title: t('每日额度'),
dataIndex: 'daily_quota',
key: 'daily_quota',
width: 120,
render: (quota) => renderQuota(quota),
},
{
title: t('天数'),
key: 'duration_days',
width: 80,
align: 'center',
render: (_, record) => {
// duration_days 不在 UserMembership 模型中,需从 end_date - start_date 计算
const days =
record.end_date && record.start_date
? Math.round((record.end_date - record.start_date) / 86400)
: '-';
return `${days} ${t('天')}`;
},
},
{
title: t('购买价格'),
dataIndex: 'price_paid',
key: 'price_paid',
width: 100,
render: (price) => `¥${price?.toFixed(2) || '0.00'}`,
},
{
title: t('生效日期'),
dataIndex: 'start_date',
key: 'start_date',
width: 110,
render: (date) => formatDate(date),
},
{
title: t('到期日期'),
dataIndex: 'end_date',
key: 'end_date',
width: 110,
render: (date) => formatDate(date),
},
{
title: t('状态'),
key: 'status',
width: 100,
render: (_, record) => renderStatusTag(record),
},
{
title: t('购买时间'),
dataIndex: 'created_at',
key: 'created_at',
width: 140,
render: (time) => formatDateTime(time),
},
],
[t, formatDate, formatDateTime],
);
},
{
title: t('购买价格'),
dataIndex: 'price_paid',
key: 'price_paid',
width: 100,
render: (price) => `¥${price?.toFixed(2) || '0.00'}`,
},
{
title: t('生效日期'),
dataIndex: 'start_date',
key: 'start_date',
width: 110,
render: (date) => formatDate(date),
},
{
title: t('到期日期'),
dataIndex: 'end_date',
key: 'end_date',
width: 110,
render: (date) => formatDate(date),
},
{
title: t('状态'),
key: 'status',
width: 100,
render: (_, record) => renderStatusTag(record),
},
{
title: t('购买时间'),
dataIndex: 'created_at',
key: 'created_at',
width: 140,
render: (time) => formatDateTime(time),
},
];
return (
<div className={inline ? 'rc-member-history' : 'flex flex-col h-full'}>
@@ -17,14 +17,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import {
TextArea,
Typography,
Button,
Switch,
Banner,
} from '@/components/ui';
import { TextArea, Typography, Button, Switch, Banner } from '@/components/ui';
import { Code, Edit, Check, X, AlertTriangle } from 'lucide-react';
import { useTranslation } from 'react-i18next';
@@ -60,12 +55,13 @@ const CustomRequestEditor = ({
]);
// 同步外部传入的customRequestBody到本地状态
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
if (customRequestBody !== localValue) {
setLocalValue(customRequestBody || '');
validateJson(customRequestBody || '');
}
}, [customRequestBody]);
});
useEffect(() => onScopeChange(), [onScopeChange, customRequestBody]);
// 验证JSON格式
const validateJson = (value) => {
+3 -1
View File
@@ -145,7 +145,9 @@ const DebugPanel = ({
<Eye size={16} />
{t('预览请求体')}
{customRequestMode && (
<span className='px-1.5 py-0.5 text-xs bg-orange-100 text-orange-600 rounded-full'>{t('自定义')}</span>
<span className='px-1.5 py-0.5 text-xs bg-orange-100 text-orange-600 rounded-full'>
{t('自定义')}
</span>
)}
</div>
}
+8 -5
View File
@@ -82,10 +82,13 @@ const MessageContent = ({
const now = new Date();
const nextDay = new Date(now);
nextDay.setHours(24, 0, 1, 0);
timerId = window.setTimeout(() => {
setCurrentDateKey(new Date().toDateString());
scheduleNextDateRefresh();
}, Math.max(1000, nextDay.getTime() - now.getTime()));
timerId = window.setTimeout(
() => {
setCurrentDateKey(new Date().toDateString());
scheduleNextDateRefresh();
},
Math.max(1000, nextDay.getTime() - now.getTime()),
);
};
scheduleNextDateRefresh();
@@ -116,7 +119,7 @@ const MessageContent = ({
const messageTimeText = React.useMemo(() => {
if (!messageTime) return '';
const now = new Date();
const now = new Date(currentDateKey);
const sameYear = messageTime.getFullYear() === now.getFullYear();
const sameDay =
sameYear &&
+5 -1
View File
@@ -29,7 +29,11 @@ import {
Zap,
} from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { renderGroupOption, renderModelOption, selectFilter } from '../../helpers';
import {
renderGroupOption,
renderModelOption,
selectFilter,
} from '../../helpers';
import ParameterControl from './ParameterControl';
import ImageUrlInput from './ImageUrlInput';
import ConfigManager from './ConfigManager';
@@ -121,7 +121,9 @@ const ThinkingContent = ({
<Typography.Text
style={{ color: 'white' }}
className='text-xs sm:text-sm font-medium opacity-90'
>{t('思考中')}</Typography.Text>
>
{t('思考中')}
</Typography.Text>
</div>
)}
{(!isThinkingStatus || message.isThinkingComplete) && (
+2 -7
View File
@@ -8,11 +8,7 @@
--q-success: var(--ui-color-success);
--q-danger: var(--ui-color-danger);
--q-warning: var(--ui-color-warning);
--q-tint: color-mix(
in srgb,
var(--ui-color-primary) 6%,
var(--surface-card)
);
--q-tint: color-mix(in srgb, var(--ui-color-primary) 6%, var(--surface-card));
display: flex;
flex-direction: column;
gap: 16px;
@@ -184,8 +180,7 @@
var(--ui-color-warning) 10%,
var(--surface-card)
);
border: 1px solid
color-mix(in srgb, var(--ui-color-warning) 30%, transparent);
border: 1px solid color-mix(in srgb, var(--ui-color-warning) 30%, transparent);
}
.quality-notice[data-tone='info'] {
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useState } from 'react';
import { Card, Spin } from '@/components/ui';
import SettingsChats from '../../pages/Setting/Chat/SettingsChats';
@@ -63,9 +64,10 @@ const ChatsSetting = () => {
}
}
useEffect(() => {
const onMount = useEffectEvent(() => {
onRefresh();
}, []);
});
useEffect(() => onMount(), [onMount]);
return (
<>
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Card, Spin, Modal } from '@/components/ui';
@@ -86,9 +87,10 @@ const DashboardSetting = () => {
}
}
useEffect(() => {
const onMount = useEffectEvent(() => {
onRefresh();
}, []);
});
useEffect(() => onMount(), [onMount]);
// 用于迁移检测的旧键,下个版本会删除
const hasLegacyData = useMemo(() => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useRef, useState } from 'react';
import {
Banner,
@@ -362,9 +363,10 @@ export default function DataSecuritySetting() {
loadOrgConfigs();
};
useEffect(() => {
const onMount = useEffectEvent(() => {
reloadAll();
}, []);
});
useEffect(() => onMount(), [onMount]);
const onSave = async () => {
if (!configLoaded) {
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useState } from 'react';
import { Card, Spin } from '@/components/ui';
import SettingsDrawing from '../../pages/Setting/Drawing/SettingsDrawing';
@@ -65,9 +66,10 @@ const DrawingSetting = () => {
}
}
useEffect(() => {
const onMount = useEffectEvent(() => {
onRefresh();
}, []);
});
useEffect(() => onMount(), [onMount]);
return (
<>
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useState } from 'react';
import { Card, Spin } from '@/components/ui';
@@ -98,9 +99,10 @@ const ModelSetting = () => {
}
}
useEffect(() => {
const onMount = useEffectEvent(() => {
onRefresh();
}, []);
});
useEffect(() => onMount(), [onMount]);
return (
<>
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useContext, useEffect, useRef, useState } from 'react';
import { Button, Col, Form, Row, Modal, Space, Card } from '@/components/ui';
import { API, showError, showSuccess, timestamp2string } from '../../helpers';
@@ -354,9 +355,10 @@ const OtherSetting = () => {
}
};
useEffect(() => {
const onMount = useEffectEvent(() => {
getOptions();
}, []);
});
useEffect(() => onMount(), [onMount]);
// 打开官网(可配置,未配置则按钮不显示)
const officialWebsite = (statusState?.status?.official_website || '').trim();
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useState } from 'react';
import { Card, Spin } from '@/components/ui';
import SettingsGeneralPayment from '../../pages/Setting/Payment/SettingsGeneralPayment';
@@ -263,9 +264,10 @@ const PaymentSetting = () => {
}
}
useEffect(() => {
const onMount = useEffectEvent(() => {
onRefresh();
}, []);
});
useEffect(() => onMount(), [onMount]);
return (
<>
+10 -4
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import { writeClipboardText } from '../../helpers/clipboard';
import React, { useContext, useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
@@ -123,7 +124,7 @@ const PersonalSetting = () => {
recordIpLog: false,
});
useEffect(() => {
const onMount = useEffectEvent(() => {
let saved = localStorage.getItem('status');
if (saved) {
const parsed = JSON.parse(saved);
@@ -161,7 +162,8 @@ const PersonalSetting = () => {
isPasskeySupported()
.then(setPasskeySupported)
.catch(() => setPasskeySupported(false));
}, []);
});
useEffect(() => onMount(), [onMount]);
useEffect(() => {
let countdownInterval = null;
@@ -176,7 +178,7 @@ const PersonalSetting = () => {
return () => clearInterval(countdownInterval);
}, [disableButton, countdown]);
useEffect(() => {
const onScopeChange2 = useEffectEvent(() => {
if (userState?.user?.setting) {
const settings = parseUserSetting(userState.user.setting);
setNotificationSettings({
@@ -214,7 +216,11 @@ const PersonalSetting = () => {
prev.avatarPreset || getDefaultAvatarPresetId(userState.user),
}));
}
}, [userState?.user?.id, userState?.user?.setting]);
});
useEffect(
() => onScopeChange2(),
[onScopeChange2, userState?.user?.id, userState?.user?.setting],
);
const handleInputChange = (name, value) => {
setInputs((inputs) => ({ ...inputs, [name]: value }));
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useState } from 'react';
import { Card, Spin } from '@/components/ui';
@@ -70,9 +71,10 @@ const RateLimitSetting = () => {
}
}
useEffect(() => {
const onMount = useEffectEvent(() => {
onRefresh();
}, []);
});
useEffect(() => onMount(), [onMount]);
return (
<>
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -71,9 +72,10 @@ const TutorialVideoSetting = () => {
}
};
useEffect(() => {
const onMount = useEffectEvent(() => {
loadVideos();
}, []);
});
useEffect(() => onMount(), [onMount]);
// 格式化时长
const formatDuration = (seconds) => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import { writeClipboardText } from '../../../../helpers/clipboard';
import { API, showError, showSuccess, showWarning } from '../../../../helpers';
import {
@@ -78,9 +79,10 @@ const TwoFASetting = ({ t }) => {
}
};
useEffect(() => {
const onMount = useEffectEvent(() => {
fetchStatus();
}, []);
});
useEffect(() => onMount(), [onMount]);
// 初始化2FA设置
const handleSetup2FA = async () => {
@@ -18,14 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
Avatar,
Card,
Tag,
Divider,
Typography,
Badge,
} from '@/components/ui';
import { Avatar, Card, Tag, Divider, Typography, Badge } from '@/components/ui';
import {
isRoot,
isAdmin,
+4 -2
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useRef } from 'react';
import { Card, Divider, Steps, Form } from '@/components/ui';
import { API, showError, showNotice } from '../../helpers';
@@ -76,9 +77,10 @@ const SetupWizard = () => {
},
];
useEffect(() => {
const onMount = useEffectEvent(() => {
fetchSetupStatus();
}, []);
});
useEffect(() => onMount(), [onMount]);
const fetchSetupStatus = async () => {
try {
@@ -60,7 +60,6 @@ const ChannelsTable = (channelsData) => {
setCurrentMultiKeyChannel,
// Auto-ban exclusion
isChannelExcluded,
excludedChannels,
autoBanExclusionFilter,
// Daily quota info
dailyQuotaInfo,
@@ -127,7 +126,7 @@ const ChannelsTable = (channelsData) => {
return channel;
})
.filter(Boolean);
}, [channels, autoBanExclusionFilter, isChannelExcluded, excludedChannels]);
}, [channels, autoBanExclusionFilter, isChannelExcluded]);
// Get all columns
const allColumns = useMemo(() => {
@@ -175,7 +174,6 @@ const ChannelsTable = (channelsData) => {
setShowMultiKeyManageModal,
setCurrentMultiKeyChannel,
isChannelExcluded,
excludedChannels,
dailyQuotaInfo,
]);
@@ -184,9 +182,7 @@ const ChannelsTable = (channelsData) => {
return allColumns.filter((column) => visibleColumns[column.key]);
};
const visibleColumnsList = useMemo(() => {
return getVisibleColumns();
}, [visibleColumns, allColumns]);
const visibleColumnsList = getVisibleColumns();
const tableColumns = useMemo(() => {
const sortableColumns = visibleColumnsList.map((column) =>
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import '../../../console/module-alignment.css';
import React, { useEffect, useState, useRef, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -964,7 +965,7 @@ const EditChannelModal = (props) => {
setModelOptions(optionsWithIcon);
}, [originModelOptions, inputs.models, t]);
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
fetchModels().then();
fetchGroups().then();
if (!isEdit) {
@@ -977,7 +978,8 @@ const EditChannelModal = (props) => {
setBasicModels(localModels);
setInputs((inputs) => ({ ...inputs, models: localModels }));
}
}, [props.editingChannel.id]);
});
useEffect(() => onScopeChange(), [onScopeChange, props.editingChannel.id]);
useEffect(() => {
if (formApiRef.current) {
@@ -985,7 +987,7 @@ const EditChannelModal = (props) => {
}
}, [inputs]);
useEffect(() => {
const onVisibilityChange2 = useEffectEvent(() => {
if (props.visible) {
if (isEdit) {
loadChannel();
@@ -1004,7 +1006,11 @@ const EditChannelModal = (props) => {
// 关闭后作废在途的兜底数据请求
fallbackLoadSeqRef.current += 1;
}
}, [props.visible, channelId]);
});
useEffect(
() => onVisibilityChange2(),
[onVisibilityChange2, props.visible, channelId],
);
useEffect(() => {
if (!isEdit) {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useEffect, useRef } from 'react';
import {
API,
@@ -270,7 +271,7 @@ const EditTagModal = (props) => {
setModelOptions(localModelOptions);
}, [originModelOptions, inputs.models]);
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
const fetchTagModels = async () => {
if (!tag) return;
setLoading(true);
@@ -305,7 +306,8 @@ const EditTagModal = (props) => {
tag: tag,
new_tag: tag,
});
}, [visible, tag]);
});
useEffect(() => onVisibilityChange(), [onVisibilityChange, visible, tag]);
useEffect(() => {
if (formApiRef.current) {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -288,12 +289,16 @@ const MultiKeyManageModal = ({ visible, onCancel, channel, onRefresh }) => {
};
// Effect to load data when modal opens
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible && channel?.id) {
setCurrentPage(1); // Reset to first page when opening
loadKeyStatus(1, pageSize);
}
}, [visible, channel?.id]);
});
useEffect(
() => onVisibilityChange(),
[onVisibilityChange, visible, channel?.id],
);
// Reset pagination when modal closes
useEffect(() => {
@@ -130,7 +130,9 @@ function renderType(type, t) {
);
case 'UPLOAD':
return (
<Tag color='blue' shape='circle' prefixIcon={<Upload size={14} />}>{t('上传文件')}</Tag>
<Tag color='blue' shape='circle' prefixIcon={<Upload size={14} />}>
{t('上传文件')}
</Tag>
);
case 'SHORTEN':
return (
@@ -404,9 +406,7 @@ export const getMjLogsColumns = ({
{
<Progress
stroke={
record.status === 'FAILURE'
? 'var(--ui-color-warning)'
: null
record.status === 'FAILURE' ? 'var(--ui-color-warning)' : null
}
percent={text ? parseInt(text.replace('%', '')) : 0}
showInfo={true}
+1 -3
View File
@@ -58,9 +58,7 @@ const MjLogsTable = (mjLogsData) => {
return allColumns.filter((column) => visibleColumns[column.key]);
};
const visibleColumnsList = useMemo(() => {
return getVisibleColumns();
}, [visibleColumns, allColumns]);
const visibleColumnsList = getVisibleColumns();
return (
<CardTable
@@ -17,16 +17,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import {
Card,
Row,
Col,
Typography,
Tag,
Spin,
Empty,
} from '@/components/ui';
import { Card, Row, Col, Typography, Tag, Spin, Empty } from '@/components/ui';
import { API, showError } from '../../../helpers';
import { MODEL_CATEGORY_NAMES } from '../../../constants';
@@ -53,9 +46,10 @@ const ModelsCategoryStats = ({ t }) => {
setLoading(false);
};
useEffect(() => {
const onMount = useEffectEvent(() => {
loadStats();
}, []);
});
useEffect(() => onMount(), [onMount]);
const getCategoryColor = (category) => {
const colorMap = {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import { Modal, Select, Typography, Spin } from '@/components/ui';
import { API, showError } from '../../../../helpers';
@@ -66,11 +67,12 @@ const BatchCategoryModal = ({
};
// 当弹窗打开时加载分类
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible) {
loadCategories();
}
}, [visible]);
});
useEffect(() => onVisibilityChange(), [onVisibilityChange, visible]);
const handleConfirm = async () => {
if (selectedCategories.length === 0) return;
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import '../../../console/module-alignment.css';
import React, { useState, useEffect, useRef } from 'react';
import JSONEditor from '../../../common/ui/JSONEditor';
@@ -228,7 +229,7 @@ const EditModelModal = (props) => {
setLoading(false);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
if (formApiRef.current) {
if (!isEdit) {
formApiRef.current.setValues({
@@ -237,9 +238,13 @@ const EditModelModal = (props) => {
});
}
}
}, [props.editingModel?.id, props.editingModel?.model_name]);
});
useEffect(
() => onScopeChange(),
[onScopeChange, props.editingModel?.id, props.editingModel?.model_name],
);
useEffect(() => {
const onVisibilityChange2 = useEffectEvent(() => {
if (props.visiable) {
if (isEdit) {
loadModel();
@@ -252,7 +257,16 @@ const EditModelModal = (props) => {
} else {
formApiRef.current?.reset();
}
}, [props.visiable, props.editingModel?.id, props.editingModel?.model_name]);
});
useEffect(
() => onVisibilityChange2(),
[
onVisibilityChange2,
props.visiable,
props.editingModel?.id,
props.editingModel?.model_name,
],
);
const submit = async (values) => {
setLoading(true);
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useRef, useEffect } from 'react';
import { Modal, Form, Col, Row } from '@/components/ui';
import { API, showError, showSuccess } from '../../../../helpers';
@@ -67,7 +68,7 @@ const EditVendorModal = ({ visible, handleClose, refresh, editingVendor }) => {
setLoading(false);
};
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible) {
if (isEdit) {
loadVendor();
@@ -77,7 +78,11 @@ const EditVendorModal = ({ visible, handleClose, refresh, editingVendor }) => {
} else {
formApiRef.current?.reset();
}
}, [visible, editingVendor?.id]);
});
useEffect(
() => onVisibilityChange(),
[onVisibilityChange, visible, editingVendor?.id],
);
const submit = async (values) => {
setLoading(true);
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useEffect, useState } from 'react';
import {
Modal,
@@ -59,7 +60,7 @@ const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
setLoading(false);
};
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible) {
fetchMissing();
setSearchKeyword('');
@@ -67,7 +68,8 @@ const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
} else {
setMissingModels([]);
}
}, [visible]);
});
useEffect(() => onVisibilityChange(), [onVisibilityChange, visible]);
// 过滤和分页逻辑
const filteredModels = missingModels.filter((model) =>
@@ -238,14 +238,7 @@ const UpstreamConflictModal = ({
});
return [...base, ...cols.filter(Boolean)];
}, [
t,
selections,
filteredDataSource,
getHeaderState,
applyHeaderChange,
toggleField,
]);
}, [t, selections, getHeaderState, applyHeaderChange, toggleField]);
const pagedDataSource = useMemo(() => {
const start = (currentPage - 1) * paginationSize;
@@ -57,19 +57,7 @@ const RedemptionsTable = (redemptionsData) => {
};
// Get all columns
const columns = useMemo(() => {
return getRedemptionsColumns({
t,
manageRedemption,
copyText,
setEditingRedemption,
setShowEdit,
refresh,
redemptions,
activePage,
showDeleteRedemptionModal,
});
}, [
const columns = getRedemptionsColumns({
t,
manageRedemption,
copyText,
@@ -79,7 +67,7 @@ const RedemptionsTable = (redemptionsData) => {
redemptions,
activePage,
showDeleteRedemptionModal,
]);
});
// Handle compact mode by removing fixed positioning
const tableColumns = useMemo(() => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -87,7 +88,7 @@ const EditRedemptionModal = (props) => {
setLoading(false);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
if (formApiRef.current) {
if (isEdit) {
loadRedemption();
@@ -95,7 +96,8 @@ const EditRedemptionModal = (props) => {
formApiRef.current.setValues(getInitValues());
}
}
}, [props.editingRedemption.id]);
});
useEffect(() => onScopeChange(), [onScopeChange, props.editingRedemption.id]);
const submit = async (values) => {
let name = values.name;
@@ -72,9 +72,7 @@ const TaskLogsTable = (taskLogsData) => {
return allColumns.filter((column) => visibleColumns[column.key]);
};
const visibleColumnsList = useMemo(() => {
return getVisibleColumns();
}, [visibleColumns, allColumns]);
const visibleColumnsList = getVisibleColumns();
const tableColumns = useMemo(() => {
return compactMode
+17 -17
View File
@@ -17,14 +17,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import React, { useEffect, useRef, useState } from 'react';
import {
Notification,
Button,
Space,
Toast,
Select,
} from '@/components/ui';
import { Notification, Button, Space, Toast, Select } from '@/components/ui';
import {
API,
showError,
@@ -51,14 +46,18 @@ function TokensPage({ labelReplace } = {}) {
// Create a wrapped translation function that replaces labels if needed
const originalT = tokensData.t;
const t = labelReplace
? (key, options) => {
const result = originalT(key, options);
return typeof result === 'string'
? result.replace(/密钥/g, labelReplace)
: result;
}
: originalT;
const t = React.useMemo(
() =>
labelReplace
? (key, options) => {
const result = originalT(key, options);
return typeof result === 'string'
? result.replace(/密钥/g, labelReplace)
: result;
}
: originalT,
[originalT, labelReplace],
);
const latestRef = useRef({
tokens: [],
@@ -256,7 +255,7 @@ function TokensPage({ labelReplace } = {}) {
};
// Show notification when Fluent container is available
useEffect(() => {
const onMount = useEffectEvent(() => {
const onAppeared = () => {
openFluentNotification();
};
@@ -271,7 +270,8 @@ function TokensPage({ labelReplace } = {}) {
window.removeEventListener('fluent-container:appeared', onAppeared);
window.removeEventListener('fluent-container:removed', onRemoved);
};
}, []);
});
useEffect(() => onMount(), [onMount]);
// When modelOptions or language changes while the notice is open, refresh the content
useEffect(() => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useContext, useRef } from 'react';
import {
API,
@@ -277,7 +278,7 @@ const EditTokenModal = (props) => {
setLoading(false);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
if (formApiRef.current) {
if (!isEdit) {
formApiRef.current.setValues(getInitValues());
@@ -286,9 +287,10 @@ const EditTokenModal = (props) => {
loadModels();
loadGroups();
loadSkillOptions();
}, [props.editingToken.id]);
});
useEffect(() => onScopeChange(), [onScopeChange, props.editingToken.id]);
useEffect(() => {
const onVisibilityChange2 = useEffectEvent(() => {
if (props.visiable) {
if (isEdit) {
loadToken();
@@ -308,7 +310,11 @@ const EditTokenModal = (props) => {
setNeverExpire(true);
setExpireDate(null);
}
}, [props.visiable, props.editingToken.id]);
});
useEffect(
() => onVisibilityChange2(),
[onVisibilityChange2, props.visiable, props.editingToken.id],
);
const generateRandomSuffix = () => {
const characters =
+9 -22
View File
@@ -125,31 +125,18 @@ const UsersTable = (usersData) => {
};
// Get all columns
const columns = useMemo(() => {
return getUsersColumns({
t,
setEditingUser,
setShowEditUser,
showPromoteModal: showPromoteUserModal,
showDemoteModal: showDemoteUserModal,
showEnableDisableModal: showEnableDisableUserModal,
showDeleteModal: showDeleteUserModal,
showResetPasskeyModal: showResetPasskeyUserModal,
showResetTwoFAModal: showResetTwoFAUserModal,
showInvitedUsersModal: showInvitedUsersUserModal,
});
}, [
const columns = getUsersColumns({
t,
setEditingUser,
setShowEditUser,
showPromoteUserModal,
showDemoteUserModal,
showEnableDisableUserModal,
showDeleteUserModal,
showResetPasskeyUserModal,
showResetTwoFAUserModal,
showInvitedUsersUserModal,
]);
showPromoteModal: showPromoteUserModal,
showDemoteModal: showDemoteUserModal,
showEnableDisableModal: showEnableDisableUserModal,
showDeleteModal: showDeleteUserModal,
showResetPasskeyModal: showResetPasskeyUserModal,
showResetTwoFAModal: showResetTwoFAUserModal,
showInvitedUsersModal: showInvitedUsersUserModal,
});
// Handle compact mode by removing fixed positioning
const tableColumns = useMemo(() => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { API, showError, showSuccess, renderQuota } from '../../../../helpers';
@@ -122,13 +123,14 @@ const EditUserModal = (props) => {
setLoading(false);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
loadUser();
if (userId) {
fetchGroups();
fetchLevels();
}
}, [props.editingUser.id]);
});
useEffect(() => onScopeChange(), [onScopeChange, props.editingUser.id]);
/* ----------------------- submit ----------------------- */
const submit = async (values) => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import { Modal, Table, Tag, Spin } from '@/components/ui';
import { API, renderQuota, renderNumber, showError } from '../../../../helpers';
@@ -27,11 +28,12 @@ const InvitedUsersModal = ({ visible, onCancel, user, t }) => {
const [loading, setLoading] = useState(false);
const [total, setTotal] = useState(0);
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible && user) {
fetchInvitedUsers();
}
}, [visible, user]);
});
useEffect(() => onVisibilityChange(), [onVisibilityChange, visible, user]);
const fetchInvitedUsers = async () => {
if (!user?.id) return;
+1 -6
View File
@@ -28,12 +28,7 @@ import {
Spin,
Tooltip,
} from '@/components/ui';
import {
CreditCard,
Coins,
Wallet,
Receipt,
} from 'lucide-react';
import { CreditCard, Coins, Wallet, Receipt } from 'lucide-react';
import {
AlipayBrandIcon,
WechatBrandIcon,
+7 -4
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useContext, useRef } from 'react';
import {
API,
@@ -467,12 +468,13 @@ const TopUp = () => {
else showError(t('复制失败,请手动复制'));
};
useEffect(() => {
const onMount = useEffectEvent(() => {
if (!userState?.user?.id) {
getUserQuota().then();
}
setTransferAmount(getQuotaPerUnit());
}, []);
});
useEffect(() => onMount(), [onMount]);
useEffect(() => {
if (affFetchedRef.current) return;
@@ -481,9 +483,10 @@ const TopUp = () => {
}, []);
// 在 statusState 可用时获取充值信息
useEffect(() => {
const onMount2 = useEffectEvent(() => {
getTopupInfo().then();
}, []);
});
useEffect(() => onMount2(), [onMount2]);
useEffect(() => {
if (statusState?.status) {
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import React, { useState, useEffect, useMemo } from 'react';
import {
Modal,
@@ -112,11 +113,15 @@ const TopupHistoryModal = ({ visible, onCancel, t }) => {
}
};
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible) {
loadTopups(page, pageSize);
}
}, [visible, page, pageSize, keyword]);
});
useEffect(
() => onVisibilityChange(),
[onVisibilityChange, visible, page, pageSize, keyword],
);
const handlePageChange = (currentPage) => {
setPage(currentPage);
@@ -187,7 +192,7 @@ const TopupHistoryModal = ({ visible, onCancel, t }) => {
// 检查是否为管理员
const userIsAdmin = useMemo(() => isAdmin(), []);
const columns = useMemo(() => {
const columns = (() => {
const baseColumns = [
{
title: t('订单号'),
@@ -273,7 +278,7 @@ const TopupHistoryModal = ({ visible, onCancel, t }) => {
});
return baseColumns;
}, [t, userIsAdmin]);
})();
return (
<Modal
+8 -10
View File
@@ -17,15 +17,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import React, { useState, useEffect, useRef } from 'react';
import {
Modal,
Button,
Spin,
Typography,
Space,
Toast,
} from '@/components/ui';
import { Modal, Button, Spin, Typography, Space, Toast } from '@/components/ui';
import { IconRefresh, IconClose } from '@/components/ui/icons';
import { useTranslation } from 'react-i18next';
import QRCode from 'qrcode';
@@ -46,7 +40,7 @@ const WechatQRModal = ({ visible, onClose, orderData, pollFn }) => {
const errorCountRef = useRef(0); // 错误计数
// 生成二维码
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible && orderData && orderData.code_url) {
// 【Bug#5修复】重置过期状态,避免上一个过期订单影响新订单的展示
setExpired(false);
@@ -60,7 +54,11 @@ const WechatQRModal = ({ visible, onClose, orderData, pollFn }) => {
stopPolling();
stopExpireTimer();
};
}, [visible, orderData]);
});
useEffect(
() => onVisibilityChange(),
[onVisibilityChange, visible, orderData],
);
const generateQRCode = async (url) => {
try {