From 654a420a63d62f8adac6dfcc4bb6fec82e414b3a Mon Sep 17 00:00:00 2001 From: Jeff Gu Date: Wed, 10 Jun 2026 11:32:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(channels):=20=E6=B7=BB=E5=8A=A0=E4=BB=85?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=B7=B2=E5=90=AF=E7=94=A8=E6=B8=A0=E9=81=93?= =?UTF-8?q?=E7=9A=84=E8=BF=87=E6=BB=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在渠道管理页面中新增了一个按钮,允许用户选择仅查看已启用的渠道。此更改旨在提升用户体验,使用户能够更方便地管理和筛选渠道。通过引入这个过滤选项,用户可以快速找到他们所需的渠道,避免在大量无效渠道中浪费时间。此外,相关的国际化文本也已更新,以支持英文、简体中文和繁体中文的显示。 --- frontend/src/i18n/locales/en.json | 1 + frontend/src/i18n/locales/zh-CN.json | 1 + frontend/src/i18n/locales/zh-TW.json | 1 + frontend/src/pages/Channels.tsx | 29 +++++++++++++++++++++++----- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 202d2b9..ee483e9 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -116,6 +116,7 @@ "title": "Channels", "description": "Configure AI provider endpoints, manage models and load balancing", "searchPlaceholder": "Search channels...", + "enabledOnly": "Enabled only", "addChannel": "Add Channel", "editChannel": "Edit Channel", "emptyTitle": "Add your first channel", diff --git a/frontend/src/i18n/locales/zh-CN.json b/frontend/src/i18n/locales/zh-CN.json index 6b078fc..2886fe1 100644 --- a/frontend/src/i18n/locales/zh-CN.json +++ b/frontend/src/i18n/locales/zh-CN.json @@ -116,6 +116,7 @@ "title": "渠道管理", "description": "配置 AI 服务商接口,管理模型和负载均衡策略", "searchPlaceholder": "搜索渠道...", + "enabledOnly": "仅已启用", "addChannel": "添加渠道", "editChannel": "编辑渠道", "emptyTitle": "添加您的第一个渠道", diff --git a/frontend/src/i18n/locales/zh-TW.json b/frontend/src/i18n/locales/zh-TW.json index 01cb2ba..b254743 100644 --- a/frontend/src/i18n/locales/zh-TW.json +++ b/frontend/src/i18n/locales/zh-TW.json @@ -116,6 +116,7 @@ "title": "渠道管理", "description": "設定 AI 服務商介面,管理模型和負載均衡策略", "searchPlaceholder": "搜尋渠道...", + "enabledOnly": "僅已啟用", "addChannel": "新增渠道", "editChannel": "編輯渠道", "emptyTitle": "新增您的第一個渠道", diff --git a/frontend/src/pages/Channels.tsx b/frontend/src/pages/Channels.tsx index 79bf666..3bcc80a 100644 --- a/frontend/src/pages/Channels.tsx +++ b/frontend/src/pages/Channels.tsx @@ -577,6 +577,7 @@ export function Channels({ createMode = false, editRoute = false }: { createMode const [modelRows, setModelRows] = useState([createEmptyModelRow()]); const [modelJsonValue, setModelJsonValue] = useState("[]"); const [searchQuery, setSearchQuery] = useState(""); + const [showEnabledOnly, setShowEnabledOnly] = useState(true); const [openMenu, setOpenMenu] = useState(null); const [isFetchedModelsDialogOpen, setIsFetchedModelsDialogOpen] = useState(false); const [fetchedModelCandidates, setFetchedModelCandidates] = useState([]); @@ -1086,13 +1087,20 @@ export function Channels({ createMode = false, editRoute = false }: { createMode return channelTypes.find((item) => item.value === type)?.label || type; }; + const normalizedSearchQuery = searchQuery.trim().toLowerCase(); const filteredData = data?.filter((channel) => { - if (!searchQuery) return true; const rawConfig = parseChannelValue(channel); const config = normalizeChannelFormConfig(rawConfig); + + if (showEnabledOnly && config.enabled === false) { + return false; + } + + if (!normalizedSearchQuery) return true; + return ( - config.name?.toLowerCase().includes(searchQuery.toLowerCase()) || - channel.key.toLowerCase().includes(searchQuery.toLowerCase()) + config.name?.toLowerCase().includes(normalizedSearchQuery) || + channel.key.toLowerCase().includes(normalizedSearchQuery) ); }); const endpointPreview = getChannelEndpointPreview(formData.type, formData.endpoint); @@ -1116,8 +1124,8 @@ export function Channels({ createMode = false, editRoute = false }: { createMode } > {data && data.length > 0 && ( -
-
+
+
+
)}