feat(settings): redesign vector store cards

Bring vector stores in line with the rest of the settings list
redesign. The previous list-row layout (lock icon + 2 tags +
endpoint subtitle + buttons) carried the same "low" feel as the
old model/provider cards: flat, tag-heavy, no engine identity.

- Replace .store-list rows with a .store-grid card grid sharing
  the same skeleton used by Parser/Storage/Mcp: a 36x36 monogram
  badge tinted per engine_type (qdrant red, milvus blue, weaviate
  green, elasticsearch amber, postgres blue, opensearch / infinity
  purple, tencent_vectordb blue, doris orange, sqlite gray, others
  fall back to brand blue).
- Title row carries the name + an env pill for read-only stores +
  a low-contrast text-style "Test" button (admin-only) + the
  hover-only ellipsis menu (edit / delete, user stores only).
- Subtitle: engine_type · endpoint (monospaced, truncated).
- Test result keeps its inline success/error bar but rebuilt as
  store-card__result so it lives inside the card instead of
  hanging off a sibling row.

Drops the .store-list / .store-item / .item-* / .test-result-*
selectors that were only ever used here.
This commit is contained in:
wizardchen
2026-05-26 21:59:20 +08:00
committed by lyingbug
parent 68d41ae7d9
commit 272be9e8c5
@@ -20,68 +20,66 @@
</t-button> </t-button>
</div> </div>
<!-- Store List --> <!-- 与其它 settings 列表同形:左侧 engine 徽章 + 标题 + env pill + 副标题 + 测试动作。
<div v-if="stores.length > 0" class="store-list"> env 来源是只读的 (engine_type / connection_config 由 .env 写入),所以没有更多菜单;
<!-- Env Stores --> user 来源沿用三点菜单的编辑 / 删除入口;测试结果作为卡片底部的彩色条出现。 -->
<div v-for="store in envStores" :key="store.id" class="store-item store-item--env"> <div v-if="stores.length > 0" class="store-grid">
<div class="item-row"> <div
<div class="item-info"> v-for="store in [...envStores, ...userStores]"
<div class="item-header"> :key="store.id"
<t-icon name="lock-on" size="14px" /> class="store-card"
<span class="item-name">{{ store.name }}</span> :class="[
<t-tag theme="warning" size="small" variant="light">{{ t('vectorStoreSettings.envTag') }}</t-tag> `store-card--${store.engine_type}`,
<t-tag size="small" variant="outline">{{ store.engine_type }}</t-tag> { 'store-card--env': store.source === 'env' }
</div> ]"
</div> >
<div class="item-actions"> <div class="store-card__main">
<t-button <div class="store-card__badge">{{ engineInitial(store.engine_type) }}</div>
v-if="authStore.hasRole('admin')" <div class="store-card__body">
theme="default" variant="outline" size="small" <div class="store-card__header">
:loading="testingId === store.id" <h3 class="store-card__title" :title="store.name">{{ store.name }}</h3>
@click="testExisting(store)" <span v-if="store.source === 'env'" class="store-card__pill">
> {{ t('vectorStoreSettings.envTag') }}
{{ t('vectorStoreSettings.testConnection') }} </span>
</t-button> <t-button
<t-button theme="default" variant="text" size="small" shape="square" style="visibility: hidden;"> v-if="authStore.hasRole('admin')"
<template #icon><t-icon name="more" /></template> class="store-card__test"
</t-button> theme="default"
</div> variant="text"
</div> size="small"
<div v-if="getTestResult(store)" :class="['test-result-bar', getTestResult(store)!.success ? 'success' : 'error']"> :loading="testingId === store.id"
<span class="test-result-message">{{ getTestResult(store)!.message }}</span> @click="testExisting(store)"
<t-icon name="close" size="14px" class="test-result-close" @click="clearTestResult(store)" /> >
</div> {{ t('vectorStoreSettings.testConnection') }}
</div>
<!-- User Stores -->
<div v-for="store in userStores" :key="store.id" class="store-item">
<div class="item-row">
<div class="item-info">
<div class="item-header">
<span class="item-name">{{ store.name }}</span>
<t-tag size="small" variant="outline">{{ store.engine_type }}</t-tag>
</div>
<div class="item-desc">{{ getStoreEndpoint(store) }}</div>
</div>
<div class="item-actions">
<t-button
v-if="authStore.hasRole('admin')"
theme="default" variant="outline" size="small"
:loading="testingId === store.id"
@click="testExisting(store)"
>
{{ t('vectorStoreSettings.testConnection') }}
</t-button>
<t-dropdown v-if="authStore.hasRole('admin')" :options="storeActions" trigger="click" @click="(action: any) => handleAction(action, store)">
<t-button theme="default" variant="text" size="small" shape="square">
<template #icon><t-icon name="more" /></template>
</t-button> </t-button>
</t-dropdown> <t-dropdown
v-if="authStore.hasRole('admin') && store.source !== 'env'"
:options="storeActions"
placement="bottom-right"
attach="body"
trigger="click"
@click="(action: any) => handleAction(action, store)"
>
<t-button variant="text" shape="square" size="small" class="store-card__more">
<t-icon name="ellipsis" />
</t-button>
</t-dropdown>
</div>
<div class="store-card__subtitle">
<span class="store-card__type">{{ store.engine_type }}</span>
<template v-if="getStoreEndpoint(store)">
<span class="store-card__sep">·</span>
<span class="store-card__endpoint" :title="getStoreEndpoint(store)">{{ getStoreEndpoint(store) }}</span>
</template>
</div>
</div> </div>
</div> </div>
<div v-if="getTestResult(store)" :class="['test-result-bar', getTestResult(store)!.success ? 'success' : 'error']"> <div
<span class="test-result-message">{{ getTestResult(store)!.message }}</span> v-if="getTestResult(store)"
<t-icon name="close" size="14px" class="test-result-close" @click="clearTestResult(store)" /> :class="['store-card__result', getTestResult(store)!.success ? 'store-card__result--ok' : 'store-card__result--err']"
>
<span class="store-card__result-message">{{ getTestResult(store)!.message }}</span>
<t-icon name="close" size="14px" class="store-card__result-close" @click="clearTestResult(store)" />
</div> </div>
</div> </div>
</div> </div>
@@ -358,6 +356,11 @@ const getStoreEndpoint = (store: VectorStoreEntity): string => {
return cc.addr || cc.host || '' return cc.addr || cc.host || ''
} }
// 卡片徽章首字母。engine_type 都是英文 ASCII,直接 charAt。
const engineInitial = (engineType: string): string => {
return (engineType || '?').charAt(0).toUpperCase()
}
const onEngineTypeChange = () => { const onEngineTypeChange = () => {
form.value.connection_config = {} form.value.connection_config = {}
form.value.index_config = {} form.value.index_config = {}
@@ -582,23 +585,27 @@ onMounted(async () => {
} }
} }
.store-list { .store-grid {
display: flex; display: grid;
flex-direction: column; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 8px; gap: 12px;
} }
.store-item { // 与 Parser / Storage / Model 等同形:徽章 + 三段式。env 来源走 secondaryContainer
// 底色暗示只读;test 按钮做成 text 模式,避免在标题行抢眼。
.store-card {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 14px 16px; padding: 14px 14px 14px 12px;
background: var(--td-bg-color-container);
border: 1px solid var(--td-component-stroke); border: 1px solid var(--td-component-stroke);
border-radius: 8px; border-radius: 10px;
transition: all 0.2s ease; background: var(--td-bg-color-container);
transition: border-color 0.18s ease, box-shadow 0.18s ease;
min-width: 0;
&:hover { &:hover {
border-color: var(--td-brand-color); border-color: var(--td-brand-color-3, var(--td-brand-color));
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
} }
&--env { &--env {
@@ -606,84 +613,200 @@ onMounted(async () => {
&:hover { &:hover {
border-color: var(--td-component-stroke); border-color: var(--td-component-stroke);
box-shadow: none;
} }
} }
} }
.item-info { .store-card__main {
display: flex;
align-items: flex-start;
gap: 12px;
min-width: 0;
}
.store-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;
background: rgba(0, 82, 217, 0.1);
color: #0052D9;
}
// 各 vector engine 配色(覆盖 11 类常见后端,未列出的回落到默认蓝)
.store-card--qdrant .store-card__badge {
background: rgba(225, 38, 38, 0.12);
color: #E12626;
}
.store-card--milvus .store-card__badge {
background: rgba(0, 137, 255, 0.12);
color: #0089FF;
}
.store-card--weaviate .store-card__badge {
background: rgba(7, 192, 95, 0.12);
color: #07A050;
}
.store-card--elasticsearch .store-card__badge,
.store-card--elasticfaiss .store-card__badge {
background: rgba(255, 153, 0, 0.12);
color: #D97706;
}
.store-card--postgres .store-card__badge {
background: rgba(0, 82, 217, 0.1);
color: #0052D9;
}
.store-card--opensearch .store-card__badge {
background: rgba(98, 53, 187, 0.12);
color: #6235BB;
}
.store-card--infinity .store-card__badge {
background: rgba(98, 53, 187, 0.12);
color: #6235BB;
}
.store-card--tencent_vectordb .store-card__badge {
background: rgba(0, 82, 217, 0.1);
color: #0052D9;
}
.store-card--doris .store-card__badge {
background: rgba(255, 90, 0, 0.12);
color: #E55A00;
}
.store-card--sqlite .store-card__badge {
background: rgba(70, 70, 70, 0.1);
color: #464646;
}
.store-card__body {
flex: 1;
min-width: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 4px;
min-width: 0;
flex: 1;
} }
.item-header { .store-card__header {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 6px;
min-width: 0;
} }
.item-name { .store-card__title {
flex: 1;
min-width: 0;
margin: 0;
font-size: 14px; font-size: 14px;
font-weight: 500; font-weight: 600;
line-height: 1.4;
color: var(--td-text-color-primary); color: var(--td-text-color-primary);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.item-desc { .store-card__pill {
font-size: 13px; flex-shrink: 0;
padding: 1px 6px;
font-size: 11px;
font-weight: 500;
line-height: 16px;
border-radius: 3px;
color: var(--td-warning-color-7, #B85C00);
background: var(--td-warning-color-1, #FEF3E6);
}
// 测试按钮做成 text 风格,hover 才显边框;让标题行视觉层级仍由名称主导。
.store-card__test {
flex-shrink: 0;
font-size: 12px;
padding: 0 8px;
height: 24px;
}
.store-card__more {
flex-shrink: 0;
color: var(--td-text-color-placeholder);
padding: 2px;
opacity: 0;
transition: opacity 0.15s ease;
&:hover,
&:focus-visible {
background: var(--td-bg-color-secondarycontainer);
color: var(--td-text-color-primary);
}
}
.store-card:hover .store-card__more,
.store-card:focus-within .store-card__more {
opacity: 1;
}
.store-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); color: var(--td-text-color-secondary);
min-width: 0;
}
.store-card__type {
font-weight: 500;
}
.store-card__sep {
color: var(--td-text-color-placeholder);
}
.store-card__endpoint {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
font-size: 11px;
color: var(--td-text-color-placeholder);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
min-width: 0;
} }
.item-actions { .store-card__result {
display: flex;
gap: 6px;
align-items: center;
flex-shrink: 0;
margin-left: 12px;
}
.item-row {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
.test-result-bar {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-top: 10px; margin-top: 10px;
padding: 8px 12px; padding: 8px 12px;
border-radius: 4px; border-radius: 6px;
font-size: 12px; font-size: 12px;
line-height: 1.4; line-height: 1.4;
word-break: break-word; word-break: break-word;
&.success { &--ok {
background: rgba(7, 192, 95, 0.1); background: rgba(7, 192, 95, 0.1);
color: var(--td-success-color); color: var(--td-success-color);
} }
&.error { &--err {
background: var(--td-error-color-1, rgba(227, 77, 89, 0.1)); background: var(--td-error-color-1, rgba(227, 77, 89, 0.1));
color: var(--td-error-color); color: var(--td-error-color);
} }
} }
.test-result-message { .store-card__result-message {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
} }
.test-result-close { .store-card__result-close {
flex-shrink: 0; flex-shrink: 0;
margin-left: 8px; margin-left: 8px;
cursor: pointer; cursor: pointer;