diff --git a/frontend/src/views/settings/McpSettings.vue b/frontend/src/views/settings/McpSettings.vue index bfc6f517..bcad7c3a 100644 --- a/frontend/src/views/settings/McpSettings.vue +++ b/frontend/src/views/settings/McpSettings.vue @@ -51,17 +51,23 @@

{{ service.name }}

- + + {{ $t('mcpSettings.builtin') }} - + + + {{ service.enabled ? $t('common.on') : $t('common.off') }} + { // Get service options for dropdown menu. MCP service mutations and the // /test endpoint (which probes external infra with stored creds) are all // Admin+ in the backend matrix, so non-Admins see an empty action menu. -const getServiceOptions = () => { +const getServiceOptions = (service: MCPService) => { if (!authStore.hasRole('admin')) { return [] } return [ + { + content: service.enabled ? t('common.off') : t('common.on'), + value: 'toggle', + }, { content: t('mcpSettings.actions.test'), value: 'test' }, { content: t('common.edit'), value: 'edit' }, { content: t('common.delete'), value: 'delete', theme: 'error' as const } @@ -279,6 +289,12 @@ const getBuiltinServiceOptions = () => { const handleMenuAction = (data: { value: string }, service: MCPService) => { if (testing.value) return switch (data.value) { + case 'toggle': + // Flip the local model and reuse the toggle path so the API call, + // optimistic UI, and rollback-on-failure all stay in one place. + service.enabled = !service.enabled + handleToggleEnabled(service) + break case 'test': handleTest(service) break @@ -492,6 +508,43 @@ onMounted(() => { } } +// On/Off 状态徽章 —— 用 dot+文字而非 t-switch,避免误触;翻转启用状态由 +// 三点菜单里的 toggle 项触发,实际 API 调用走 handleToggleEnabled 同一路径。 +.service-card__status { + flex-shrink: 0; + display: inline-flex; + align-items: center; + gap: 5px; + padding: 1px 8px 1px 6px; + font-size: 11px; + font-weight: 500; + line-height: 16px; + border-radius: 10px; + background: var(--td-bg-color-secondarycontainer); + + &--on { + color: var(--td-success-color-7, #118053); + + .service-card__status-dot { + background: var(--td-success-color, #118053); + } + } + + &--off { + color: var(--td-text-color-placeholder); + + .service-card__status-dot { + background: var(--td-gray-color-5); + } + } +} + +.service-card__status-dot { + width: 6px; + height: 6px; + border-radius: 50%; +} + .service-card__more { flex-shrink: 0; color: var(--td-text-color-placeholder); diff --git a/frontend/src/views/settings/WebSearchSettings.vue b/frontend/src/views/settings/WebSearchSettings.vue index e1d0564d..426eee6e 100644 --- a/frontend/src/views/settings/WebSearchSettings.vue +++ b/frontend/src/views/settings/WebSearchSettings.vue @@ -29,12 +29,6 @@

{{ entity.name }}

- - {{ t('webSearchSettings.default') }} - - - {{ t('webSearchSettings.free') }} - { return !providerType.requires_api_key && !providerType.requires_engine_id } -const isEntityFree = (entity: WebSearchProviderEntity) => { - const pt = providerTypes.value.find(p => p.id === entity.provider) - return pt ? isProviderFree(pt) : false -} - // 卡片首字母徽章。复用 providerType 信息表,让多字节缩写也走同一处。 const providerInitial = (providerId: string) => { const label = providerTypes.value.find(p => p.id === providerId)?.name || providerId @@ -612,25 +601,6 @@ onMounted(async () => { white-space: nowrap; } -.provider-card__pill { - flex-shrink: 0; - padding: 1px 6px; - font-size: 11px; - font-weight: 500; - line-height: 16px; - border-radius: 3px; - - &--success { - color: var(--td-success-color-7, #118053); - background: var(--td-success-color-1, #E7F7F2); - } - - &--warning { - color: var(--td-warning-color-7, #B85C00); - background: var(--td-warning-color-1, #FEF3E6); - } -} - .provider-card__more { flex-shrink: 0; color: var(--td-text-color-placeholder);