Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

feat(settings): redesign websearch/mcp provider cards

wizardchen260b3eec26c2
diff --git a/frontend/src/views/settings/McpSettings.vue b/frontend/src/views/settings/McpSettings.vue
index 675f2358a..bfc6f5173 100644
--- a/frontend/src/views/settings/McpSettings.vue
+++ b/frontend/src/views/settings/McpSettings.vue
@@ -33,54 +33,57 @@
</div>
<div v-else class="services-grid">
- <SettingCard
+ <!-- 与 ModelSettings / WebSearchSettings 同形的卡片:左侧 transport 徽章 +
+ 标题 / 副标题 / url 三段式。开关挂在标题行右侧,三点菜单 hover 才出现。
+ SettingCard 当前没有其它消费者了,但保留组件供未来需要时复用。 -->
+ <div
v-for="service in services"
:key="service.id"
- :title="service.name"
- :description="service.description || ''"
- :disabled="service.is_builtin"
- :actions="service.is_builtin ? getBuiltinServiceOptions() : getServiceOptions()"
- @action="(value: string) => handleMenuAction({ value }, service)"
+ class="service-card"
+ :class="[
+ `service-card--${service.transport_type || 'unknown'}`,
+ { 'service-card--builtin': service.is_builtin }
+ ]"
>
- <template #tags>
- <t-tag
- :theme="getTransportTypeTheme(service.transport_type)"
- size="small"
- variant="light"
- >
- {{ getTransportTypeLabel(service.transport_type) }}
- </t-tag>
- <t-tag
- v-if="service.is_builtin"
- theme="warning"
- size="small"
- variant="light"
- >
- {{ $t('mcpSettings.builtin') }}
- </t-tag>
- <t-tag
- :theme="service.enabled ? 'success' : 'default'"
- size="small"
- variant="light"
- >
- {{ service.enabled ? $t('common.on') : $t('common.off') }}
- </t-tag>
- </template>
- <template #controls>
- <t-switch
- v-model="service.enabled"
- size="medium"
- :disabled="service.is_builtin || !authStore.hasRole('admin')"
- @change="() => handleToggleEnabled(service)"
- />
- </template>
- <template #meta>
- <span v-if="service.url" class="service-meta-item" :title="service.url">
- <t-icon name="link" size="12px" />
- <span class="service-meta-text">{{ service.url }}</span>
- </span>
- </template>
- </SettingCard>
+ <div class="service-card__badge" :aria-label="getTransportTypeLabel(service.transport_type)">
+ <t-icon :name="getTransportTypeIcon(service.transport_type)" size="18px" />
+ </div>
+ <div class="service-card__body">
+ <div class="service-card__header">
+ <h3 class="service-card__title" :title="service.name">{{ service.name }}</h3>
+ <span v-if="service.is_builtin" class="service-card__pill service-card__pill--warning">
+ {{ $t('mcpSettings.builtin') }}
+ </span>
+ <t-switch
+ v-model="service.enabled"
+ size="medium"
+ :disabled="service.is_builtin || !authStore.hasRole('admin')"
+ @change="() => handleToggleEnabled(service)"
+ />
+ <t-dropdown
+ :options="service.is_builtin ? getBuiltinServiceOptions() : getServiceOptions()"
+ placement="bottom-right"
+ attach="body"
+ trigger="click"
+ @click="(data: any) => handleMenuAction({ value: data.value }, service)"
+ >
+ <t-button variant="text" shape="square" size="small" class="service-card__more">
+ <t-icon name="ellipsis" />
+ </t-button>
+ </t-dropdown>
+ </div>
+ <div class="service-card__subtitle">
+ <span class="service-card__type">{{ getTransportTypeLabel(service.transport_type) }}</span>
+ <template v-if="service.description">
+ <span class="service-card__sep">·</span>
+ <span class="service-card__desc" :title="service.description">{{ service.description }}</span>
+ </template>
+ </div>
+ <div v-if="service.url" class="service-card__url" :title="service.url">
+ {{ service.url }}
+ </div>
+ </div>
+ </div>
</div>
</template>
@@ -116,7 +119,6 @@ import {
} from '@/api/mcp-service'
import McpServiceDialog from './components/McpServiceDialog.vue'
import McpTestResult from './components/McpTestResult.vue'
-import SettingCard from '@/components/settings/SettingCard.vue'
import { useConfirmDelete } from '@/components/settings/useConfirmDelete'
import { useAuthStore } from '@/stores/auth'
@@ -289,17 +291,17 @@ const handleMenuAction = (data: { value: string }, service: MCPService) => {
}
}
-// Get transport type theme for tag
-const getTransportTypeTheme = (transportType: string) => {
+// Get transport type icon. 复用 tdesign 自带 icon name;新增 transport 时同步加。
+const getTransportTypeIcon = (transportType: string) => {
switch (transportType) {
case 'sse':
- return 'success'
+ return 'cast'
case 'http-streamable':
- return 'primary'
+ return 'link'
case 'stdio':
- return 'warning'
+ return 'code'
default:
- return 'default'
+ return 'tools'
}
}
@@ -390,21 +392,160 @@ onMounted(() => {
.services-grid {
display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
+ grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
+ gap: 12px;
+}
+
+// Transport-distinguished card. 与 ModelSettings / WebSearchSettings 同形。
+.service-card {
+ display: flex;
+ align-items: flex-start;
gap: 12px;
+ padding: 14px 14px 14px 12px;
+ border: 1px solid var(--td-component-stroke);
+ border-radius: 10px;
+ background: var(--td-bg-color-container);
+ transition: border-color 0.18s ease, box-shadow 0.18s ease;
+ min-width: 0;
+
+ &:hover {
+ border-color: var(--td-brand-color-3, var(--td-brand-color));
+ box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
+ }
+
+ &--builtin {
+ background: var(--td-bg-color-secondarycontainer);
+
+ &:hover {
+ box-shadow: none;
+ border-color: var(--td-component-stroke);
+ }
+ }
}
-.service-meta-item {
- display: inline-flex;
+.service-card__badge {
+ flex-shrink: 0;
+ width: 36px;
+ height: 36px;
+ border-radius: 9px;
+ display: flex;
align-items: center;
+ justify-content: center;
+ margin-top: 1px;
+ background: rgba(0, 82, 217, 0.1);
+ color: #0052D9;
+}
+
+// 三种 transport 的徽章配色:sse 流式 → 绿,http-streamable → 蓝,stdio → 橙
+.service-card--sse .service-card__badge {
+ background: rgba(17, 128, 83, 0.12);
+ color: #118053;
+}
+.service-card--http-streamable .service-card__badge {
+ background: rgba(0, 82, 217, 0.1);
+ color: #0052D9;
+}
+.service-card--stdio .service-card__badge {
+ background: rgba(184, 92, 0, 0.12);
+ color: #B85C00;
+}
+
+.service-card__body {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
gap: 4px;
- max-width: 100%;
+}
+
+.service-card__header {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+}
+
+.service-card__title {
+ flex: 1;
+ min-width: 0;
+ margin: 0;
+ font-size: 14px;
+ font-weight: 600;
+ line-height: 1.4;
+ color: var(--td-text-color-primary);
overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.service-card__pill {
+ flex-shrink: 0;
+ padding: 1px 6px;
+ font-size: 11px;
+ font-weight: 500;
+ line-height: 16px;
+ border-radius: 3px;
+
+ &--warning {
+ color: var(--td-warning-color-7, #B85C00);
+ background: var(--td-warning-color-1, #FEF3E6);
+ }
+}
+
+.service-card__more {
+ flex-shrink: 0;
+ color: var(--td-text-color-placeholder);
+ padding: 2px;
+ opacity: 0;
+ transition: opacity 0.15s ease;
- .service-meta-text {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+ &:hover,
+ &:focus-visible {
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-primary);
}
}
+
+// switch 始终显示(它是状态锚点);三点按钮只在 hover/focus 时出现。
+.service-card:hover .service-card__more,
+.service-card:focus-within .service-card__more {
+ opacity: 1;
+}
+
+.service-card__subtitle {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 4px;
+ font-size: 12px;
+ line-height: 1.4;
+ color: var(--td-text-color-secondary);
+ min-width: 0;
+}
+
+.service-card__type {
+ font-weight: 500;
+}
+
+.service-card__sep {
+ color: var(--td-text-color-placeholder);
+}
+
+.service-card__desc {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ min-width: 0;
+}
+
+.service-card__url {
+ font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
+ font-size: 11px;
+ line-height: 1.4;
+ color: var(--td-text-color-placeholder);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ min-width: 0;
+}
</style>
diff --git a/frontend/src/views/settings/WebSearchSettings.vue b/frontend/src/views/settings/WebSearchSettings.vue
index c0a21d3e9..e1d0564d7 100644
--- a/frontend/src/views/settings/WebSearchSettings.vue
+++ b/frontend/src/views/settings/WebSearchSettings.vue
@@ -13,29 +13,53 @@
</t-button>
</div>
- <!-- Provider List -->
+ <!-- Provider List —— 与 ModelSettings 的卡片同形:左侧标识徽章 + 标题 / 副标题 / proxy URL 三段式。
+ 不复用 SettingCard 的原因和 Models 一样:每页有微妙不同的右上侧栏需求(这里没有控件,
+ Mcp 有开关),SettingCard 仍服务于其它消费者。 -->
<div v-if="providerEntities.length > 0" class="provider-grid">
- <SettingCard v-for="entity in providerEntities" :key="entity.id" :title="entity.name"
- :description="entity.description || ''" :actions="getProviderOptions(entity)"
- @action="(value: string) => handleMenuAction({ value }, entity)">
- <template #tags>
- <t-tag theme="primary" size="small" variant="light">
- {{ entity.provider }}
- </t-tag>
- <t-tag v-if="entity.is_default" theme="success" size="small" variant="light">
- {{ t('webSearchSettings.default') }}
- </t-tag>
- <t-tag v-if="isEntityFree(entity)" theme="warning" size="small" variant="light">
- {{ t('webSearchSettings.free') }}
- </t-tag>
- </template>
- <template #meta>
- <span v-if="entity.parameters?.proxy_url" class="provider-meta-item" :title="entity.parameters.proxy_url">
- <t-icon name="internet" size="12px" />
- <span class="provider-meta-text">{{ entity.parameters.proxy_url }}</span>
- </span>
- </template>
- </SettingCard>
+ <div
+ v-for="entity in providerEntities"
+ :key="entity.id"
+ class="provider-card"
+ :class="`provider-card--${entity.provider}`"
+ >
+ <div class="provider-card__badge" :aria-label="entity.provider">
+ {{ providerInitial(entity.provider) }}
+ </div>
+ <div class="provider-card__body">
+ <div class="provider-card__header">
+ <h3 class="provider-card__title" :title="entity.name">{{ entity.name }}</h3>
+ <span v-if="entity.is_default" class="provider-card__pill provider-card__pill--success">
+ {{ t('webSearchSettings.default') }}
+ </span>
+ <span v-if="isEntityFree(entity)" class="provider-card__pill provider-card__pill--warning">
+ {{ t('webSearchSettings.free') }}
+ </span>
+ <t-dropdown
+ v-if="getProviderOptions(entity).length > 0"
+ :options="getProviderOptions(entity)"
+ placement="bottom-right"
+ attach="body"
+ trigger="click"
+ @click="(data: any) => handleMenuAction({ value: data.value }, entity)"
+ >
+ <t-button variant="text" shape="square" size="small" class="provider-card__more">
+ <t-icon name="ellipsis" />
+ </t-button>
+ </t-dropdown>
+ </div>
+ <div class="provider-card__subtitle">
+ <span class="provider-card__type">{{ providerTypeLabel(entity.provider) }}</span>
+ <template v-if="entity.description">
+ <span class="provider-card__sep">·</span>
+ <span class="provider-card__desc" :title="entity.description">{{ entity.description }}</span>
+ </template>
+ </div>
+ <div v-if="entity.parameters?.proxy_url" class="provider-card__url" :title="entity.parameters.proxy_url">
+ {{ entity.parameters.proxy_url }}
+ </div>
+ </div>
+ </div>
</div>
<!-- Empty State -->
@@ -164,7 +188,6 @@ import {
type WebSearchProviderTypeInfo,
type WebSearchCredentialField,
} from '@/api/web-search-provider'
-import SettingCard from '@/components/settings/SettingCard.vue'
import SettingDrawer from '@/components/settings/SettingDrawer.vue'
import CredentialResource, {
type CredentialFieldDef,
@@ -245,6 +268,16 @@ const isEntityFree = (entity: WebSearchProviderEntity) => {
return pt ? isProviderFree(pt) : false
}
+// 卡片首字母徽章。复用 providerType 信息表,让多字节缩写也走同一处。
+const providerInitial = (providerId: string) => {
+ const label = providerTypes.value.find(p => p.id === providerId)?.name || providerId
+ return (label.trim().charAt(0) || '?').toUpperCase()
+}
+
+const providerTypeLabel = (providerId: string) => {
+ return providerTypes.value.find(p => p.id === providerId)?.name || providerId
+}
+
// ===== Methods =====
const onProviderTypeChange = () => {
providerForm.value.parameters = {}
@@ -480,24 +513,180 @@ onMounted(async () => {
.provider-grid {
display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
+ grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 12px;
}
-.provider-meta-item {
- display: inline-flex;
+// 卡片视觉与 ModelSettings 的 model-card 同构(徽章 + 标题 / 副标题 / url 三段式)。
+// 现阶段两份样式各自维护避免过度抽象;如果后续 Mcp / 第四个消费者出现,
+// 再把共用片段抽到 components/settings/ 下的基类。
+.provider-card {
+ display: flex;
+ align-items: flex-start;
+ gap: 12px;
+ padding: 14px 14px 14px 12px;
+ border: 1px solid var(--td-component-stroke);
+ border-radius: 10px;
+ background: var(--td-bg-color-container);
+ transition: border-color 0.18s ease, box-shadow 0.18s ease;
+ min-width: 0;
+
+ &:hover {
+ border-color: var(--td-brand-color-3, var(--td-brand-color));
+ box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
+ }
+}
+
+.provider-card__badge {
+ flex-shrink: 0;
+ width: 36px;
+ height: 36px;
+ border-radius: 9px;
+ display: flex;
align-items: center;
+ justify-content: center;
+ margin-top: 1px;
+ font-size: 15px;
+ font-weight: 600;
+ letter-spacing: 0.02em;
+ // 默认色,被 provider 修饰覆盖
+ background: rgba(0, 82, 217, 0.1);
+ color: #0052D9;
+}
+
+// 各搜索源的徽章配色 —— 不强求与官方 logo 一致,挑同色系低饱和版即可。
+.provider-card--duckduckgo .provider-card__badge {
+ background: rgba(222, 88, 51, 0.12);
+ color: #DE5833;
+}
+.provider-card--bing .provider-card__badge {
+ background: rgba(0, 137, 255, 0.12);
+ color: #0089FF;
+}
+.provider-card--google .provider-card__badge {
+ background: rgba(66, 133, 244, 0.12);
+ color: #4285F4;
+}
+.provider-card--tavily .provider-card__badge {
+ background: rgba(98, 53, 187, 0.12);
+ color: #6235BB;
+}
+.provider-card--baidu .provider-card__badge {
+ background: rgba(225, 38, 38, 0.12);
+ color: #E12626;
+}
+.provider-card--searxng .provider-card__badge {
+ background: rgba(33, 86, 137, 0.12);
+ color: #215689;
+}
+.provider-card--ollama .provider-card__badge {
+ background: rgba(70, 70, 70, 0.12);
+ color: #464646;
+}
+
+.provider-card__body {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
gap: 4px;
- max-width: 100%;
+}
+
+.provider-card__header {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+}
+
+.provider-card__title {
+ flex: 1;
+ min-width: 0;
+ margin: 0;
+ font-size: 14px;
+ font-weight: 600;
+ line-height: 1.4;
+ color: var(--td-text-color-primary);
overflow: hidden;
+ text-overflow: ellipsis;
+ 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);
+ padding: 2px;
+ opacity: 0;
+ transition: opacity 0.15s ease;
- .provider-meta-text {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+ &:hover,
+ &:focus-visible {
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-primary);
}
}
+.provider-card:hover .provider-card__more,
+.provider-card:focus-within .provider-card__more {
+ opacity: 1;
+}
+
+.provider-card__subtitle {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 4px;
+ font-size: 12px;
+ line-height: 1.4;
+ color: var(--td-text-color-secondary);
+ min-width: 0;
+}
+
+.provider-card__type {
+ font-weight: 500;
+}
+
+.provider-card__sep {
+ color: var(--td-text-color-placeholder);
+}
+
+.provider-card__desc {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ min-width: 0;
+}
+
+.provider-card__url {
+ font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
+ font-size: 11px;
+ line-height: 1.4;
+ color: var(--td-text-color-placeholder);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ min-width: 0;
+}
+
.empty-state {
padding: 64px 0;
text-align: center;