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
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 LobeHub
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+28
View File
@@ -0,0 +1,28 @@
# Audited brand icons
The generated `lobehub.js` contains the 30 brands supported by `LobeHubIcon`
and their existing Mono, Color, Text, Avatar and Combine variants, where provided
upstream. SVG paths and brand metadata come from **@lobehub/icons 1.97.2**
([upstream](https://github.com/lobehub/lobe-icons)); see the original MIT `LICENSE`.
`manifest.json` records the version, brand list and each generated file's SHA-256.
`primitives.js` exposes only Mono/Color SVGs for Home and the rendering helpers;
`shared-*.js` shares their SVG implementations with the lazily loaded variants.
Do not import `lobehub.js` from those eager entry points.
This is a generated visual asset, not a second UI framework. Its only runtime
imports are React and three local adapters under `components/common/brand-icons`.
Avatar containers use Ant Design. Theme-aware variants read the existing app
theme. No Lobe UI, Radix, Floating UI, antd-style or layout-kit runtime is needed.
Do not edit generated paths or metadata manually. To reproduce:
1. Download the pinned source with `npm pack @lobehub/icons@1.97.2 --pack-destination <temporary-directory>`.
2. Extract that tarball into the temporary directory using `tar -xf <tarball> -C <temporary-directory>`.
3. Run `npm run vendor:icons -- <temporary-directory>/package` from the repository root.
4. Run `npm run check:ui`, then compare all supported variants in light and dark themes.
The generator rejects unexpected external dependencies. Updating the upstream
version requires reviewing the generator pin, license, brand APIs and output.
Keep source packages and browser evidence outside tracked source. The normal
application install and build use the checked-in assets and never download
the upstream package.
File diff suppressed because one or more lines are too long
+43
View File
@@ -0,0 +1,43 @@
{
"source": "@lobehub/icons",
"version": "1.97.2",
"license": "MIT",
"brands": [
"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"
],
"moduleCount": 204,
"files": {
"lobehub.js": "e048c7076a0c5a3a10508aa19a946877b0b65c497f1f8635d1ad5983b4dc065d",
"primitives.js": "cbab18ff82b8613288089b0242458e44183c99aa417c906e4bc1453fb62a649b",
"shared-2YS4Y76I.js": "3a395caca1c4d9d75756a2e897a6e71333d1fde2dd75d5234edfc5c898ab7d05"
}
}
+105
View File
@@ -0,0 +1,105 @@
// Generated from @lobehub/icons@1.97.2. See LICENSE and README.md.
import {
Color_default,
Color_default10,
Color_default11,
Color_default12,
Color_default13,
Color_default14,
Color_default15,
Color_default16,
Color_default17,
Color_default18,
Color_default19,
Color_default2,
Color_default20,
Color_default3,
Color_default4,
Color_default5,
Color_default6,
Color_default7,
Color_default8,
Color_default9,
Mono_default,
Mono_default10,
Mono_default11,
Mono_default12,
Mono_default13,
Mono_default14,
Mono_default15,
Mono_default16,
Mono_default17,
Mono_default18,
Mono_default19,
Mono_default2,
Mono_default20,
Mono_default21,
Mono_default22,
Mono_default23,
Mono_default24,
Mono_default25,
Mono_default26,
Mono_default27,
Mono_default28,
Mono_default29,
Mono_default3,
Mono_default30,
Mono_default4,
Mono_default5,
Mono_default6,
Mono_default7,
Mono_default8,
Mono_default9,
} from './shared-2YS4Y76I.js';
export {
Color_default12 as Ai360Color,
Mono_default15 as Ai360Mono,
Color_default as ClaudeColor,
Mono_default2 as ClaudeMono,
Color_default11 as CloudflareColor,
Mono_default14 as CloudflareMono,
Color_default10 as CohereColor,
Mono_default13 as CohereMono,
Mono_default26 as CozeMono,
Color_default5 as DeepSeekColor,
Mono_default7 as DeepSeekMono,
Color_default17 as DifyColor,
Mono_default25 as DifyMono,
Color_default15 as DoubaoColor,
Mono_default21 as DoubaoMono,
Color_default2 as GeminiColor,
Mono_default3 as GeminiMono,
Color_default9 as HunyuanColor,
Mono_default12 as HunyuanMono,
Mono_default17 as JinaMono,
Color_default19 as KlingColor,
Mono_default28 as KlingMono,
Mono_default11 as MidjourneyMono,
Color_default6 as MinimaxColor,
Mono_default8 as MinimaxMono,
Color_default14 as MistralColor,
Mono_default18 as MistralMono,
Mono_default4 as MoonshotMono,
Mono_default20 as OllamaMono,
Mono_default as OpenAIMono,
Mono_default24 as OpenRouterMono,
Color_default20 as PerplexityColor,
Mono_default29 as PerplexityMono,
Color_default4 as QwenColor,
Mono_default6 as QwenMono,
Mono_default30 as ReplicateMono,
Color_default18 as SiliconCloudColor,
Mono_default27 as SiliconCloudMono,
Color_default8 as SparkColor,
Mono_default10 as SparkMono,
Mono_default22 as SunoMono,
Color_default7 as WenxinColor,
Mono_default9 as WenxinMono,
Mono_default19 as XAIMono,
Color_default16 as XinferenceColor,
Mono_default23 as XinferenceMono,
Color_default13 as YiColor,
Mono_default16 as YiMono,
Color_default3 as ZhipuColor,
Mono_default5 as ZhipuMono,
};
File diff suppressed because it is too large Load Diff
+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 {
+1 -5
View File
@@ -16,11 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, {
createContext,
useReducer,
useCallback,
} from 'react';
import React, { createContext, useReducer, useCallback } from 'react';
import { reducer, initialState } from './reducer';
import { API } from '../../helpers/api';
+5 -1
View File
@@ -43,7 +43,11 @@ export const RESERVED_LOGIN_NAMES = [
/** 是否命中保留名(大小写不敏感、去空格,与后端同口径)。 */
export function isReservedLoginName(name) {
return RESERVED_LOGIN_NAMES.includes(String(name || '').trim().toLowerCase());
return RESERVED_LOGIN_NAMES.includes(
String(name || '')
.trim()
.toLowerCase(),
);
}
/**
+32 -30
View File
@@ -17,6 +17,38 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import {
OpenAIMono as OpenAI,
ClaudeColor as Claude,
GeminiColor as Gemini,
MoonshotMono as Moonshot,
ZhipuColor as Zhipu,
QwenColor as Qwen,
DeepSeekColor as DeepSeek,
MinimaxColor as Minimax,
WenxinColor as Wenxin,
SparkColor as Spark,
MidjourneyMono as Midjourney,
HunyuanColor as Hunyuan,
CohereColor as Cohere,
CloudflareColor as Cloudflare,
Ai360Color as Ai360,
YiColor as Yi,
JinaMono as Jina,
MistralColor as Mistral,
XAIMono as XAI,
OllamaMono as Ollama,
DoubaoColor as Doubao,
SunoMono as Suno,
XinferenceColor as Xinference,
OpenRouterMono as OpenRouter,
DifyColor as Dify,
CozeMono as Coze,
SiliconCloudColor as SiliconCloud,
KlingColor as Kling,
PerplexityColor as Perplexity,
ReplicateMono as Replicate,
} from '@/assets/brand-icons/primitives';
import React, { lazy, Suspense } from 'react';
import i18next from 'i18next';
// React 18-compatible LobeHub icons lack these brands; use generic icons.
@@ -24,36 +56,6 @@ import { Lock, Bot as FastGPT, Image as Jimeng } from 'lucide-react';
import { Modal, Tag, Typography } from '@/components/ui';
import { copy, getCurrencySymbol, showSuccess } from './utils';
import { visit } from 'unist-util-visit';
import OpenAI from '@lobehub/icons/es/OpenAI/components/Mono';
import Claude from '@lobehub/icons/es/Claude/components/Color';
import Gemini from '@lobehub/icons/es/Gemini/components/Color';
import Moonshot from '@lobehub/icons/es/Moonshot/components/Mono';
import Zhipu from '@lobehub/icons/es/Zhipu/components/Color';
import Qwen from '@lobehub/icons/es/Qwen/components/Color';
import DeepSeek from '@lobehub/icons/es/DeepSeek/components/Color';
import Minimax from '@lobehub/icons/es/Minimax/components/Color';
import Wenxin from '@lobehub/icons/es/Wenxin/components/Color';
import Spark from '@lobehub/icons/es/Spark/components/Color';
import Midjourney from '@lobehub/icons/es/Midjourney/components/Mono';
import Hunyuan from '@lobehub/icons/es/Hunyuan/components/Color';
import Cohere from '@lobehub/icons/es/Cohere/components/Color';
import Cloudflare from '@lobehub/icons/es/Cloudflare/components/Color';
import Ai360 from '@lobehub/icons/es/Ai360/components/Color';
import Yi from '@lobehub/icons/es/Yi/components/Color';
import Jina from '@lobehub/icons/es/Jina/components/Mono';
import Mistral from '@lobehub/icons/es/Mistral/components/Color';
import XAI from '@lobehub/icons/es/XAI/components/Mono';
import Ollama from '@lobehub/icons/es/Ollama/components/Mono';
import Doubao from '@lobehub/icons/es/Doubao/components/Color';
import Suno from '@lobehub/icons/es/Suno/components/Mono';
import Xinference from '@lobehub/icons/es/Xinference/components/Color';
import OpenRouter from '@lobehub/icons/es/OpenRouter/components/Mono';
import Dify from '@lobehub/icons/es/Dify/components/Color';
import Coze from '@lobehub/icons/es/Coze/components/Mono';
import SiliconCloud from '@lobehub/icons/es/SiliconCloud/components/Color';
import Kling from '@lobehub/icons/es/Kling/components/Color';
import Perplexity from '@lobehub/icons/es/Perplexity/components/Color';
import Replicate from '@lobehub/icons/es/Replicate/components/Mono';
// Full Avatar/Text/Combine variants are loaded only when configured icons render.
const LobeHubIcon = lazy(() => import('../components/common/LobeHubIcon'));
+32 -26
View File
@@ -59,7 +59,9 @@ function parseConfig(jsonString) {
export function setPresetOverrides(jsonString, { persist = true } = {}) {
try {
presetOverrides =
jsonString && typeof jsonString === 'string' ? JSON.parse(jsonString) : {};
jsonString && typeof jsonString === 'string'
? JSON.parse(jsonString)
: {};
if (!presetOverrides || typeof presetOverrides !== 'object') {
presetOverrides = {};
}
@@ -68,10 +70,7 @@ export function setPresetOverrides(jsonString, { persist = true } = {}) {
}
if (!persist) return;
try {
window.localStorage.setItem(
PRESETS_CACHE_KEY,
jsonString || '{}',
);
window.localStorage.setItem(PRESETS_CACHE_KEY, jsonString || '{}');
} catch {
/* ignore */
}
@@ -203,7 +202,10 @@ export function applyTheme(jsonString, { persist = true } = {}) {
doApply(config);
if (!persist) return;
try {
window.localStorage.setItem(CACHE_KEY, jsonString || JSON.stringify(config));
window.localStorage.setItem(
CACHE_KEY,
jsonString || JSON.stringify(config),
);
} catch {
/* ignore */
}
@@ -281,7 +283,12 @@ function doApply(config) {
function cachePresplashCSS() {
try {
const ids = [STYLE_ID_LIGHT, STYLE_ID_DARK, STYLE_ID_CONTROLS_LIGHT, STYLE_ID_CONTROLS_DARK];
const ids = [
STYLE_ID_LIGHT,
STYLE_ID_DARK,
STYLE_ID_CONTROLS_LIGHT,
STYLE_ID_CONTROLS_DARK,
];
const css = ids
.map((id) => {
const el = document.getElementById(id);
@@ -307,37 +314,36 @@ function cachePresplashCSS() {
function buildControlRules(baseHex, isDark, infoHex) {
const base = colord(baseHex);
const info = colord(infoHex || baseHex);
const step = (c, n) =>
isDark ? c.lighten(n).toHex() : c.darken(n).toHex();
const step = (c, n) => (isDark ? c.lighten(n).toHex() : c.darken(n).toHex());
const alphaSoft = (c, a) => c.alpha(a).toRgbString();
// 浅暗模式 light 系列透明度策略略不同(参考 Semi 默认)
const softDefault = isDark ? 0.2 : 0.12;
const softHover = isDark ? 0.3 : 0.16;
const softActive = isDark ? 0.4 : 0.2;
const infoHexNorm = (infoHex || baseHex);
const infoHexNorm = infoHex || baseHex;
return {
/* primary(7 个)—— 跟随 brand-primary */
'ui-color-primary': baseHex,
'ui-color-primary-hover': step(base, 0.05),
'ui-color-primary-active': step(base, 0.1),
'ui-color-primary-disabled': alphaSoft(base, 0.4),
'ui-color-primary': baseHex,
'ui-color-primary-hover': step(base, 0.05),
'ui-color-primary-active': step(base, 0.1),
'ui-color-primary-disabled': alphaSoft(base, 0.4),
'ui-color-primary-light-default': alphaSoft(base, softDefault),
'ui-color-primary-light-hover': alphaSoft(base, softHover),
'ui-color-primary-light-active': alphaSoft(base, softActive),
'ui-color-primary-light-hover': alphaSoft(base, softHover),
'ui-color-primary-light-active': alphaSoft(base, softActive),
/* info(7 个)—— 跟随 accent-blue,保留"信息=蓝"语义 */
'ui-color-info': infoHexNorm,
'ui-color-info-hover': step(info, 0.05),
'ui-color-info-active': step(info, 0.1),
'ui-color-info-disabled': alphaSoft(info, 0.4),
'ui-color-info-light-default': alphaSoft(info, softDefault),
'ui-color-info-light-hover': alphaSoft(info, softHover),
'ui-color-info-light-active': alphaSoft(info, softActive),
'ui-color-info': infoHexNorm,
'ui-color-info-hover': step(info, 0.05),
'ui-color-info-active': step(info, 0.1),
'ui-color-info-disabled': alphaSoft(info, 0.4),
'ui-color-info-light-default': alphaSoft(info, softDefault),
'ui-color-info-light-hover': alphaSoft(info, softHover),
'ui-color-info-light-active': alphaSoft(info, softActive),
/* link(4 个)—— 跟随 brand-primary */
'ui-color-link': baseHex,
'ui-color-link-hover': step(base, 0.05),
'ui-color-link-active': step(base, 0.1),
'ui-color-link': baseHex,
'ui-color-link-hover': step(base, 0.05),
'ui-color-link-active': step(base, 0.1),
'ui-color-link-visited': baseHex,
/* focus-border(1 个) */
'ui-color-focus-border': baseHex,
+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 '../common/useEffectEvent';
import { useState, useEffect, useRef, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -127,7 +128,7 @@ export const useChannelsData = () => {
};
// Initialize from localStorage
useEffect(() => {
const onMount = useEffectEvent(() => {
const localIdSort = localStorage.getItem('id-sort') === 'true';
const localPageSize =
parseInt(localStorage.getItem('page-size')) || ITEMS_PER_PAGE;
@@ -149,7 +150,8 @@ export const useChannelsData = () => {
fetchGroups().then();
fetchExcludedChannels().then();
loadChannelModels().then();
}, []);
});
useEffect(() => onMount(), [onMount]);
// Column visibility management
const getDefaultColumnVisibility = () => {
@@ -175,7 +177,7 @@ export const useChannelsData = () => {
};
// Load saved column preferences
useEffect(() => {
const onMount2 = useEffectEvent(() => {
const savedColumns = localStorage.getItem('channels-table-columns');
if (savedColumns) {
try {
@@ -190,7 +192,8 @@ export const useChannelsData = () => {
} else {
initDefaultColumns();
}
}, []);
});
useEffect(() => onMount2(), [onMount2]);
// Save column preferences
useEffect(() => {
+34
View File
@@ -0,0 +1,34 @@
/*
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 { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
const useCommitEffect =
typeof window === 'undefined' ? useEffect : useLayoutEffect;
// React 18 equivalent for effect events: read the latest committed values without
// making callback identity or draft state restart requests, timers, or form resets.
// Call from effects or their handlers; keep reactive triggers in useEffect's deps.
export function useEffectEvent(callback) {
const callbackRef = useRef(callback);
useCommitEffect(() => {
callbackRef.current = callback;
});
return useCallback((...args) => callbackRef.current(...args), []);
}
+4 -11
View File
@@ -121,9 +121,10 @@ export const useSecureVerification = ({
);
// 执行验证
const apiCall = verificationState.apiCall;
const executeVerification = useCallback(
async (method, code = '') => {
if (!verificationState.apiCall) {
if (!apiCall) {
showError(t('验证配置错误'));
return;
}
@@ -135,7 +136,7 @@ export const useSecureVerification = ({
await SecureVerificationService.verify(method, code);
// 验证成功,调用业务 API(此时中间件会通过)
const result = await verificationState.apiCall();
const result = await apiCall();
// 显示成功消息
if (successMessage) {
@@ -159,15 +160,7 @@ export const useSecureVerification = ({
setVerificationState((prev) => ({ ...prev, loading: false }));
}
},
[
verificationState.apiCall,
successMessage,
onSuccess,
onError,
autoReset,
resetState,
t,
],
[apiCall, successMessage, onSuccess, onError, autoReset, resetState, t],
);
// 设置验证码
+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 './useEffectEvent';
import { useState, useEffect, useMemo, useContext, useRef } from 'react';
import { StatusContext } from '../../context/Status';
import { API } from '../../helpers';
@@ -148,13 +149,14 @@ export const useSidebar = () => {
);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
if (Object.keys(adminConfig).length > 0) {
loadUserConfig();
}
}, [adminConfig]);
});
useEffect(() => onScopeChange(), [onScopeChange, adminConfig]);
useEffect(() => {
const onScopeChange2 = useEffectEvent(() => {
const handleRefresh = (event) => {
if (event?.detail?.sourceId === instanceIdRef.current) {
return;
@@ -175,7 +177,8 @@ export const useSidebar = () => {
handleRefresh,
);
};
}, [adminConfig]);
});
useEffect(() => onScopeChange2(), [onScopeChange2, adminConfig]);
const finalConfig = useMemo(() => {
const result = {};
+4 -4
View File
@@ -92,7 +92,6 @@ export const useDashboardData = (userState, userDispatch, statusState) => {
const [activeUptimeTab, setActiveUptimeTab] = useState('');
// ========== 常量 ==========
const now = new Date();
const isAdminUser = isAdmin();
// ========== Panel enable flags ==========
@@ -116,7 +115,8 @@ export const useDashboardData = (userState, userDispatch, statusState) => {
);
const performanceMetrics = useMemo(() => {
const { start_timestamp, end_timestamp } = inputs;
const start_timestamp = inputs.start_timestamp;
const end_timestamp = inputs.end_timestamp;
const timeDiff =
(Date.parse(end_timestamp) - Date.parse(start_timestamp)) / 60000;
const avgRPM = isNaN(times / timeDiff)
@@ -189,7 +189,7 @@ export const useDashboardData = (userState, userDispatch, statusState) => {
count: 0,
model_name: '无数据',
quota: 0,
created_at: now.getTime() / 1000,
created_at: Date.now() / 1000,
});
}
data.sort((a, b) => a.created_at - b.created_at);
@@ -201,7 +201,7 @@ export const useDashboardData = (userState, userDispatch, statusState) => {
} finally {
setLoading(false);
}
}, [inputs, dataExportDefaultTime, isAdminUser, now]);
}, [inputs, dataExportDefaultTime, isAdminUser]);
const loadTokenUsageData = useCallback(async () => {
setTokenUsageLoading(true);
@@ -35,7 +35,6 @@ export const useDashboardStats = (
consumeQuota,
consumeTokens,
times,
trendData,
performanceMetrics,
navigate,
t,
@@ -138,7 +137,6 @@ export const useDashboardStats = (
userState?.user?.used_quota,
userState?.user?.request_count,
times,
trendData,
performanceMetrics,
tokenUsage,
t,
+6 -7
View File
@@ -167,15 +167,14 @@ const useImageModel = () => {
if (currentModel) {
// 检查当前选择的尺寸是否可用,如果不可用则选择第一个可用尺寸
if (!currentModel.capabilities.sizes.includes(selectedSize)) {
setSelectedSize(currentModel.capabilities.sizes[0]);
}
setSelectedSize((previous) =>
currentModel.capabilities.sizes.includes(previous)
? previous
: currentModel.capabilities.sizes[0],
);
// 如果模型不支持质量选择,确保质量设置为standard
if (
!currentModel.capabilities.supportsQuality &&
selectedQuality !== 'standard'
) {
if (!currentModel.capabilities.supportsQuality) {
setSelectedQuality('standard');
}
}
+23 -19
View File
@@ -99,25 +99,6 @@ const useImageStatus = () => {
);
// 设置成功
const setSuccess = useCallback((message = '') => {
setIsLoading(false);
setLoadingStage(LOADING_STAGES.IDLE);
setError(null);
setProgress(100);
setSuccessMessage(message);
// 如果有成功消息,短暂显示通知
if (message) {
showNotification(message, 'success');
}
}, []);
// 更新进度
const updateProgress = useCallback((newProgress) => {
setProgress(Math.min(Math.max(0, newProgress), 100));
}, []);
// 显示通知
const showNotification = useCallback(
(message, type = 'info', duration = 3000) => {
setNotification({
@@ -135,6 +116,29 @@ const useImageStatus = () => {
[],
);
const setSuccess = useCallback(
(message = '') => {
setIsLoading(false);
setLoadingStage(LOADING_STAGES.IDLE);
setError(null);
setProgress(100);
setSuccessMessage(message);
// 如果有成功消息,短暂显示通知
if (message) {
showNotification(message, 'success');
}
},
[showNotification],
);
// 更新进度
const updateProgress = useCallback((newProgress) => {
setProgress(Math.min(Math.max(0, newProgress), 100));
}, []);
// 显示通知
// 清除通知
const clearNotification = useCallback(() => {
setNotification(null);
+8 -5
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 '../common/useEffectEvent';
import { useState, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { Modal } from '@/components/ui';
@@ -87,7 +88,7 @@ export const useMjLogsData = () => {
const [showColumnSelector, setShowColumnSelector] = useState(false);
// Load saved column preferences from localStorage
useEffect(() => {
const onMount = useEffectEvent(() => {
const savedColumns = localStorage.getItem(STORAGE_KEY);
if (savedColumns) {
try {
@@ -108,7 +109,8 @@ export const useMjLogsData = () => {
} else {
initDefaultColumns();
}
}, []);
});
useEffect(() => onMount(), [onMount]);
// Check banner notification
useEffect(() => {
@@ -173,7 +175,7 @@ export const useMjLogsData = () => {
if (Object.keys(visibleColumns).length > 0) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(visibleColumns));
}
}, [visibleColumns]);
}, [visibleColumns, STORAGE_KEY]);
// Get form values helper function
const getFormValues = () => {
@@ -283,12 +285,13 @@ export const useMjLogsData = () => {
};
// Initialize data
useEffect(() => {
const onMount2 = useEffectEvent(() => {
const localPageSize =
parseInt(localStorage.getItem('mj-page-size')) || ITEMS_PER_PAGE;
setPageSize(localPageSize);
loadLogs(1, localPageSize).then();
}, []);
});
useEffect(() => onMount2(), [onMount2]);
return {
// Basic state
@@ -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 '../common/useEffectEvent';
import { useState, useEffect, useContext, useRef, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -351,9 +352,10 @@ export const useModelPricingData = () => {
}, 300);
};
useEffect(() => {
const onMount = useEffectEvent(() => {
refresh().then();
}, []);
});
useEffect(() => onMount(), [onMount]);
// 当筛选条件变化时重置到第一页
useEffect(() => {
@@ -17,7 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useMemo } from 'react';
import { useCallback, useMemo } from 'react';
// 工具函数:将 tags 字符串转为小写去重数组
const normalizeTags = (tags = '') =>
@@ -48,120 +48,93 @@ export const usePricingFilterCounts = ({
* @param {Array<string>} ignore 需要忽略的过滤条件 key
* @returns {boolean}
*/
const matchesFilters = (model, ignore = []) => {
// 分组
if (!ignore.includes('group') && filterGroup !== 'all') {
if (!model.enable_groups || !model.enable_groups.includes(filterGroup))
return false;
}
// 计费类型
if (!ignore.includes('quota') && filterQuotaType !== 'all') {
if (model.quota_type !== filterQuotaType) return false;
}
// 端点类型
if (!ignore.includes('endpoint') && filterEndpointType !== 'all') {
if (
!model.supported_endpoint_types ||
!model.supported_endpoint_types.includes(filterEndpointType)
)
return false;
}
// 供应商
if (!ignore.includes('vendor') && filterVendor !== 'all') {
if (filterVendor === 'unknown') {
if (model.vendor_name) return false;
} else if (model.vendor_name !== filterVendor) {
return false;
const matchesFilters = useCallback(
(model, ignore = []) => {
// 分组
if (!ignore.includes('group') && filterGroup !== 'all') {
if (!model.enable_groups || !model.enable_groups.includes(filterGroup))
return false;
}
}
// 标签
if (!ignore.includes('tag') && filterTag !== 'all') {
const tagsArr = normalizeTags(model.tags);
if (!tagsArr.includes(filterTag.toLowerCase())) return false;
}
// 计费类型
if (!ignore.includes('quota') && filterQuotaType !== 'all') {
if (model.quota_type !== filterQuotaType) return false;
}
// 搜索
if (!ignore.includes('search') && searchValue) {
const term = searchValue.toLowerCase();
const tags = model.tags ? model.tags.toLowerCase() : '';
if (
!(
// 端点类型
if (!ignore.includes('endpoint') && filterEndpointType !== 'all') {
if (
!model.supported_endpoint_types ||
!model.supported_endpoint_types.includes(filterEndpointType)
)
return false;
}
// 供应商
if (!ignore.includes('vendor') && filterVendor !== 'all') {
if (filterVendor === 'unknown') {
if (model.vendor_name) return false;
} else if (model.vendor_name !== filterVendor) {
return false;
}
}
// 标签
if (!ignore.includes('tag') && filterTag !== 'all') {
const tagsArr = normalizeTags(model.tags);
if (!tagsArr.includes(filterTag.toLowerCase())) return false;
}
// 搜索
if (!ignore.includes('search') && searchValue) {
const term = searchValue.toLowerCase();
const tags = model.tags ? model.tags.toLowerCase() : '';
if (!(
model.model_name.toLowerCase().includes(term) ||
(model.description &&
model.description.toLowerCase().includes(term)) ||
tags.includes(term) ||
(model.vendor_name && model.vendor_name.toLowerCase().includes(term))
)
)
return false;
}
))
return false;
}
return true;
};
return true;
},
[
filterGroup,
filterQuotaType,
filterEndpointType,
filterVendor,
filterTag,
searchValue,
],
);
// 生成不同视图所需的模型集合
const quotaTypeModels = useMemo(
() => allModels.filter((m) => matchesFilters(m, ['quota'])),
[
allModels,
filterGroup,
filterEndpointType,
filterVendor,
filterTag,
searchValue,
],
[allModels, matchesFilters],
);
const endpointTypeModels = useMemo(
() => allModels.filter((m) => matchesFilters(m, ['endpoint'])),
[
allModels,
filterGroup,
filterQuotaType,
filterVendor,
filterTag,
searchValue,
],
[allModels, matchesFilters],
);
const vendorModels = useMemo(
() => allModels.filter((m) => matchesFilters(m, ['vendor'])),
[
allModels,
filterGroup,
filterQuotaType,
filterEndpointType,
filterTag,
searchValue,
],
[allModels, matchesFilters],
);
const tagModels = useMemo(
() => allModels.filter((m) => matchesFilters(m, ['tag'])),
[
allModels,
filterGroup,
filterQuotaType,
filterEndpointType,
filterVendor,
searchValue,
],
[allModels, matchesFilters],
);
const groupCountModels = useMemo(
() => allModels.filter((m) => matchesFilters(m, ['group'])),
[
allModels,
filterQuotaType,
filterEndpointType,
filterVendor,
filterTag,
searchValue,
],
[allModels, matchesFilters],
);
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 '../common/useEffectEvent';
import { writeClipboardText } from '../../helpers/clipboard';
import { useState, useEffect, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
@@ -355,9 +356,10 @@ export const useModelsData = () => {
};
// Reload models when activeVendorKey changes
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
loadModels(1, pageSize, activeVendorKey);
}, [activeVendorKey]);
});
useEffect(() => onScopeChange(), [onScopeChange, activeVendorKey]);
// Handle page size change
const handlePageSizeChange = async (size) => {
+3 -2
View File
@@ -966,9 +966,10 @@ export const useApiRequest = (
streamMessageUpdate,
completeMessage,
t,
applyAutoCollapseLogic,
onConversationIdReceived,
onUserMessageIdReceived,
sseSourceRef,
setMessage,
],
);
@@ -1019,7 +1020,7 @@ export const useApiRequest = (
setTimeout(() => {
if (capturedUpdated) saveMessages(capturedUpdated);
}, 0);
}, [setMessage, applyAutoCollapseLogic, saveMessages]);
}, [setMessage, applyAutoCollapseLogic, saveMessages, sseSourceRef]);
// 发送请求
const sendRequest = useCallback(
+1 -2
View File
@@ -343,8 +343,7 @@ export const useFileUpload = ({ maxSizeMB, maxCount = 10, onSuccess } = {}) => {
// SVG 虽然 MIME 是 image/*,但本质是 XML 文本,多数大模型不接受 SVG 作为
// input_image(OpenAI vision 会返 "invalid image"),所以当 file 处理走文件分支。
fileType:
file.type?.startsWith('image/') &&
file.type !== 'image/svg+xml'
file.type?.startsWith('image/') && file.type !== 'image/svg+xml'
? 'image'
: 'file',
status: 'uploading',
+21 -16
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 '../common/useEffectEvent';
import { useState, useCallback, useRef, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Toast } from '@/components/ui';
@@ -238,22 +239,25 @@ export const usePlaygroundState = (options = {}) => {
}
}, []);
const handleConfigReset = useCallback((options = {}) => {
const { resetMessages = false } = options;
const handleConfigReset = useCallback(
(options = {}) => {
const { resetMessages = false } = options;
setInputs(DEFAULT_CONFIG.inputs);
setParameterEnabled(DEFAULT_CONFIG.parameterEnabled);
setShowDebugPanel(DEFAULT_CONFIG.showDebugPanel);
setCustomRequestMode(DEFAULT_CONFIG.customRequestMode);
setCustomRequestBody(DEFAULT_CONFIG.customRequestBody);
setInputs(DEFAULT_CONFIG.inputs);
setParameterEnabled(DEFAULT_CONFIG.parameterEnabled);
setShowDebugPanel(DEFAULT_CONFIG.showDebugPanel);
setCustomRequestMode(DEFAULT_CONFIG.customRequestMode);
setCustomRequestBody(DEFAULT_CONFIG.customRequestBody);
if (resetMessages) {
setMessage([]);
setTimeout(() => {
setMessage(getDefaultMessages(t));
}, 0);
}
}, []);
if (resetMessages) {
setMessage([]);
setTimeout(() => {
setMessage(getDefaultMessages(t));
}, 0);
}
},
[t],
);
const SESSIONS_PAGE_SIZE = 30;
@@ -552,7 +556,7 @@ export const usePlaygroundState = (options = {}) => {
};
}, []);
useEffect(() => {
const onMount = useEffectEvent(() => {
if (!Array.isArray(message) || message.length === 0) return;
const lastMsg = message[message.length - 1];
@@ -578,7 +582,8 @@ export const usePlaygroundState = (options = {}) => {
setTimeout(() => saveMessagesImmediately(updatedMessages), 0);
}
}, []);
});
useEffect(() => onMount(), [onMount]);
return {
inputs,
+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 '../common/useEffectEvent';
import { useState, useEffect } from 'react';
import { API, showError, showSuccess, copy } from '../../helpers';
import { ITEMS_PER_PAGE } from '../../constants';
@@ -295,13 +296,14 @@ export const useRedemptionsData = () => {
};
// Initialize data loading
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
loadRedemptions(1, pageSize)
.then()
.catch((reason) => {
showError(reason);
});
}, [pageSize]);
});
useEffect(() => onScopeChange(), [onScopeChange, pageSize]);
return {
// Data state
+17 -10
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 '../common/useEffectEvent';
import { useState, useEffect, useRef, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Modal } from '@/components/ui';
@@ -162,7 +163,7 @@ export const useTaskLogsData = ({
const [compactMode, setCompactMode] = useTableCompactMode('taskLogs');
// Load saved column preferences from localStorage
useEffect(() => {
const onMount = useEffectEvent(() => {
const savedColumns = localStorage.getItem(STORAGE_KEY);
setVisibleColumns(
resolveColumnVisibility(
@@ -171,7 +172,8 @@ export const useTaskLogsData = ({
isAdminUser ? [] : [COLUMN_KEYS.CHANNEL],
),
);
}, []);
});
useEffect(() => onMount(), [onMount]);
// Get default column visibility based on user role
const getDefaultColumnVisibility = () => {
@@ -224,7 +226,7 @@ export const useTaskLogsData = ({
if (Object.keys(visibleColumns).length > 0) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(visibleColumns));
}
}, [visibleColumns]);
}, [visibleColumns, STORAGE_KEY]);
// Get form values helper function
const getFormValues = () => {
@@ -439,17 +441,22 @@ export const useTaskLogsData = ({
};
// Initialize data
useEffect(() => {
const onScopeChange2 = useEffectEvent(() => {
const localPageSize =
parseInt(localStorage.getItem('task-page-size')) || ITEMS_PER_PAGE;
setPageSize(localPageSize);
loadLogs(1, localPageSize).then();
}, [
organizationMode,
sharedStartTimestamp,
sharedEndTimestamp,
sharedFilterRevision,
]);
});
useEffect(
() => onScopeChange2(),
[
onScopeChange2,
organizationMode,
sharedStartTimestamp,
sharedEndTimestamp,
sharedFilterRevision,
],
);
// 存在进行中的任务时,自动轮询刷新(10s 间隔),无 pending 则停止,避免无谓请求
const loadLogsRef = useRef(loadLogs);
+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 '../common/useEffectEvent';
import { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Modal } from '@/components/ui';
@@ -330,13 +331,14 @@ export const useTokensData = (openFluentNotification) => {
};
// Initialize data
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
loadTokens(1)
.then()
.catch((reason) => {
showError(reason);
});
}, [pageSize]);
});
useEffect(() => onScopeChange(), [onScopeChange, pageSize]);
return {
// Basic state
+11 -7
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 '../common/useEffectEvent';
import { useState, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { Modal } from '@/components/ui';
@@ -190,7 +191,7 @@ export const useLogsData = () => {
};
// Load saved column preferences from localStorage
useEffect(() => {
const onMount = useEffectEvent(() => {
const savedColumns = localStorage.getItem(STORAGE_KEY);
setVisibleColumns(
resolveColumnVisibility(
@@ -201,7 +202,8 @@ export const useLogsData = () => {
: [COLUMN_KEYS.CHANNEL, COLUMN_KEYS.USERNAME, COLUMN_KEYS.RETRY],
),
);
}, []);
});
useEffect(() => onMount(), [onMount]);
// Get default column visibility based on user role
const getDefaultColumnVisibility = () => {
@@ -262,7 +264,7 @@ export const useLogsData = () => {
if (Object.keys(visibleColumns).length > 0) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(visibleColumns));
}
}, [visibleColumns]);
}, [visibleColumns, STORAGE_KEY]);
// 获取表单值的辅助函数,确保所有值都是字符串
const getFormValues = () => {
@@ -659,7 +661,7 @@ export const useLogsData = () => {
};
// Initialize data
useEffect(() => {
const onMount2 = useEffectEvent(() => {
const localPageSize =
parseInt(localStorage.getItem('page-size')) || ITEMS_PER_PAGE;
setPageSize(localPageSize);
@@ -668,14 +670,16 @@ export const useLogsData = () => {
.catch((reason) => {
showError(reason);
});
}, []);
});
useEffect(() => onMount2(), [onMount2]);
// Initialize statistics when formApi is available
useEffect(() => {
const onScopeChange3 = useEffectEvent(() => {
if (formApi) {
handleEyeClick();
}
}, [formApi]);
});
useEffect(() => onScopeChange3(), [onScopeChange3, formApi]);
// 订阅"任务完成"事件:任务转终态时后端会产生消费日志,这里跟随刷新
// 用 ref 保存最新的加载函数,避免依赖数组里塞太多 state 导致频繁重订阅
+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 '../common/useEffectEvent';
import { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { API, showError, showSuccess } from '../../helpers';
@@ -268,14 +269,15 @@ export const useUsersData = () => {
};
// Initialize data on component mount
useEffect(() => {
const onMount = useEffectEvent(() => {
loadUsers(0, pageSize)
.then()
.catch((reason) => {
showError(reason);
});
fetchGroups().then();
}, []);
});
useEffect(() => onMount(), [onMount]);
return {
// Data state

Some files were not shown because too many files have changed in this diff Show More