From c037e35e5d368ec98ecacec32b68bba12f0997eb Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 20 Aug 2025 17:53:22 +0800 Subject: [PATCH] fix: enterprise credential --- .../model-auth/add-custom-model.tsx | 26 ++++++++----------- .../model-auth/authorized/index.tsx | 12 +++------ web/i18n/zh-Hans/plugin.ts | 2 +- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx index cfc97f35c8..d22b0ad61e 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx @@ -39,16 +39,20 @@ const AddCustomModel = ({ const { handleOpenModal, } = useAuth(provider, configurationMethod, currentCustomConfigurationModelFixedFields, true) - const handleClick = useCallback(() => { - handleOpenModal() - }, [handleOpenModal]) const notAllowCustomCredential = provider.allow_custom_token === false + const handleClick = useCallback(() => { + if (notAllowCustomCredential) + return + + handleOpenModal() + }, [handleOpenModal, notAllowCustomCredential]) const ButtonComponent = useMemo(() => { const Item = ( ) - if (notAllowCustomCredential) { - return ( - - {Item} - - ) - } return Item - }, [notAllowCustomCredential, t]) + }, [t]) if (noModels) return ButtonComponent diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx index 385caa4065..8f4b47148f 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx @@ -112,19 +112,18 @@ const Authorized = ({ const notAllowCustomCredential = provider.allow_custom_token === false const Trigger = useMemo(() => { - const hasValidCredential = items.some(item => item.credentials.some(credential => !credential.not_allowed_to_use)) const Item = ( ) - if (notAllowCustomCredential && !hasValidCredential) { + if (notAllowCustomCredential) { return ( @@ -148,11 +147,6 @@ const Authorized = ({ > { - if (notAllowCustomCredential) { - const hasValidCredential = items.some(item => item.credentials.some(credential => !credential.not_allowed_to_use)) - if (!hasValidCredential) - return - } setMergedIsOpen(!mergedIsOpen) }} asChild diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts index e014ac5ee6..e37de6d69f 100644 --- a/web/i18n/zh-Hans/plugin.ts +++ b/web/i18n/zh-Hans/plugin.ts @@ -297,7 +297,7 @@ const translation = { authRemoved: '凭据已移除', clientInfo: '由于未找到此工具提供者的系统客户端密钥,因此需要手动设置,对于 redirect_uri,请使用', oauthClient: 'OAuth 客户端', - credentialUnavailable: '凭据当前不可用,请联系管理员。', + credentialUnavailable: '自定义凭据当前不可用,请联系管理员。', customCredentialUnavailable: '自定义凭据当前不可用', unavailable: '不可用', },