Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat(model-editor): enhance ModelEditorDialog with connection test and improved layout
wizardchen9d1f3001e8aa
diff --git a/frontend/src/components/ModelEditorDialog.vue b/frontend/src/components/ModelEditorDialog.vueindex 1091d01b9..e2a34fc6e 100644--- a/frontend/src/components/ModelEditorDialog.vue+++ b/frontend/src/components/ModelEditorDialog.vue@@ -1,244 +1,311 @@<template><SettingDrawer :visible="dialogVisible" :title="isEdit ? $t('model.editor.editTitle') : $t('model.editor.addTitle')"- :description="getModalDescription()" :confirm-loading="saving"+ :description="getModalDescription()" :icon="modelTypeIcon" :confirm-loading="saving":confirm-disabled="formData.provider === 'weknoracloud' && wkcCredentialState !== 'configured'"@update:visible="(v: boolean) => dialogVisible = v" @confirm="handleConfirm" @cancel="handleCancel">++ <!--+ Footer-left slot: connection-test button lives here so it sits next to+ Save/Cancel — primary actions all aligned along the bottom of the+ drawer. Avoids the "test, then scroll back down to save" dance.+ Mirrors the pattern used in WebSearchSettings' provider drawer.+ -->+ <template v-if="formData.source === 'remote'" #footer-left>+ <t-button variant="outline" @click="checkRemoteAPI" :loading="checking"+ :disabled="!formData.modelName || (!formData.baseUrl && formData.provider !== 'weknoracloud') || (formData.provider === 'weknoracloud' && wkcCredentialState !== 'configured')">+ <template #icon>+ <t-icon v-if="!checking && remoteChecked && remoteAvailable" name="check-circle-filled"+ class="status-icon available" />+ <t-icon v-else-if="!checking && remoteChecked && !remoteAvailable" name="close-circle-filled"+ class="status-icon unavailable" />+ </template>+ {{ checking ? $t('model.editor.testing') : $t('model.editor.testConnection') }}+ </t-button>+ <span v-if="remoteChecked" :class="['footer-test-message', remoteAvailable ? 'success' : 'error']"+ :title="remoteMessage">+ {{ remoteMessage }}+ </span>+ </template>+<t-form ref="formRef" :data="formData" :rules="rules" layout="vertical">- <!-- 模型来源 -->- <div class="form-item">- <label class="form-label required">{{ $t('model.editor.sourceLabel') }}</label>- <t-radio-group v-model="formData.source" class="source-select">- <t-radio-button value="local" :disabled="ollamaServiceStatus === false || modelType === 'rerank'">- {{ $t('model.editor.sourceLocal') }}- </t-radio-button>- <t-radio-button value="remote">{{ $t('model.editor.sourceRemote') }}</t-radio-button>- </t-radio-group>-- <!-- ReRank模型不支持Ollama的提示信息 -->- <div v-if="modelType === 'rerank'" class="ollama-unavailable-tip rerank-tip">- <t-icon name="info-circle-filled" class="tip-icon info" />- <span class="tip-text">{{ $t('model.editor.ollamaNotSupportRerank') }}</span>- </div>- <!-- Ollama不可用时的提示信息 -->- <div v-else-if="shouldShowOllamaUnavailableTip(formData.source, modelType, ollamaServiceStatus)"- class="ollama-unavailable-tip">- <t-icon name="error-circle-filled" class="tip-icon" />- <span class="tip-text">{{ $t('model.editor.ollamaUnavailable') }}</span>- <t-button variant="text" size="small" @click="goToOllamaSettings" class="tip-link">- <template #icon><t-icon name="jump" /></template>- {{ $t('model.editor.goToOllamaSettings') }}- </t-button>+ <!--+ Section 1 — 模型来源 + 模型名称(来源直接决定下方字段,所以放一节)+ -->+ <section class="setting-drawer__section">+ <h4 class="setting-drawer__section-title">{{ $t('model.editor.sectionSource') }}</h4>++ <div class="form-item">+ <!--+ Section title already says 「模型来源」,所以这里不再重复 label,+ 直接把分段控件作为 section 的首个内容呈现,避免「双标题」感。+ -->+ <div class="source-options" role="radiogroup" :aria-label="$t('model.editor.sourceLabel')">+ <button+ type="button"+ class="source-option"+ :class="{ 'is-active': formData.source === 'local', 'is-disabled': ollamaServiceStatus === false || modelType === 'rerank' }"+ :disabled="ollamaServiceStatus === false || modelType === 'rerank'"+ role="radio"+ :aria-checked="formData.source === 'local'"+ @click="formData.source = 'local'"+ >+ <t-icon name="server" class="source-option__icon" />+ <span class="source-option__label">{{ $t('model.editor.sourceLocal') }}</span>+ </button>+ <button+ type="button"+ class="source-option"+ :class="{ 'is-active': formData.source === 'remote' }"+ role="radio"+ :aria-checked="formData.source === 'remote'"+ @click="formData.source = 'remote'"+ >+ <t-icon name="cloud" class="source-option__icon" />+ <span class="source-option__label">{{ $t('model.editor.sourceRemote') }}</span>+ </button>+ </div>++ <!-- ReRank模型不支持Ollama的提示信息 -->+ <div v-if="modelType === 'rerank'" class="ollama-unavailable-tip rerank-tip">+ <t-icon name="info-circle-filled" class="tip-icon info" />+ <span class="tip-text">{{ $t('model.editor.ollamaNotSupportRerank') }}</span>+ </div>++ <!-- Ollama不可用时的提示信息 -->+ <div v-else-if="shouldShowOllamaUnavailableTip(formData.source, modelType, ollamaServiceStatus)"+ class="ollama-unavailable-tip">+ <t-icon name="error-circle-filled" class="tip-icon" />+ <span class="tip-text">{{ $t('model.editor.ollamaUnavailable') }}</span>+ <t-button variant="text" size="small" @click="goToOllamaSettings" class="tip-link">+ <template #icon><t-icon name="jump" /></template>+ {{ $t('model.editor.goToOllamaSettings') }}+ </t-button>+ </div></div>- </div>-- <!-- Ollama 本地模型选择器 -->- <div v-if="formData.source === 'local'" class="form-item">- <label class="form-label required">{{ $t('model.modelName') }}</label>- <div class="model-select-row">- <t-select v-model="formData.modelName" :loading="loadingOllamaModels" :class="{ 'downloading': downloading }"- :style="downloading ? `--progress: ${downloadProgress}%` : ''" filterable :filter="handleModelFilter"- :placeholder="$t('model.searchPlaceholder')" @focus="loadOllamaModels"- @visible-change="handleDropdownVisibleChange">- <!-- 已下载的模型 -->- <t-option v-for="model in filteredOllamaModels" :key="model.name" :value="model.name" :label="model.name">- <div class="model-option">- <t-icon name="check-circle-filled" class="downloaded-icon" />- <span class="model-name">{{ model.name }}</span>- <span class="model-size">{{ formatModelSize(model.size) }}</span>- </div>- </t-option>-- <!-- 下载新模型选项(仅当搜索词不在列表中时显示) -->- <t-option v-if="showDownloadOption" :value="`__download__${searchKeyword}`"- :label="$t('model.editor.downloadLabel', { keyword: searchKeyword })" class="download-option">- <div class="model-option download">- <t-icon name="download" class="download-icon" />- <span class="model-name">{{ $t('model.editor.downloadLabel', { keyword: searchKeyword }) }}</span>- </div>- </t-option>- <!-- 下载进度后缀 -->- <template v-if="downloading" #suffix>- <div class="download-suffix">- <t-icon name="loading" class="spinning" />- <span class="progress-text">{{ downloadProgress.toFixed(1) }}%</span>- </div>- </template>- </t-select>-- <!-- 刷新按钮 -->- <t-button variant="text" size="small" :loading="loadingOllamaModels" @click="refreshOllamaModels"- class="refresh-btn">- <t-icon name="refresh" />- {{ $t('model.editor.refreshList') }}- </t-button>+ <!-- Ollama 本地模型选择器 -->+ <div v-if="formData.source === 'local'" class="form-item">+ <label class="form-label required">{{ $t('model.modelName') }}</label>+ <div class="model-select-row">+ <t-select v-model="formData.modelName" :loading="loadingOllamaModels" :class="{ 'downloading': downloading }"+ :style="downloading ? `--progress: ${downloadProgress}%` : ''" filterable :filter="handleModelFilter"+ :placeholder="$t('model.searchPlaceholder')" @focus="loadOllamaModels"+ @visible-change="handleDropdownVisibleChange">+ <!-- 已下载的模型 -->+ <t-option v-for="model in filteredOllamaModels" :key="model.name" :value="model.name" :label="model.name">+ <div class="model-option">+ <t-icon name="check-circle-filled" class="downloaded-icon" />+ <span class="model-name">{{ model.name }}</span>+ <span class="model-size">{{ formatModelSize(model.size) }}</span>+ </div>+ </t-option>++ <!-- 下载新模型选项(仅当搜索词不在列表中时显示) -->+ <t-option v-if="showDownloadOption" :value="`__download__${searchKeyword}`"+ :label="$t('model.editor.downloadLabel', { keyword: searchKeyword })" class="download-option">+ <div class="model-option download">+ <t-icon name="download" class="download-icon" />+ <span class="model-name">{{ $t('model.editor.downloadLabel', { keyword: searchKeyword }) }}</span>+ </div>+ </t-option>++ <!-- 下载进度后缀 -->+ <template v-if="downloading" #suffix>+ <div class="download-suffix">+ <t-icon name="loading" class="spinning" />+ <span class="progress-text">{{ downloadProgress.toFixed(1) }}%</span>+ </div>+ </template>+ </t-select>++ <!-- 刷新按钮 -->+ <t-button variant="text" size="small" :loading="loadingOllamaModels" @click="refreshOllamaModels"+ class="refresh-btn">+ <t-icon name="refresh" />+ {{ $t('model.editor.refreshList') }}+ </t-button>+ </div></div>- </div>+ </section><!-- Remote API 配置 --><template v-if="formData.source === 'remote'">- <!-- 厂商选择器 -->- <div class="form-item">- <label class="form-label">{{ $t('model.editor.providerLabel') }}</label>- <t-select v-model="formData.provider" :placeholder="$t('model.editor.providerPlaceholder')"- @change="handleProviderChange" :popup-props="{ overlayClassName: 'provider-select-popup' }">- <t-option v-for="opt in providerOptions" :key="opt.value" :value="opt.value" :label="opt.label">- <div class="provider-option">- <span class="provider-name">{{ opt.label }}</span>- <span class="provider-desc">{{ opt.description }}</span>- </div>- </t-option>- </t-select>- </div>+ <section class="setting-drawer__section">+ <h4 class="setting-drawer__section-title">{{ $t('model.editor.sectionProvider') }}</h4>++ <!-- 厂商选择器 -->+ <div class="form-item">+ <label class="form-label">{{ $t('model.editor.providerLabel') }}</label>+ <t-select v-model="formData.provider" :placeholder="$t('model.editor.providerPlaceholder')"+ @change="handleProviderChange" :popup-props="{ overlayClassName: 'provider-select-popup' }">+ <!--+ show-overflow-tooltip=false: TDesign 默认在 hover 时给选项浮一个+ 完整 label 的小气泡,但这里选项本身就是双行(主名 + 描述),不会+ 出现省略,tooltip 只会和已经命中的灰底打架。直接关掉。+ -->+ <t-option v-for="opt in providerOptions" :key="opt.value" :value="opt.value" :label="opt.label"+ :show-overflow-tooltip="false">+ <div class="provider-option">+ <span class="provider-name">{{ opt.label }}</span>+ <span class="provider-desc">{{ opt.description }}</span>+ </div>+ </t-option>+ </t-select>+ </div>- <!-- WeKnoraCloud 提示信息 -->- <template v-if="formData.provider === 'weknoracloud'">- <!-- 凭证已配置 -->- <div v-if="wkcCredentialState === 'configured'" class="weknoracloud-hint weknoracloud-hint--ok">- <t-icon name="check-circle-filled"- style="font-size: 16px; color: var(--td-success-color); flex-shrink: 0;" />- <div>- {{ $t('settings.weknoraCloud.modelHintConfigured') }}- <a href="https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html"- target="_blank" rel="noopener noreferrer" class="doc-link">- {{ $t('settings.weknoraCloud.modelHintDocsLink') }}- <t-icon name="link" class="link-icon" />- </a>+ <!-- WeKnoraCloud 提示信息 -->+ <template v-if="formData.provider === 'weknoracloud'">+ <!-- 凭证已配置 -->+ <div v-if="wkcCredentialState === 'configured'" class="weknoracloud-hint weknoracloud-hint--ok">+ <t-icon name="check-circle-filled" class="hint-icon hint-icon--ok" />+ <div>+ {{ $t('settings.weknoraCloud.modelHintConfigured') }}+ <a href="https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html"+ target="_blank" rel="noopener noreferrer" class="doc-link">+ {{ $t('settings.weknoraCloud.modelHintDocsLink') }}+ <t-icon name="link" class="link-icon" />+ </a>+ </div></div>- </div>- <!-- 未配置 / 失效 -->- <div v-else-if="wkcCredentialState !== 'loading'" class="weknoracloud-hint weknoracloud-hint--warn">- <t-icon name="error-circle-filled" style="font-size: 16px; color: #f97316; flex-shrink: 0;" />- <div style="flex: 1;">- <template v-if="wkcCredentialState === 'expired'">- {{ $t('settings.weknoraCloud.credentialExpired') }}- </template>- <template v-else>- {{ $t('settings.weknoraCloud.credentialUnconfigured') }}- </template>- <div style="margin-top: 8px;">- <t-button variant="text" size="small" @click="goToWeKnoraCloudSettings"- style="padding: 0; height: auto;">- <template #icon><t-icon name="jump" /></template>- {{ $t('settings.weknoraCloud.goToSettings') }}- </t-button>+ <!-- 未配置 / 失效 -->+ <div v-else-if="wkcCredentialState !== 'loading'" class="weknoracloud-hint weknoracloud-hint--warn">+ <t-icon name="error-circle-filled" class="hint-icon hint-icon--warn" />+ <div style="flex: 1;">+ <template v-if="wkcCredentialState === 'expired'">+ {{ $t('settings.weknoraCloud.credentialExpired') }}+ </template>+ <template v-else>+ {{ $t('settings.weknoraCloud.credentialUnconfigured') }}+ </template>+ <div style="margin-top: 8px;">+ <t-button variant="text" size="small" @click="goToWeKnoraCloudSettings"+ style="padding: 0; height: auto;">+ <template #icon><t-icon name="jump" /></template>+ {{ $t('settings.weknoraCloud.goToSettings') }}+ </t-button>+ </div></div></div>- </div>- <!-- 加载中 -->- <div v-else class="weknoracloud-hint">- <t-icon name="loading" class="spinning"- style="font-size: 16px; color: var(--td-text-color-placeholder); flex-shrink: 0;" />- <span>{{ $t('settings.weknoraCloud.checkingStatus') }}</span>- </div>- </template>+ <!-- 加载中 -->+ <div v-else class="weknoracloud-hint">+ <t-icon name="loading" class="spinning hint-icon hint-icon--loading" />+ <span>{{ $t('settings.weknoraCloud.checkingStatus') }}</span>+ </div>+ </template>- <!-- 模型名称 -->- <div class="form-item">- <label class="form-label required">{{ $t('model.modelName') }}</label>- <t-input v-model="formData.modelName" :placeholder="getModelNamePlaceholder()"- :disabled="formData.provider === 'weknoracloud' && wkcCredentialState !== 'configured'" />- </div>+ <!-- 模型名称 -->+ <div class="form-item">+ <label class="form-label required">{{ $t('model.modelName') }}</label>+ <t-input v-model="formData.modelName" :placeholder="getModelNamePlaceholder()"+ :disabled="formData.provider === 'weknoracloud' && wkcCredentialState !== 'configured'" />+ </div>- <div class="form-item">- <label class="form-label">{{ $t('model.editor.displayNameLabel') }}</label>- <t-input v-model="formData.displayName" :placeholder="$t('model.editor.displayNamePlaceholder')" />- <p class="form-desc">{{ $t('model.editor.displayNameDesc') }}</p>- </div>+ <div class="form-item">+ <label class="form-label">{{ $t('model.editor.displayNameLabel') }}</label>+ <t-input v-model="formData.displayName" :placeholder="$t('model.editor.displayNamePlaceholder')" />+ <p class="form-desc">{{ $t('model.editor.displayNameDesc') }}</p>+ </div>- <div v-if="formData.provider !== 'weknoracloud'" class="form-item">- <label class="form-label required">{{ $t('model.editor.baseUrlLabel') }}</label>- <t-input v-model="formData.baseUrl" :placeholder="getBaseUrlPlaceholder()" />- </div>+ <div v-if="formData.provider !== 'weknoracloud'" class="form-item">+ <label class="form-label required">{{ $t('model.editor.baseUrlLabel') }}</label>+ <t-input v-model="formData.baseUrl" :placeholder="getBaseUrlPlaceholder()" />+ </div>- <div v-if="formData.provider !== 'weknoracloud'" class="form-item">- <label class="form-label">{{ $t('model.editor.apiKeyOptional') }}</label>- <!--+ <div v-if="formData.provider !== 'weknoracloud'" class="form-item">+ <label class="form-label">{{ $t('model.editor.apiKeyOptional') }}</label>+ <!--Edit mode: credentials live behind the /credentials subresource- of the model — managed by the shared CredentialResource card.- Create mode: the resource doesn't exist yet, so accept the- initial API key in the form and POST it with the rest.+ of the model — managed by the shared CredentialResource card,+ which now renders an INPUT-LOOKING row (32px tall, same border+ + radius as t-input) so it sits flush with the Base URL field+ above and the 自定义请求头 controls below — no more+ "card inside a card" feel.+ Create mode: the resource doesn't exist yet, so we render a+ plain password input with a leading lock icon and a trailing+ show/hide eye toggle.-->- <CredentialResource v-if="isEdit && props.modelData?.id" :api="credentialApi" :fields="credentialFields"- :meta="credentialMeta" />- <t-input v-else v-model="formData.apiKey" type="password" :placeholder="apiKeyPlaceholder" />- </div>-- <!-- 自定义 HTTP Header(类似 OpenAI Python SDK 的 extra_headers) -->- <div v-if="formData.provider !== 'weknoracloud'" class="form-item">- <div class="custom-headers-header">- <label class="form-label" style="margin-bottom: 0;">{{ $t('model.editor.customHeadersLabel') }}</label>- <t-button variant="text" size="small" theme="primary" @click="addCustomHeader">- <template #icon><t-icon name="add" /></template>- {{ $t('model.editor.customHeadersAdd') }}- </t-button>+ <CredentialResource v-if="isEdit && props.modelData?.id" :api="credentialApi" :fields="credentialFields"+ :meta="credentialMeta" />+ <t-input v-else v-model="formData.apiKey" :type="showApiKey ? 'text' : 'password'"+ :placeholder="apiKeyPlaceholder" class="api-key-input" autocomplete="off" spellcheck="false">+ <template #prefix-icon><t-icon name="lock-on" /></template>+ <template #suffix-icon>+ <t-icon+ :name="showApiKey ? 'browse-off' : 'browse'"+ class="api-key-toggle"+ :aria-label="showApiKey ? 'Hide' : 'Show'"+ @click.stop="showApiKey = !showApiKey"+ />+ </template>+ </t-input></div>- <p class="form-desc custom-headers-desc">{{ $t('model.editor.customHeadersDesc') }}</p>- <div v-if="formData.customHeaders && formData.customHeaders.length > 0" class="custom-headers-list">- <div v-for="(item, idx) in formData.customHeaders" :key="idx" class="custom-header-row">- <t-input v-model="item.key" :placeholder="$t('model.editor.customHeadersKeyPlaceholder')"- class="custom-header-key" />- <t-input v-model="item.value" :placeholder="$t('model.editor.customHeadersValuePlaceholder')"- class="custom-header-value" />- <t-button variant="text" shape="square" size="small" theme="danger" @click="removeCustomHeader(idx)"- :aria-label="$t('common.delete')">- <t-icon name="close" />++ <!-- 自定义 HTTP Header(类似 OpenAI Python SDK 的 extra_headers) -->+ <div v-if="formData.provider !== 'weknoracloud'" class="form-item">+ <div class="custom-headers-header">+ <label class="form-label" style="margin-bottom: 0;">{{ $t('model.editor.customHeadersLabel') }}</label>+ <t-button variant="text" size="small" theme="primary" @click="addCustomHeader">+ <template #icon><t-icon name="add" /></template>+ {{ $t('model.editor.customHeadersAdd') }}</t-button></div>+ <p class="form-desc custom-headers-desc">{{ $t('model.editor.customHeadersDesc') }}</p>+ <div v-if="formData.customHeaders && formData.customHeaders.length > 0" class="custom-headers-list">+ <div v-for="(item, idx) in formData.customHeaders" :key="idx" class="custom-header-row">+ <t-input v-model="item.key" :placeholder="$t('model.editor.customHeadersKeyPlaceholder')"+ class="custom-header-key" />+ <t-input v-model="item.value" :placeholder="$t('model.editor.customHeadersValuePlaceholder')"+ class="custom-header-value" />+ <t-button variant="text" shape="square" size="small" class="custom-header-remove"+ @click="removeCustomHeader(idx)" :aria-label="$t('common.delete')">+ <t-icon name="close" />+ </t-button>+ </div>+ </div></div>- </div>- <!-- Remote API 校验 -->- <div class="form-item">- <label class="form-label">{{ $t('model.editor.connectionTest') }}</label>- <div class="api-test-section">- <t-button variant="outline" @click="checkRemoteAPI" :loading="checking"- :disabled="!formData.modelName || (!formData.baseUrl && formData.provider !== 'weknoracloud') || (formData.provider === 'weknoracloud' && wkcCredentialState !== 'configured')">- <template #icon>- <t-icon v-if="!checking && remoteChecked && remoteAvailable" name="check-circle-filled"- class="status-icon available" />- <t-icon v-else-if="!checking && remoteChecked && !remoteAvailable" name="close-circle-filled"- class="status-icon unavailable" />- </template>- {{ checking ? $t('model.editor.testing') : $t('model.editor.testConnection') }}+ <!--+ Connection test action moved to the drawer footer (footer-left+ slot above) so primary actions live in one row at the bottom.+ -->+ </section>+ </template>++ <!-- Section 3 — 高级选项(仅在有内容时渲染,避免空 section 出现底部分隔线) -->+ <section v-if="modelType === 'embedding' || modelType === 'chat'" class="setting-drawer__section">+ <h4 class="setting-drawer__section-title">{{ $t('model.editor.sectionAdvanced') }}</h4>++ <!-- Embedding 专用:维度 -->+ <div v-if="modelType === 'embedding'" class="form-item">+ <label class="form-label">{{ $t('model.editor.dimensionLabel') }}</label>+ <div class="dimension-control">+ <t-input v-model.number="formData.dimension" type="number" :min="128" :max="4096"+ :placeholder="$t('model.editor.dimensionPlaceholder')"+ :disabled="formData.source === 'local' && checking" />+ <!-- Ollama 本地模型:自动检测维度按钮 -->+ <t-button v-if="formData.source === 'local' && formData.modelName" variant="text" size="small"+ :loading="checking" @click="checkOllamaDimension" class="dimension-check-btn">+ <t-icon name="refresh" />+ {{ $t('model.editor.checkDimension') }}</t-button>- <span v-if="remoteChecked" :class="['test-message', remoteAvailable ? 'success' : 'error']">- {{ remoteMessage }}- </span></div>+ <p v-if="dimensionChecked && dimensionMessage" class="dimension-hint" :class="{ success: dimensionSuccess }">+ {{ dimensionMessage }}+ </p></div>- </template>- <!-- Embedding 专用:维度 -->- <div v-if="modelType === 'embedding'" class="form-item">- <label class="form-label">{{ $t('model.editor.dimensionLabel') }}</label>- <div class="dimension-control">- <t-input v-model.number="formData.dimension" type="number" :min="128" :max="4096"- :placeholder="$t('model.editor.dimensionPlaceholder')"- :disabled="formData.source === 'local' && checking" />- <!-- Ollama 本地模型:自动检测维度按钮 -->- <t-button v-if="formData.source === 'local' && formData.modelName" variant="text" size="small"- :loading="checking" @click="checkOllamaDimension" class="dimension-check-btn">- <t-icon name="refresh" />- {{ $t('model.editor.checkDimension') }}- </t-button>- </div>- <p v-if="dimensionChecked && dimensionMessage" class="dimension-hint" :class="{ success: dimensionSuccess }">- {{ dimensionMessage }}- </p>- </div>-- <!-- Chat: supports vision toggle (VLLM models are inherently multimodal) -->- <div v-if="modelType === 'chat'" class="form-item">- <label class="form-label">{{ $t('model.editor.supportsVisionLabel') }}</label>- <div style="display: flex; align-items: center; gap: 8px;">- <t-switch v-model="formData.supportsVision" />- <span class="form-desc">{{ $t('model.editor.supportsVisionDesc') }}</span>+ <!-- Chat: supports vision toggle (VLLM models are inherently multimodal) -->+ <div v-if="modelType === 'chat'" class="form-item">+ <label class="form-label">{{ $t('model.editor.supportsVisionLabel') }}</label>+ <div class="vision-toggle">+ <t-switch v-model="formData.supportsVision" />+ <span class="form-desc form-desc--inline">{{ $t('model.editor.supportsVisionDesc') }}</span>+ </div></div>- </div>+ </section></t-form></SettingDrawer>@@ -464,6 +531,20 @@ const dialogVisible = computed({const isEdit = computed(() => !!props.modelData)+// Header icon for the SettingDrawer — uses the same TDesign icon name table+// as the model card list, so the drawer's leading badge visually matches the+// card the user just clicked on.+const modelTypeIcon = computed(() => {+ const map: Record<string, string> = {+ chat: 'chat',+ embedding: 'chart-bubble',+ rerank: 'filter-sort',+ vllm: 'image',+ asr: 'sound',+ }+ return map[props.modelType] || 'setting'+})+// Credential resource binding for the shared <CredentialResource> component.// "app_secret" is only relevant for the WeKnora Cloud provider; the visible// fields collapse to just api_key for every other provider. We always pass@@ -506,6 +587,12 @@ const apiKeyPlaceholder = computed(() => t('model.editor.apiKeyPlaceholder'))const formRef = ref()const saving = ref(false)+// Toggles the create-mode API key input between masked and plain text. Lets+// the user proofread a freshly pasted secret without losing the password+// affordance for everyday use. Reset every time the drawer closes (see+// reset block in the visible watcher) so we never leak the previous value+// across editor sessions.+const showApiKey = ref(false)const modelChecked = ref(false)const modelAvailable = ref(false)const checking = ref(false)@@ -765,6 +852,7 @@ const resetForm = () => {dimensionChecked.value = falsedimensionSuccess.value = falsedimensionMessage.value = ''+ showApiKey.value = false}// 处理厂商选择变化 (自动填充默认 URL)@@ -1269,11 +1357,10 @@ const handleCancel = () => {// 表单项样式.form-item {- margin-bottom: 16px;-- &:last-child {- margin-bottom: 0;- }+ // No bottom margin — vertical rhythm is owned by the parent+ // .setting-drawer__section's `gap`. That keeps the spacing inside a section+ // tight and the gap between sections visually distinct.+ margin-bottom: 0;}.form-label {@@ -1282,24 +1369,73 @@ const handleCancel = () => {font-size: 13px;font-weight: 500;color: var(--td-text-color-primary);+ line-height: 1.4;- &.required::after {+ // TDesign-style required marker: leading asterisk before the label text,+ // matching the rest of the app's <t-form-item required ...> appearance.+ &.required::before {content: '*';color: var(--td-error-color);- margin-left: 4px;+ margin-right: 4px;font-weight: 500;+ line-height: 1;}}-// 模型来源分段:两个选项等分宽度-.source-select {- display: flex;- width: 100%;+// 模型来源分段:紧凑单行 pill 形 segmented。容器自身是浅底圆角条,+// 选中按钮通过实色背景 + 主题色描边浮出,未选中态接近透明,节省纵向空间。+.source-options {+ display: inline-flex;+ align-items: center;+ gap: 4px;+ padding: 3px;+ background: var(--td-bg-color-component);+ border: 1px solid var(--td-component-stroke);+ border-radius: 8px;+}- :deep(.t-radio-button) {- flex: 1;- text-align: center;+.source-option {+ display: inline-flex;+ align-items: center;+ gap: 6px;+ padding: 5px 12px;+ height: 28px;+ background: transparent;+ border: 1px solid transparent;+ border-radius: 6px;+ cursor: pointer;+ font-family: inherit;+ font-size: 13px;+ color: var(--td-text-color-secondary);+ line-height: 1;+ transition: all 0.15s ease;++ &:hover:not(.is-disabled):not(.is-active) {+ color: var(--td-text-color-primary);+ background: var(--td-bg-color-container-hover);}++ &.is-active {+ background: var(--td-bg-color-container);+ border-color: var(--td-brand-color);+ color: var(--td-brand-color);+ font-weight: 500;+ box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);+ }++ &.is-disabled {+ cursor: not-allowed;+ opacity: 0.45;+ }+}++.source-option__icon {+ font-size: 14px;+ flex-shrink: 0;+}++.source-option__label {+ white-space: nowrap;}// 输入框样式:只在最外层 .t-input 上调字号,避免在内部 wrap/inner 上重复加边@@ -1325,11 +1461,41 @@ const handleCancel = () => {}}-// API 测试区域+// API Key 输入:前置 lock 图标 + 后置可点击的"显示/隐藏"小眼睛。+// TDesign 默认会让 prefix-icon 显示成灰色,这里没动;suffix 上的眼睛+// 用 placeholder 色,hover 时切到主文本色,避免抢戏。+.api-key-input {+ :deep(.t-input__prefix) {+ color: var(--td-text-color-placeholder);+ }++ :deep(.t-input__suffix) {+ color: var(--td-text-color-placeholder);+ }++ .api-key-toggle {+ cursor: pointer;+ transition: color 0.15s ease;+ font-size: 16px;++ &:hover {+ color: var(--td-text-color-primary);+ }+ }+}++// API 测试区域 — 弱卡片化:用浅底 + dashed 边把"操作 + 反馈"框成一块,+// 让用户视觉上把它当成一个独立的"动作单元",而不是又一个普通字段。+// (历史样式保留:仅当某个分支仍以 inline 方式渲染测试块时使用;当前 RemoteAPI+// 测试已上移到 SettingDrawer footer-left 槽,主流程不再走这块。).api-test-section {display: flex;align-items: center;gap: 12px;+ padding: 10px 12px;+ background: var(--td-bg-color-container-hover);+ border: 1px dashed var(--td-component-stroke);+ border-radius: 8px;.test-message {font-size: 13px;@@ -1367,29 +1533,82 @@ const handleCancel = () => {}}+// Connection-test message rendered next to the test button in the drawer+// footer. Truncates with ellipsis so a long backend error doesn't push+// Save/Cancel off-screen — the full text is in the title attribute.+.footer-test-message {+ font-size: 12px;+ line-height: 1.4;+ flex: 1;+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;++ &.success {+ color: var(--td-brand-color-active);+ }++ &.error {+ color: var(--td-error-color);+ }+}++// Status icon variant used inside the footer button.+.status-icon {+ font-size: 16px;+ flex-shrink: 0;++ &.available {+ color: var(--td-brand-color);+ }++ &.unavailable {+ color: var(--td-error-color);+ }+}+// WeKnoraCloud 提示信息.weknoracloud-hint {display: flex;align-items: flex-start;- gap: 8px;- margin-bottom: 20px;- padding: 10px 12px;- border-radius: 6px;+ gap: 10px;+ padding: 12px 14px;+ border-radius: 8px;font-size: 13px;color: var(--td-text-color-secondary);line-height: 1.5;+ // Theming via tokens so the warn/ok states track light/dark switches+ // instead of fighting hardcoded `#fff7ed` etc.&--ok {background: var(--td-success-color-light);border: 1px solid var(--td-success-color-focus);}&--warn {- background: #fff7ed;- border: 1px solid #fed7aa;- border-left: 3px solid #f97316;+ background: var(--td-warning-color-light, #fff7ed);+ border: 1px solid var(--td-warning-color-focus, #fed7aa);+ border-left: 3px solid var(--td-warning-color, #f97316);}+ .hint-icon {+ font-size: 16px;+ flex-shrink: 0;+ margin-top: 2px;++ &--ok {+ color: var(--td-success-color);+ }++ &--warn {+ color: var(--td-warning-color, #f97316);+ }++ &--loading {+ color: var(--td-text-color-placeholder);+ }+ }}// Ollama 模型选择器样式@@ -1564,11 +1783,22 @@ const handleCancel = () => {flex: 1;}- :deep(.t-button) {+ // Ghost icon button — matches the model-card "more" affordance: invisible+ // until hover/focus, then a subtle background pops in. Avoids painting a+ // permanent red splotch next to every header row.+ .custom-header-remove {flex-shrink: 0;width: 32px;height: 32px;padding: 0;+ color: var(--td-text-color-placeholder);+ border-radius: 6px;+ transition: all 0.18s ease;++ &:hover {+ background: var(--td-error-color-light);+ color: var(--td-error-color);+ }}}@@ -1577,6 +1807,18 @@ const handleCancel = () => {font-size: 12px;line-height: 1.5;color: var(--td-text-color-placeholder);++ // Inline with switches/checkboxes — drops the top margin so the label and+ // helper text sit on the same baseline.+ &--inline {+ margin: 0;+ }+}++.vision-toggle {+ display: flex;+ align-items: center;+ gap: 8px;}// Ollama不可用提示样式@@ -1588,7 +1830,7 @@ const handleCancel = () => {padding: 10px 12px;background: var(--td-error-color-light);border: 1px solid var(--td-error-color-focus);- border-radius: 6px;+ border-radius: 8px;font-size: 13px;.tip-icon {@@ -1670,26 +1912,57 @@ const handleCancel = () => {<!-- 非 scoped 样式:t-select popup 渲染到 body 下,scoped 样式无法覆盖 --><style lang="less">.provider-select-popup {+ // 容器留点呼吸:避免选项贴着 popup 圆角+ padding: 4px;++ // TDesign 默认会在 t-select-option 上挂一个 overflow tooltip(浮在右侧+ // 显示完整 label)。我们的选项排版是「主名称 + 次描述」两行,永远不会+ // 触发省略,tooltip 反而成了视觉噪音 → 直接隐藏 popup 自带的提示。+ + .t-popup .t-tooltip,+ ~ .t-popup .t-tooltip {+ display: none !important;+ }- // 覆盖 TDesign option 默认固定高度,让两行内容正常展示.t-select-option {height: auto !important;- padding: 6px 12px;+ padding: 8px 10px;border-radius: 6px;- margin: 0 4px;+ margin: 2px 0;outline: none;+ transition: background-color 0.15s ease;&:focus,&:focus-visible {outline: none;}++ // hover 态:用浅 brand 色而非强灰,跟主题色调一致+ &:hover:not(.t-is-selected) {+ background-color: var(--td-bg-color-container-hover);+ }}- // 命中态:浅一点的底色,去掉默认的描边/反色+ // 命中态:浅一点的底色 + 左侧主题色条作为 affordance,不再用全填的灰底.t-select-option.t-is-selected {background-color: var(--td-brand-color-light);color: var(--td-text-color-primary);font-weight: 500;+ position: relative;++ &::before {+ content: '';+ position: absolute;+ left: 0;+ top: 8px;+ bottom: 8px;+ width: 3px;+ background: var(--td-brand-color);+ border-radius: 0 2px 2px 0;+ }++ .provider-name {+ color: var(--td-brand-color);+ }}.provider-option {diff --git a/frontend/src/components/credentials/CredentialResource.vue b/frontend/src/components/credentials/CredentialResource.vueindex c441695ec..114626e26 100644--- a/frontend/src/components/credentials/CredentialResource.vue+++ b/frontend/src/components/credentials/CredentialResource.vue@@ -27,51 +27,102 @@<template><div class="credential-resource"><div v-for="field in fields" :key="field.key" class="credential-row">- <!-- Configured: read-only badge + actions -->+ <!--+ Per-field label, rendered only when there is more than one credential+ (e.g. WeKnora Cloud's api_key + app_secret) so a single-field card+ doesn't double up with the parent's outer .form-label. Single-field+ consumers (ModelEditorDialog API key, WebSearch provider api_key,+ McpService api_key) keep showing the parent label only.+ -->+ <div v-if="fields.length > 1" class="credential-row-label">{{ field.label }}</div>++ <!-- Configured: faux input row (visually identical to t-input) --><template v-if="stateOf(field.key) === 'configured'">- <div class="credential-summary">- <t-icon name="check-circle-filled" class="status-icon success" />- <div class="credential-meta">- <div class="credential-label">{{ field.label }}</div>- <div class="credential-sub">{{ t('credential.configured') }}</div>- </div>- <div class="credential-actions">- <t-button size="small" variant="outline" @click="enterEdit(field.key)">- {{ t('credential.update') }}- </t-button>- <t-button size="small" variant="outline" theme="danger" :loading="busy[field.key] === 'remove'"- @click="onRemove(field)">- {{ t('credential.remove') }}- </t-button>- </div>+ <!--+ Two possible looks:+ a) default — ✓ 已配置 + [更换 | 移除]+ b) confirm-remove pending — ⚠ 确认移除?此操作不可撤销 + [取消 | 确认移除]++ We use a sub-state instead of a global modal because the modal+ forces the user to context-switch to the screen center, then back+ to this row to see the result. Inline confirm keeps focus on the+ row that's actually changing.+ -->+ <div+ class="credential-faux-input"+ :class="{ 'is-confirm-remove': pendingRemove[field.key] }"+ :title="pendingRemove[field.key] ? '' : t('credential.configured')"+ >+ <template v-if="pendingRemove[field.key]">+ <t-icon name="error-circle-filled" class="status-icon warn" />+ <span class="credential-faux-text danger">{{ t('credential.confirmRemovePrompt') }}</span>+ <div class="credential-actions">+ <t-button size="small" variant="text" @click="cancelPendingRemove(field.key)">+ {{ t('common.cancel') }}+ </t-button>+ <span class="action-divider"></span>+ <t-button size="small" variant="text" theme="danger" :loading="busy[field.key] === 'remove'"+ @click="confirmRemove(field)">+ {{ t('credential.confirmRemove') }}+ </t-button>+ </div>+ </template>+ <template v-else>+ <t-icon name="check-circle-filled" class="status-icon success" />+ <span class="credential-faux-text">{{ t('credential.configured') }}</span>+ <div class="credential-actions">+ <t-button size="small" variant="text" @click="enterEdit(field.key)">+ {{ t('credential.update') }}+ </t-button>+ <span class="action-divider"></span>+ <t-button size="small" variant="text" theme="danger" @click="requestRemove(field.key)">+ {{ t('credential.remove') }}+ </t-button>+ </div>+ </template></div></template>- <!-- Unconfigured: collapsed prompt + "Configure" -->+ <!-- Unconfigured: faux input row with a single "Configure" affordance --><template v-else-if="stateOf(field.key) === 'unconfigured'">- <div class="credential-summary">- <t-icon name="info-circle" class="status-icon muted" />- <div class="credential-meta">- <div class="credential-label">{{ field.label }}</div>- <div class="credential-sub">{{ t('credential.unconfigured') }}</div>- </div>- <div class="credential-actions">- <t-button size="small" variant="outline" @click="enterEdit(field.key)">- {{ t('credential.configure') }}- </t-button>- </div>+ <div+ class="credential-faux-input is-empty"+ :class="{ 'is-just-removed': inlineToast[field.key]?.kind === 'removed' }"+ @click="enterEdit(field.key)"+ >+ <!--+ Right after a successful remove we hold the row in place but swap+ the icon + placeholder text for a brief success state. After+ ~2.4s the row fades back to its plain "未配置" prompt. This+ keeps feedback anchored to where the user just clicked, instead+ of asking them to glance at a global toast somewhere else.+ -->+ <template v-if="inlineToast[field.key]?.kind === 'removed'">+ <t-icon name="check-circle-filled" class="status-icon success" />+ <span class="credential-faux-text">{{ t('credential.removedToast') }}</span>+ </template>+ <template v-else>+ <t-icon name="lock-on" class="status-icon muted" />+ <span class="credential-faux-text muted">{{ t('credential.unconfigured') }}</span>+ <div class="credential-actions">+ <t-button size="small" variant="text" theme="primary" @click.stop="enterEdit(field.key)">+ {{ t('credential.configure') }}+ </t-button>+ </div>+ </template></div></template>- <!-- Editing: inline input + Save / Cancel -->+ <!-- Editing: real input + tiny action row beneath --><template v-else><div class="credential-edit">- <div class="credential-label">{{ field.label }}</div><t-input v-model="drafts[field.key]" type="password":placeholder="field.placeholder ?? t('credential.inputPlaceholder')" :autocomplete="'new-password'"- @keydown.enter.prevent="onSave(field)" />+ class="credential-edit-input" @keydown.enter.prevent="onSave(field)">+ <template #prefix-icon><t-icon name="lock-on" /></template>+ </t-input><div class="credential-edit-actions">- <t-button size="small" variant="outline" @click="cancelEdit(field.key)">+ <t-button size="small" variant="text" @click="cancelEdit(field.key)">{{ t('common.cancel') }}</t-button><t-button size="small" theme="primary" :loading="busy[field.key] === 'save'" :disabled="!drafts[field.key]"@@ -86,7 +137,7 @@</template><script setup lang="ts" generic="K extends string">-import { ref, reactive, watch } from 'vue'+import { onBeforeUnmount, reactive, ref, watch } from 'vue'import { useI18n } from 'vue-i18n'import { MessagePlugin } from 'tdesign-vue-next'@@ -134,6 +185,31 @@ const states = reactive<Record<string, State>>({})const drafts = reactive<Record<string, string>>({})const busy = reactive<Record<string, 'save' | 'remove' | null>>({})+// Per-field "did the user just press Remove" flag. While true, the+// configured row swaps to an inline confirm prompt instead of immediately+// deleting. Cleared on cancel, on the actual DELETE request firing, and+// any time the field leaves the configured state for any other reason.+const pendingRemove = reactive<Record<string, boolean>>({})++// Inline per-field flash message used as an anchored "toast" instead of the+// global MessagePlugin one for actions whose effect happens at this exact+// row (currently: remove). Cleared after a short delay so the row reverts+// to its normal placeholder. Keyed by field.key.+type InlineToastKind = 'removed'+const inlineToast = reactive<Record<string, { kind: InlineToastKind } | null>>({})+const inlineToastTimers: Record<string, ReturnType<typeof setTimeout> | null> = {}++function flashInlineToast(key: string, kind: InlineToastKind, ms = 2400) {+ inlineToast[key] = { kind }+ if (inlineToastTimers[key]) {+ clearTimeout(inlineToastTimers[key]!)+ }+ inlineToastTimers[key] = setTimeout(() => {+ inlineToast[key] = null+ inlineToastTimers[key] = null+ }, ms)+}+function deriveStatesFromMeta(meta: Record<string, { configured: boolean }>) {for (const f of props.fields) {// Preserve in-progress edits across parent re-renders — `meta` describes@@ -157,6 +233,7 @@ watch(watch(() => props.api, () => {for (const k of Object.keys(states)) delete states[k]for (const k of Object.keys(drafts)) delete drafts[k]+ for (const k of Object.keys(pendingRemove)) delete pendingRemove[k]})function stateOf(key: string): State {@@ -166,6 +243,10 @@ function stateOf(key: string): State {function enterEdit(key: string) {drafts[key] = ''states[key] = 'editing'+ // If the user was mid-confirm and changed their mind ("update" instead+ // of "remove"), drop the pending flag so we don't bounce back into the+ // confirm UI when they cancel the edit.+ pendingRemove[key] = false}// Cancel returns directly to whatever the parent told us via props.meta —@@ -202,18 +283,29 @@ async function onSave(field: CredentialFieldDef) {}}-// Remove is a single-click action: skip the modal confirm dialog and just-// do it, with a toast for feedback. Rationale: the secret is irrecoverable-// from the client side regardless of whether we confirm (we never had the-// plaintext), so a modal adds friction without adding safety — re-typing-// the secret is the recovery path either way. The danger-themed "Remove"-// button itself already serves as a visual deterrent against misclicks.-async function onRemove(field: CredentialFieldDef) {+// Two-step remove. First click flips the row to a confirm state; second+// click actually fires DELETE. We deliberately do NOT use a global modal+// here — the row is also the place where the result will appear, and a+// modal forces an unnecessary screen-center detour. The danger-themed+// "确认移除" button on a tinted-warning row gives the same protection+// against fat-fingered destructive clicks without that detour.+//+// Errors still surface via global MessagePlugin so the user can't miss them.+function requestRemove(key: string) {+ pendingRemove[key] = true+}++function cancelPendingRemove(key: string) {+ pendingRemove[key] = false+}++async function confirmRemove(field: CredentialFieldDef) {busy[field.key] = 'remove'try {await props.api.remove(field.key as K)states[field.key] = 'unconfigured'- MessagePlugin.success(t('credential.removedToast'))+ pendingRemove[field.key] = false+ flashInlineToast(field.key, 'removed')emit('changed')} catch (err: any) {MessagePlugin.error(err?.message || t('credential.removeFailed'))@@ -221,54 +313,152 @@ async function onRemove(field: CredentialFieldDef) {busy[field.key] = null}}++// Cancel pending inline-toast timers when the component unmounts so we+// don't write to a torn-down reactive object after navigation.+onBeforeUnmount(() => {+ for (const k of Object.keys(inlineToastTimers)) {+ if (inlineToastTimers[k]) {+ clearTimeout(inlineToastTimers[k]!)+ inlineToastTimers[k] = null+ }+ }+})</script><style scoped lang="less">.credential-resource {display: flex;flex-direction: column;- gap: 12px;+ gap: 8px;}.credential-row {- border: 1px solid var(--td-component-stroke);- border-radius: 6px;- padding: 12px 14px;- background: var(--td-bg-color-container);+ /* Empty wrapper now — each state owns its own outer styling so the+ "configured" and "unconfigured" rows can mimic a t-input exactly,+ and the editing state can defer the chrome to t-input itself. */+}++.credential-row-label {+ font-size: 13px;+ font-weight: 500;+ color: var(--td-text-color-primary);+ margin-bottom: 4px;+ line-height: 1.4;}-.credential-summary {+/*+ Faux-input row: visually identical to a TDesign default t-input+ - 32px tall+ - same border (--td-component-border) + radius (6px) + bg+ - 0 12px horizontal padding+ This makes the credential card stop looking like "a card inside a card"+ when it sits between Base URL and 自定义请求头 — it reads as a normal+ field, just one that doesn't accept typed input.+*/+.credential-faux-input {display: flex;align-items: center;- gap: 12px;-}+ gap: 8px;+ height: 32px;+ padding: 0 4px 0 12px;+ background: var(--td-bg-color-container);+ border: 1px solid var(--td-component-border);+ border-radius: 6px;+ font-size: 13px;+ transition: border-color 0.15s ease, background-color 0.15s ease;-.credential-meta {- flex: 1;- min-width: 0;+ &:hover {+ border-color: var(--td-brand-color-hover);+ }++ &.is-empty {+ cursor: pointer;+ background: var(--td-bg-color-container);++ &:hover {+ background: var(--td-bg-color-container-hover);+ }+ }++ /*+ Just-removed flash state: brief tinted background + brand-color border+ so the row gives the user clear, anchored confirmation that the remove+ actually happened — no need for them to find a corner toast. Auto-fades+ after ~2.4s back to plain "未配置" via the inlineToast timer.+ */+ &.is-just-removed {+ background: var(--td-success-color-light);+ border-color: var(--td-success-color-focus);+ animation: credential-toast-flash 0.25s ease both;+ cursor: default;++ &:hover {+ background: var(--td-success-color-light);+ border-color: var(--td-success-color-focus);+ }+ }++ /*+ Confirm-remove state: warning-tinted background + danger-color border,+ making it obvious that the row is in a destructive-action standoff. The+ button group changes to [Cancel | Confirm-danger]; user has to make a+ deliberate second click to actually delete.+ */+ &.is-confirm-remove {+ background: var(--td-error-color-light);+ border-color: var(--td-error-color-focus);+ animation: credential-confirm-flash 0.2s ease both;++ &:hover {+ border-color: var(--td-error-color-focus);+ }+ }}-.credential-label {- font-size: 14px;- font-weight: 500;- color: var(--td-text-color-primary);- margin-bottom: 2px;+@keyframes credential-toast-flash {+ from {+ background: var(--td-bg-color-container);+ border-color: var(--td-component-border);+ }+ to {+ background: var(--td-success-color-light);+ border-color: var(--td-success-color-focus);+ }}-.credential-sub {- font-size: 12px;- color: var(--td-text-color-secondary);+@keyframes credential-confirm-flash {+ from {+ background: var(--td-bg-color-container);+ border-color: var(--td-component-border);+ }+ to {+ background: var(--td-error-color-light);+ border-color: var(--td-error-color-focus);+ }}-.credential-actions {- display: flex;- gap: 8px;- flex-shrink: 0;+.credential-faux-text {+ flex: 1;+ min-width: 0;+ color: var(--td-text-color-primary);+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;++ &.muted {+ color: var(--td-text-color-placeholder);+ }++ &.danger {+ color: var(--td-error-color);+ font-weight: 500;+ }}.status-icon {- font-size: 18px;flex-shrink: 0;+ font-size: 16px;&.success {color: var(--td-success-color);@@ -277,17 +467,59 @@ async function onRemove(field: CredentialFieldDef) {&.muted {color: var(--td-text-color-placeholder);}++ &.warn {+ color: var(--td-error-color);+ }}+/*+ Inline action buttons inside the faux input. We use `variant="text"` so+ they read as inline text affordances — same visual weight as the eye+ toggle on the create-mode API key input. A 1px divider between Update+ and Remove gives them just enough separation without adding boxes.+*/+.credential-actions {+ display: flex;+ align-items: center;+ gap: 2px;+ flex-shrink: 0;++ :deep(.t-button--variant-text) {+ height: 24px;+ padding: 0 8px;+ font-size: 12px;+ border-radius: 4px;+ }+}++.action-divider {+ width: 1px;+ height: 14px;+ background: var(--td-component-stroke);+ margin: 0 2px;+}++/*+ Editing state — let t-input own its frame; we just stack a tiny+ end-aligned action row underneath. No border on this wrapper.+*/.credential-edit {display: flex;flex-direction: column;- gap: 8px;+ gap: 6px;}.credential-edit-actions {display: flex;justify-content: flex-end;- gap: 8px;+ align-items: center;+ gap: 4px;++ :deep(.t-button) {+ height: 28px;+ padding: 0 12px;+ font-size: 12px;+ }}</style>diff --git a/frontend/src/components/settings/SettingDrawer.vue b/frontend/src/components/settings/SettingDrawer.vueindex c9f0d9e9e..0d169faac 100644--- a/frontend/src/components/settings/SettingDrawer.vue+++ b/frontend/src/components/settings/SettingDrawer.vue@@ -1,13 +1,37 @@<template><t-drawerv-model:visible="drawerVisible"- :header="title"- :size="width"+ :size="effectiveWidth"+ :size-draggable="resizable ? sizeDragLimit : false"placement="right"destroy-on-close+ class="setting-drawer"+ @size-drag-end="onSizeDragEnd">+ <!--+ Custom header. We replace TDesign's default header so we can put a leading+ icon badge and an optional subtitle (description) right next to the title,+ keeping the body uncluttered. The close affordance is the slide-out drawer+ itself + the underlying overlay click — TDesign already wires those up,+ so we don't need a redundant X button.+ -->+ <template #header>+ <div class="setting-drawer__header">+ <div v-if="$slots.headerIcon || icon" class="setting-drawer__header-icon">+ <slot name="headerIcon">+ <t-icon v-if="icon" :name="icon" />+ </slot>+ </div>+ <div class="setting-drawer__header-text">+ <div class="setting-drawer__title">{{ title }}</div>+ <div v-if="description || $slots.subtitle" class="setting-drawer__subtitle">+ <slot name="subtitle">{{ description }}</slot>+ </div>+ </div>+ </div>+ </template>+<div class="setting-drawer__body">- <p v-if="description" class="setting-drawer__desc">{{ description }}</p><slot /></div><template v-if="!hideFooter" #footer>@@ -34,14 +58,37 @@</template><script setup lang="ts">-import { computed } from 'vue'+import { computed, ref } from 'vue'import { useI18n } from 'vue-i18n'interface Props {visible: booleantitle: stringdescription?: string+ /** Optional TDesign icon name shown as a leading badge in the header. */+ icon?: string+ /**+ * Initial width when the user has no persisted preference. Accepts any+ * CSS length string (e.g. "560px", "40%").+ */width?: string+ /**+ * Whether the drawer can be horizontally resized by dragging its left+ * edge. We delegate to TDesign's built-in `sizeDraggable` — it already+ * renders the resize cursor on the panel edge and takes care of the+ * mousemove handlers, so all we do here is bound it and persist the+ * final size on drag-end.+ */+ resizable?: boolean+ /** Min/max bounds for the drag-resize, in px. */+ minWidth?: number+ maxWidth?: number+ /**+ * localStorage key used to remember the user's chosen width. Set to '' to+ * disable persistence. Default key is namespaced per-consumer using the+ * drawer title.+ */+ storageKey?: stringconfirmLoading?: booleanconfirmDisabled?: booleanconfirmText?: string@@ -51,7 +98,12 @@ interface Props {const props = withDefaults(defineProps<Props>(), {description: '',- width: '500px',+ icon: '',+ width: '560px',+ resizable: true,+ minWidth: 480,+ maxWidth: 1200,+ storageKey: '',confirmLoading: false,confirmDisabled: false,confirmText: '',@@ -67,11 +119,66 @@ const emit = defineEmits<{const { t } = useI18n()+// ---------- visibility ----------const drawerVisible = computed({get: () => props.visible,set: (val) => emit('update:visible', val)})+// ---------- width state ----------+// Storage key derives from the drawer title so different drawers (model+// editor vs MCP service vs web search provider) get independent widths.+// Callers can override via the `storageKey` prop when titles collide.+const resolvedStorageKey = computed(+ () => props.storageKey || `setting-drawer:width:${props.title || 'default'}`+)++const clampWidth = (n: number) =>+ Math.max(props.minWidth, Math.min(props.maxWidth, Math.round(n)))++const loadStoredWidth = (): number | null => {+ if (typeof window === 'undefined') return null+ try {+ const raw = window.localStorage.getItem(resolvedStorageKey.value)+ if (!raw) return null+ const n = Number(raw)+ if (!Number.isFinite(n)) return null+ return clampWidth(n)+ } catch {+ return null+ }+}++// User's persisted width (px) wins over the prop default.+const userWidthPx = ref<number | null>(loadStoredWidth())++const effectiveWidth = computed(() =>+ userWidthPx.value != null ? `${userWidthPx.value}px` : props.width+)++// ---------- TDesign-native drag-resize ----------+// `sizeDraggable` accepts true (no clamp) or { min, max }. We always pass+// the bounds so the user can't accidentally collapse the drawer to nothing+// or push it past the viewport.+const sizeDragLimit = computed(() => ({+ min: props.minWidth,+ max: props.maxWidth,+}))++const onSizeDragEnd = (ctx: { e: MouseEvent; size: number }) => {+ const next = clampWidth(ctx.size)+ userWidthPx.value = next+ if (typeof window !== 'undefined' && props.storageKey !== '') {+ try {+ window.localStorage.setItem(resolvedStorageKey.value, String(next))+ } catch {+ // localStorage can throw in private mode / quota errors. The width+ // still applies for this session; we just lose the persistence on+ // next open.+ }+ }+}+const handleConfirm = () => emit('confirm')const handleCancel = () => {emit('cancel')@@ -80,19 +187,136 @@ const handleCancel = () => {</script><style lang="less" scoped>+/* ---------- Header ---------- */+.setting-drawer__header {+ display: flex;+ align-items: center;+ gap: 10px;+ flex: 1;+ min-width: 0;+ padding: 2px 0;+}++.setting-drawer__header-icon {+ flex-shrink: 0;+ width: 32px;+ height: 32px;+ border-radius: 9px;+ display: flex;+ align-items: center;+ justify-content: center;+ background: rgba(7, 192, 95, 0.1);+ color: var(--td-brand-color);+ font-size: 16px;+ transition: background 0.2s ease;+}++.setting-drawer__header-text {+ display: flex;+ flex-direction: column;+ gap: 1px;+ min-width: 0;+}++.setting-drawer__title {+ font-size: 15px;+ font-weight: 600;+ line-height: 1.4;+ color: var(--td-text-color-primary);+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.setting-drawer__subtitle {+ font-size: 12px;+ line-height: 1.45;+ color: var(--td-text-color-secondary);+}++/* ---------- Body ---------- */.setting-drawer__body {display: flex;flex-direction: column;- gap: 20px;+ gap: 4px;+ /* The Body is the entry-animation host. Children (.form-item) get+ a subtle staggered slide-in to echo the model-card hover transform. */+ animation: setting-drawer-body-in 0.28s ease both;+}++@keyframes setting-drawer-body-in {+ from {+ opacity: 0;+ transform: translateY(4px);+ }+ to {+ opacity: 1;+ transform: translateY(0);+ }+}++/* ---------- Sections (consumed by ModelEditorDialog & friends) ---------- */+.setting-drawer__body :deep(.setting-drawer__section) {+ padding: 12px 0 16px;+ border-bottom: 1px solid var(--td-component-stroke);+ display: flex;+ flex-direction: column;+ gap: 14px;+ animation: setting-drawer-section-in 0.32s ease both;++ &:first-child {+ padding-top: 0;+ animation-delay: 0.04s;+ }++ &:nth-child(2) {+ animation-delay: 0.08s;+ }++ &:nth-child(3) {+ animation-delay: 0.12s;+ }++ &:last-child {+ border-bottom: none;+ padding-bottom: 0;+ }}-.setting-drawer__desc {- margin: 0;+@keyframes setting-drawer-section-in {+ from {+ opacity: 0;+ transform: translateY(6px);+ }+ to {+ opacity: 1;+ transform: translateY(0);+ }+}++.setting-drawer__body :deep(.setting-drawer__section-title) {font-size: 13px;- color: var(--td-text-color-secondary);- line-height: 1.6;+ font-weight: 600;+ color: var(--td-text-color-primary);+ margin: 0 0 4px;+ user-select: none;+ display: flex;+ align-items: center;+ gap: 8px;++ /* A subtle leading bar — replaces the previous all-caps + letter-spacing+ trick (which mangles Chinese). Gives the section title a consistent+ visual anchor without yelling at the user. */+ &::before {+ content: '';+ width: 3px;+ height: 14px;+ background: var(--td-brand-color);+ border-radius: 2px;+ }}+/* ---------- Footer ---------- */.setting-drawer__footer {display: flex;align-items: center;@@ -116,3 +340,55 @@ const handleCancel = () => {flex-shrink: 0;}</style>++<!--+ Non-scoped block: t-drawer renders header/footer wrappers outside the+ scoped style boundary in some TDesign builds, so we tweak chrome (border,+ padding) at the global level — namespaced under `.setting-drawer` to avoid+ bleeding into other drawers in the app.+-->+<style lang="less">+.setting-drawer {+ .t-drawer__header {+ padding: 14px 18px;+ border-bottom: 1px solid var(--td-component-stroke);+ }++ .t-drawer__body {+ padding: 16px 18px;+ }++ .t-drawer__footer {+ padding: 10px 18px;+ border-top: 1px solid var(--td-component-stroke);+ box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.04);+ }++ /*+ TDesign renders the drag handle as a class-less <div> on the panel edge+ when sizeDraggable is on, with inline style `cursor: col-resize` and a+ 16px-wide TRANSPARENT background — so users can drag, but they have no+ visual cue that they can. We use an attribute selector on the inline+ cursor style to give it a visible 3px line that lights up on hover/drag,+ matching the brand color so it reads as a deliberate affordance.+ */+ .t-drawer__content-wrapper > div[style*="col-resize"] {+ /* Override TDesign's hardcoded inline width so the visible line is a+ reasonable thickness; the handle still extends past it because the+ hit area is generous on hover. */+ background: var(--td-component-stroke) !important;+ width: 3px !important;+ transition: background 0.15s ease, width 0.15s ease;++ &:hover {+ background: var(--td-brand-color) !important;+ width: 4px !important;+ }++ &:active {+ background: var(--td-brand-color-active, var(--td-brand-color)) !important;+ width: 4px !important;+ }+ }+}+</style>diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex 1fab158d7..b0aaa877e 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -2972,9 +2972,12 @@ export default {editor: {addTitle: 'Add Model',editTitle: 'Edit Model',+ sectionSource: 'Source',+ sectionProvider: 'Provider Settings',+ sectionAdvanced: 'Advanced Options',sourceLabel: 'Model Source',- sourceLocal: 'Ollama (Local)',- sourceRemote: 'Remote API',+ sourceLocal: 'Ollama',+ sourceRemote: 'API',description: {chat: 'Configure large language models for conversations',embedding: 'Configure embedding models for text vectorization',@@ -4803,6 +4806,8 @@ export default {saveFailed: 'Failed to save credential',removedToast: 'Credential removed',removeFailed: 'Failed to remove credential',+ confirmRemovePrompt: 'Remove this credential? This cannot be undone.',+ confirmRemove: 'Confirm remove',confirmRemoveTitle: 'Remove {field}?',confirmRemoveBody:'This permanently deletes the stored credential. Integrations using it will stop working until you configure a new value.',diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.tsindex 2474aca0a..353d6628f 100755--- a/frontend/src/i18n/locales/ko-KR.ts+++ b/frontend/src/i18n/locales/ko-KR.ts@@ -2210,9 +2210,12 @@ export default {editor: {addTitle: "모델 추가",editTitle: "모델 편집",+ sectionSource: "모델 소스",+ sectionProvider: "연결 설정",+ sectionAdvanced: "고급 옵션",sourceLabel: "모델 소스",- sourceLocal: "Ollama (로컬)",- sourceRemote: "Remote API (원격)",+ sourceLocal: "Ollama",+ sourceRemote: "API",description: {chat: "대화용 대규모 언어 모델 설정",embedding: "텍스트 벡터화용 임베딩 모델 설정",@@ -4862,6 +4865,8 @@ export default {saveFailed: "credential 저장 실패",removedToast: "credential이 제거되었습니다",removeFailed: "credential 제거 실패",+ confirmRemovePrompt: "이 credential을 제거하시겠습니까? 이 작업은 되돌릴 수 없습니다.",+ confirmRemove: "제거 확인",confirmRemoveTitle: "{field} 제거하시겠습니까?",confirmRemoveBody:"저장된 credential이 영구적으로 삭제되며, 이를 사용하는 통합은 새 값을 구성할 때까지 동작하지 않습니다.",diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.tsindex 638c294f7..14e4bc3f5 100755--- a/frontend/src/i18n/locales/ru-RU.ts+++ b/frontend/src/i18n/locales/ru-RU.ts@@ -1929,9 +1929,12 @@ export default {editor: {addTitle: 'Добавить модель',editTitle: 'Редактировать модель',+ sectionSource: 'Источник',+ sectionProvider: 'Настройки провайдера',+ sectionAdvanced: 'Дополнительные параметры',sourceLabel: 'Источник модели',- sourceLocal: 'Ollama (локальный)',- sourceRemote: 'Remote API (удалённый)',+ sourceLocal: 'Ollama',+ sourceRemote: 'API',description: {chat: 'Настройте языковую модель для диалогов',embedding: 'Настройте модель встраивания для текстовой векторизации',@@ -4684,6 +4687,8 @@ export default {saveFailed: 'Не удалось сохранить учётные данные',removedToast: 'Учётные данные удалены',removeFailed: 'Не удалось удалить учётные данные',+ confirmRemovePrompt: 'Удалить учётные данные? Действие необратимо.',+ confirmRemove: 'Подтвердить удаление',confirmRemoveTitle: 'Удалить {field}?',confirmRemoveBody:'Сохранённые учётные данные будут безвозвратно удалены. Интеграции, использующие их, перестанут работать до настройки нового значения.',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex e32f0720d..5b2784e29 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -2189,9 +2189,12 @@ export default {editor: {addTitle: "添加模型",editTitle: "编辑模型",+ sectionSource: "模型来源",+ sectionProvider: "接入配置",+ sectionAdvanced: "高级选项",sourceLabel: "模型来源",- sourceLocal: "Ollama(本地)",- sourceRemote: "Remote API(远程)",+ sourceLocal: "Ollama",+ sourceRemote: "API",description: {chat: "配置用于对话的大语言模型",embedding: "配置用于文本向量化的嵌入模型",@@ -4794,6 +4797,8 @@ export default {saveFailed: "保存凭据失败",removedToast: "凭据已移除",removeFailed: "移除凭据失败",+ confirmRemovePrompt: "确认移除?此操作不可撤销",+ confirmRemove: "确认移除",confirmRemoveTitle: "移除 {field}?",confirmRemoveBody:"此操作将永久删除已保存的凭据,依赖它的集成将停止工作,直到您重新配置。",