2025-11-05 15:18:44 +00:00
|
|
|
|
<template>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<Teleport to="body">
|
|
|
|
|
|
<Transition name="modal">
|
2026-03-02 07:19:47 +00:00
|
|
|
|
<div v-if="dialogVisible" class="model-editor-overlay" @mousedown.self="handleOverlayMouseDown" @mouseup.self="handleOverlayMouseUp">
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<div class="model-editor-modal">
|
|
|
|
|
|
<!-- 关闭按钮 -->
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<button class="close-btn" @click="handleCancel" :aria-label="$t('common.close')">
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
|
|
|
|
|
|
<path d="M15 5L5 15M5 5L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 标题区域 -->
|
|
|
|
|
|
<div class="modal-header">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<h2 class="modal-title">{{ isEdit ? $t('model.editor.editTitle') : $t('model.editor.addTitle') }}</h2>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<p class="modal-desc">{{ getModalDescription() }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 表单内容区域 -->
|
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
|
<t-form ref="formRef" :data="formData" :rules="rules" layout="vertical">
|
2025-11-05 15:18:44 +00:00
|
|
|
|
<!-- 模型来源 -->
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<div class="form-item">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<label class="form-label required">{{ $t('model.editor.sourceLabel') }}</label>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
<t-radio-group v-model="formData.source">
|
2025-11-20 17:07:28 +00:00
|
|
|
|
<t-radio
|
|
|
|
|
|
value="local"
|
2025-12-18 02:49:45 +00:00
|
|
|
|
:disabled="ollamaServiceStatus === false || modelType === 'rerank'"
|
2025-11-20 17:07:28 +00:00
|
|
|
|
>
|
|
|
|
|
|
{{ $t('model.editor.sourceLocal') }}
|
|
|
|
|
|
</t-radio>
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<t-radio value="remote">{{ $t('model.editor.sourceRemote') }}</t-radio>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
</t-radio-group>
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-12-18 02:49:45 +00:00
|
|
|
|
<!-- 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>
|
|
|
|
|
|
|
2025-11-20 17:07:28 +00:00
|
|
|
|
<!-- Ollama不可用时的提示信息 -->
|
2025-12-18 02:49:45 +00:00
|
|
|
|
<div v-else-if="ollamaServiceStatus === false" class="ollama-unavailable-tip">
|
2025-11-20 17:07:28 +00:00
|
|
|
|
<t-icon name="error-circle-filled" class="tip-icon" />
|
|
|
|
|
|
<span class="tip-text">{{ $t('model.editor.ollamaUnavailable') }}</span>
|
|
|
|
|
|
<t-button
|
|
|
|
|
|
variant="text"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
theme="primary"
|
|
|
|
|
|
@click="goToOllamaSettings"
|
|
|
|
|
|
class="tip-link"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ $t('model.editor.goToOllamaSettings') }}
|
|
|
|
|
|
</t-button>
|
|
|
|
|
|
</div>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</div>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
<!-- Ollama 本地模型选择器 -->
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<div v-if="formData.source === 'local'" class="form-item">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<label class="form-label required">{{ $t('model.modelName') }}</label>
|
2025-11-07 07:52:52 +00:00
|
|
|
|
<div class="model-select-row">
|
|
|
|
|
|
<t-select
|
|
|
|
|
|
v-model="formData.modelName"
|
|
|
|
|
|
:loading="loadingOllamaModels"
|
|
|
|
|
|
:class="{ 'downloading': downloading }"
|
|
|
|
|
|
:style="downloading ? `--progress: ${downloadProgress}%` : ''"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
:filter="handleModelFilter"
|
2025-11-13 11:34:33 +00:00
|
|
|
|
:placeholder="$t('model.searchPlaceholder')"
|
2025-11-07 07:52:52 +00:00
|
|
|
|
@focus="loadOllamaModels"
|
|
|
|
|
|
@visible-change="handleDropdownVisibleChange"
|
2025-11-05 15:18:44 +00:00
|
|
|
|
>
|
2025-11-07 07:52:52 +00:00
|
|
|
|
<!-- 已下载的模型 -->
|
|
|
|
|
|
<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}`"
|
2025-11-13 11:34:33 +00:00
|
|
|
|
:label="$t('model.editor.downloadLabel', { keyword: searchKeyword })"
|
2025-11-07 07:52:52 +00:00
|
|
|
|
class="download-option"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="model-option download">
|
|
|
|
|
|
<t-icon name="download" class="download-icon" />
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<span class="model-name">{{ $t('model.editor.downloadLabel', { keyword: searchKeyword }) }}</span>
|
2025-11-07 07:52:52 +00:00
|
|
|
|
</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>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-07 07:52:52 +00:00
|
|
|
|
<!-- 刷新按钮 -->
|
|
|
|
|
|
<t-button
|
|
|
|
|
|
variant="text"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
:loading="loadingOllamaModels"
|
|
|
|
|
|
@click="refreshOllamaModels"
|
|
|
|
|
|
class="refresh-btn"
|
2025-11-05 15:18:44 +00:00
|
|
|
|
>
|
2025-11-07 07:52:52 +00:00
|
|
|
|
<t-icon name="refresh" />
|
2025-11-13 11:34:33 +00:00
|
|
|
|
{{ $t('model.editor.refreshList') }}
|
2025-11-07 07:52:52 +00:00
|
|
|
|
</t-button>
|
|
|
|
|
|
</div>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</div>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<!-- Remote API 配置 -->
|
|
|
|
|
|
<template v-if="formData.source === 'remote'">
|
2025-12-28 17:31:27 +00:00
|
|
|
|
<!-- 厂商选择器 -->
|
|
|
|
|
|
<div class="form-item">
|
|
|
|
|
|
<label class="form-label">{{ $t('model.editor.providerLabel') }}</label>
|
2026-04-02 12:53:44 +00:00
|
|
|
|
<t-select
|
|
|
|
|
|
v-model="formData.provider"
|
2025-12-28 17:31:27 +00:00
|
|
|
|
:placeholder="$t('model.editor.providerPlaceholder')"
|
|
|
|
|
|
@change="handleProviderChange"
|
2026-04-02 12:53:44 +00:00
|
|
|
|
:popup-props="{ overlayClassName: 'provider-select-popup' }"
|
2025-12-28 17:31:27 +00:00
|
|
|
|
>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 模型名称 -->
|
|
|
|
|
|
<div class="form-item">
|
|
|
|
|
|
<label class="form-label required">{{ $t('model.modelName') }}</label>
|
|
|
|
|
|
<t-input
|
|
|
|
|
|
v-model="formData.modelName"
|
|
|
|
|
|
:placeholder="getModelNamePlaceholder()"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<div class="form-item">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<label class="form-label required">{{ $t('model.editor.baseUrlLabel') }}</label>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
<t-input
|
|
|
|
|
|
v-model="formData.baseUrl"
|
2025-11-13 11:34:33 +00:00
|
|
|
|
:placeholder="getBaseUrlPlaceholder()"
|
2025-11-05 15:18:44 +00:00
|
|
|
|
/>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</div>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<div class="form-item">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<label class="form-label">{{ $t('model.editor.apiKeyOptional') }}</label>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
<t-input
|
|
|
|
|
|
v-model="formData.apiKey"
|
|
|
|
|
|
type="password"
|
2025-11-13 11:34:33 +00:00
|
|
|
|
:placeholder="$t('model.editor.apiKeyPlaceholder')"
|
2025-11-05 15:18:44 +00:00
|
|
|
|
/>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</div>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
<!-- Remote API 校验 -->
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<div class="form-item">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<label class="form-label">{{ $t('model.editor.connectionTest') }}</label>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
<div class="api-test-section">
|
|
|
|
|
|
<t-button
|
|
|
|
|
|
variant="outline"
|
|
|
|
|
|
@click="checkRemoteAPI"
|
|
|
|
|
|
:loading="checking"
|
|
|
|
|
|
:disabled="!formData.modelName || !formData.baseUrl"
|
|
|
|
|
|
>
|
|
|
|
|
|
<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>
|
2025-11-13 11:34:33 +00:00
|
|
|
|
{{ checking ? $t('model.editor.testing') : $t('model.editor.testConnection') }}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
</t-button>
|
|
|
|
|
|
<span v-if="remoteChecked" :class="['test-message', remoteAvailable ? 'success' : 'error']">
|
|
|
|
|
|
{{ remoteMessage }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</div>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Embedding 专用:维度 -->
|
2025-11-06 16:30:15 +00:00
|
|
|
|
<div v-if="modelType === 'embedding'" class="form-item">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<label class="form-label">{{ $t('model.editor.dimensionLabel') }}</label>
|
2025-11-07 07:52:52 +00:00
|
|
|
|
<div class="dimension-control">
|
|
|
|
|
|
<t-input
|
|
|
|
|
|
v-model.number="formData.dimension"
|
|
|
|
|
|
type="number"
|
2025-11-07 08:40:53 +00:00
|
|
|
|
:min="128"
|
|
|
|
|
|
:max="4096"
|
2025-11-13 11:34:33 +00:00
|
|
|
|
:placeholder="$t('model.editor.dimensionPlaceholder')"
|
2025-11-07 07:52:52 +00:00
|
|
|
|
:disabled="formData.source === 'local' && checking"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<!-- Ollama 本地模型:自动检测维度按钮 -->
|
|
|
|
|
|
<t-button
|
|
|
|
|
|
v-if="formData.source === 'local' && formData.modelName"
|
|
|
|
|
|
variant="outline"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
:loading="checking"
|
|
|
|
|
|
@click="checkOllamaDimension"
|
|
|
|
|
|
class="dimension-check-btn"
|
|
|
|
|
|
>
|
|
|
|
|
|
<t-icon name="refresh" />
|
2025-11-13 11:34:33 +00:00
|
|
|
|
{{ $t('model.editor.checkDimension') }}
|
2025-11-07 07:52:52 +00:00
|
|
|
|
</t-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<p v-if="dimensionChecked && dimensionMessage" class="dimension-hint" :class="{ success: dimensionSuccess }">
|
|
|
|
|
|
{{ dimensionMessage }}
|
|
|
|
|
|
</p>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</div>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2026-03-23 12:09:48 +00:00
|
|
|
|
<!-- Chat: supports vision toggle (VLLM models are inherently multimodal) -->
|
|
|
|
|
|
<div v-if="modelType === 'chat'" class="form-item">
|
2026-03-11 09:17:32 +00:00
|
|
|
|
<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>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
</t-form>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 底部按钮区域 -->
|
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
|
<t-button theme="default" variant="outline" @click="handleCancel">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
{{ $t('common.cancel') }}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</t-button>
|
|
|
|
|
|
<t-button theme="primary" @click="handleConfirm" :loading="saving">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
{{ $t('common.save') }}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
</t-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Transition>
|
|
|
|
|
|
</Teleport>
|
2025-11-05 15:18:44 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2025-11-20 17:07:28 +00:00
|
|
|
|
import { ref, watch, computed, onUnmounted, nextTick } from 'vue'
|
2025-11-05 15:18:44 +00:00
|
|
|
|
import { MessagePlugin } from 'tdesign-vue-next'
|
2026-04-02 12:53:44 +00:00
|
|
|
|
import { checkOllamaModels, checkRemoteModel, testEmbeddingModel, checkRerankModel, checkASRModel, listOllamaModels, downloadOllamaModel, getDownloadProgress, checkOllamaStatus, listModelProviders, type OllamaModelInfo, type ModelProviderOption } from '@/api/initialization'
|
2025-11-13 11:34:33 +00:00
|
|
|
|
import { useI18n } from 'vue-i18n'
|
2025-11-20 17:07:28 +00:00
|
|
|
|
import { useUIStore } from '@/stores/ui'
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
interface ModelFormData {
|
|
|
|
|
|
id: string
|
|
|
|
|
|
name: string
|
|
|
|
|
|
source: 'local' | 'remote'
|
2025-12-28 17:31:27 +00:00
|
|
|
|
provider?: string // Provider identifier: openai, aliyun, zhipu, generic, etc.
|
2025-11-05 15:18:44 +00:00
|
|
|
|
modelName: string
|
|
|
|
|
|
baseUrl?: string
|
|
|
|
|
|
apiKey?: string
|
|
|
|
|
|
dimension?: number
|
|
|
|
|
|
interfaceType?: 'ollama' | 'openai'
|
|
|
|
|
|
isDefault: boolean
|
2026-03-11 09:17:32 +00:00
|
|
|
|
supportsVision?: boolean
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
|
visible: boolean
|
2026-04-02 08:43:37 +00:00
|
|
|
|
modelType: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'
|
2025-11-05 15:18:44 +00:00
|
|
|
|
modelData?: ModelFormData | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-06 13:27:50 +00:00
|
|
|
|
const { t, te } = useI18n()
|
2025-11-20 17:07:28 +00:00
|
|
|
|
const uiStore = useUIStore()
|
2025-11-13 11:34:33 +00:00
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
|
|
|
visible: false,
|
|
|
|
|
|
modelData: null
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
|
'update:visible': [value: boolean]
|
|
|
|
|
|
'confirm': [data: ModelFormData]
|
|
|
|
|
|
}>()
|
|
|
|
|
|
|
2025-12-28 17:31:27 +00:00
|
|
|
|
// API 返回的 Provider 列表
|
|
|
|
|
|
const apiProviderOptions = ref<ModelProviderOption[]>([])
|
|
|
|
|
|
const loadingProviders = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
// 硬编码的后备 Provider 配置 (当 API 不可用时使用)
|
|
|
|
|
|
const fallbackProviderOptions = computed(() => [
|
2026-04-02 08:43:37 +00:00
|
|
|
|
{
|
|
|
|
|
|
value: 'openai',
|
|
|
|
|
|
label: t('model.editor.providers.openai.label'),
|
2025-12-28 17:31:27 +00:00
|
|
|
|
defaultUrls: {
|
|
|
|
|
|
chat: 'https://api.openai.com/v1',
|
|
|
|
|
|
embedding: 'https://api.openai.com/v1',
|
|
|
|
|
|
rerank: 'https://api.openai.com/v1',
|
2026-04-02 08:43:37 +00:00
|
|
|
|
vllm: 'https://api.openai.com/v1',
|
|
|
|
|
|
asr: 'https://api.openai.com/v1'
|
2025-12-28 17:31:27 +00:00
|
|
|
|
},
|
|
|
|
|
|
description: t('model.editor.providers.openai.description'),
|
2026-04-02 08:43:37 +00:00
|
|
|
|
modelTypes: ['chat', 'embedding', 'vllm', 'asr']
|
2025-12-28 17:31:27 +00:00
|
|
|
|
},
|
2026-04-07 11:19:15 +00:00
|
|
|
|
{
|
|
|
|
|
|
value: 'azure_openai',
|
|
|
|
|
|
label: t('model.editor.providers.azure_openai.label'),
|
|
|
|
|
|
defaultUrls: {
|
|
|
|
|
|
chat: 'https://{resource}.openai.azure.com',
|
|
|
|
|
|
embedding: 'https://{resource}.openai.azure.com',
|
|
|
|
|
|
vllm: 'https://{resource}.openai.azure.com',
|
|
|
|
|
|
asr: 'https://{resource}.openai.azure.com'
|
|
|
|
|
|
},
|
|
|
|
|
|
description: t('model.editor.providers.azure_openai.description'),
|
|
|
|
|
|
modelTypes: ['chat', 'embedding', 'vllm', 'asr']
|
|
|
|
|
|
},
|
2026-04-02 08:43:37 +00:00
|
|
|
|
{
|
|
|
|
|
|
value: 'aliyun',
|
|
|
|
|
|
label: t('model.editor.providers.aliyun.label'),
|
2025-12-28 17:31:27 +00:00
|
|
|
|
defaultUrls: {
|
|
|
|
|
|
chat: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
|
|
|
|
embedding: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
|
|
|
|
rerank: 'https://dashscope.aliyuncs.com/api/v1/services/rerank/text-rerank/text-rerank',
|
2026-04-02 12:53:44 +00:00
|
|
|
|
vllm: 'https://dashscope.aliyuncs.com/compatible-mode/v1'
|
2025-12-28 17:31:27 +00:00
|
|
|
|
},
|
|
|
|
|
|
description: t('model.editor.providers.aliyun.description'),
|
2026-04-02 12:53:44 +00:00
|
|
|
|
modelTypes: ['chat', 'embedding', 'rerank', 'vllm']
|
2025-12-28 17:31:27 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'zhipu',
|
|
|
|
|
|
label: t('model.editor.providers.zhipu.label'),
|
|
|
|
|
|
defaultUrls: {
|
|
|
|
|
|
chat: 'https://open.bigmodel.cn/api/paas/v4',
|
|
|
|
|
|
embedding: 'https://open.bigmodel.cn/api/paas/v4/embeddings',
|
|
|
|
|
|
vllm: 'https://open.bigmodel.cn/api/paas/v4'
|
|
|
|
|
|
},
|
|
|
|
|
|
description: t('model.editor.providers.zhipu.description'),
|
|
|
|
|
|
modelTypes: ['chat', 'embedding', 'vllm']
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'openrouter',
|
|
|
|
|
|
label: t('model.editor.providers.openrouter.label'),
|
2026-03-19 15:03:34 +00:00
|
|
|
|
defaultUrls: {
|
|
|
|
|
|
chat: 'https://openrouter.ai/api/v1',
|
|
|
|
|
|
embedding: 'https://openrouter.ai/api/v1'
|
|
|
|
|
|
},
|
2025-12-28 17:31:27 +00:00
|
|
|
|
description: t('model.editor.providers.openrouter.description'),
|
2026-03-19 15:03:34 +00:00
|
|
|
|
modelTypes: ['chat', 'embedding']
|
2025-12-28 17:31:27 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'siliconflow',
|
|
|
|
|
|
label: t('model.editor.providers.siliconflow.label'),
|
|
|
|
|
|
defaultUrls: {
|
|
|
|
|
|
chat: 'https://api.siliconflow.cn/v1',
|
|
|
|
|
|
embedding: 'https://api.siliconflow.cn/v1',
|
|
|
|
|
|
rerank: 'https://api.siliconflow.cn/v1'
|
|
|
|
|
|
},
|
|
|
|
|
|
description: t('model.editor.providers.siliconflow.description'),
|
|
|
|
|
|
modelTypes: ['chat', 'embedding', 'rerank']
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'jina',
|
|
|
|
|
|
label: t('model.editor.providers.jina.label'),
|
|
|
|
|
|
defaultUrls: {
|
|
|
|
|
|
embedding: 'https://api.jina.ai/v1',
|
|
|
|
|
|
rerank: 'https://api.jina.ai/v1'
|
|
|
|
|
|
},
|
|
|
|
|
|
description: t('model.editor.providers.jina.description'),
|
|
|
|
|
|
modelTypes: ['embedding', 'rerank']
|
|
|
|
|
|
},
|
2026-03-10 04:32:48 +00:00
|
|
|
|
{
|
|
|
|
|
|
value: 'nvidia',
|
|
|
|
|
|
label: t('model.editor.providers.nvidia.label'),
|
|
|
|
|
|
defaultUrls: {
|
2026-03-29 15:55:25 +00:00
|
|
|
|
chat: 'https://integrate.api.nvidia.com/v1',
|
2026-03-10 04:32:48 +00:00
|
|
|
|
embedding: 'https://integrate.api.nvidia.com/v1',
|
|
|
|
|
|
rerank: 'https://ai.api.nvidia.com/v1/retrieval/nvidia/reranking',
|
|
|
|
|
|
vllm: 'https://integrate.api.nvidia.com/v1',
|
|
|
|
|
|
},
|
|
|
|
|
|
description: t('model.editor.providers.nvidia.description'),
|
|
|
|
|
|
modelTypes: ['chat', 'embedding', 'rerank', 'vllm']
|
|
|
|
|
|
},
|
2026-03-24 12:19:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
value: 'novita',
|
|
|
|
|
|
label: t('model.editor.providers.novita.label'),
|
|
|
|
|
|
defaultUrls: {
|
|
|
|
|
|
chat: 'https://api.novita.ai/openai/v1',
|
|
|
|
|
|
embedding: 'https://api.novita.ai/openai/v1',
|
|
|
|
|
|
vllm: 'https://api.novita.ai/openai/v1',
|
|
|
|
|
|
},
|
|
|
|
|
|
description: t('model.editor.providers.novita.description'),
|
|
|
|
|
|
modelTypes: ['chat', 'embedding', 'vllm']
|
|
|
|
|
|
},
|
2025-12-28 17:31:27 +00:00
|
|
|
|
{
|
|
|
|
|
|
value: 'generic',
|
2026-04-02 08:43:37 +00:00
|
|
|
|
label: t('model.editor.providers.generic.label'),
|
2025-12-28 17:31:27 +00:00
|
|
|
|
defaultUrls: {},
|
|
|
|
|
|
description: t('model.editor.providers.generic.description'),
|
2026-04-02 08:43:37 +00:00
|
|
|
|
modelTypes: ['chat', 'embedding', 'rerank', 'vllm', 'asr']
|
2025-12-28 17:31:27 +00:00
|
|
|
|
},
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
// 从 API 获取 Provider 列表
|
|
|
|
|
|
const loadProviders = async () => {
|
|
|
|
|
|
loadingProviders.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
const providers = await listModelProviders(props.modelType)
|
|
|
|
|
|
if (providers.length > 0) {
|
|
|
|
|
|
apiProviderOptions.value = providers
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('Failed to load providers from API, using fallback', error)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loadingProviders.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 根据当前模型类型过滤的 Provider 列表
|
2026-03-06 13:27:50 +00:00
|
|
|
|
// API 返回的 defaultUrls/modelTypes 数据优先,但 label/description 使用 i18n
|
2025-12-28 17:31:27 +00:00
|
|
|
|
const providerOptions = computed(() => {
|
2026-03-06 13:27:50 +00:00
|
|
|
|
// API 数据可用时,用 API 的结构数据 + i18n 的显示文本
|
2025-12-28 17:31:27 +00:00
|
|
|
|
if (apiProviderOptions.value.length > 0) {
|
2026-03-06 13:27:50 +00:00
|
|
|
|
return apiProviderOptions.value.map(p => ({
|
|
|
|
|
|
...p,
|
|
|
|
|
|
label: te(`model.editor.providers.${p.value}.label`)
|
|
|
|
|
|
? t(`model.editor.providers.${p.value}.label`)
|
|
|
|
|
|
: p.label,
|
|
|
|
|
|
description: te(`model.editor.providers.${p.value}.description`)
|
|
|
|
|
|
? t(`model.editor.providers.${p.value}.description`)
|
|
|
|
|
|
: p.description,
|
|
|
|
|
|
}))
|
2025-12-28 17:31:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
// 回退到硬编码值,按 modelTypes 过滤
|
2026-03-06 13:27:50 +00:00
|
|
|
|
return fallbackProviderOptions.value.filter(p =>
|
2025-12-28 17:31:27 +00:00
|
|
|
|
p.modelTypes.includes(props.modelType)
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
const dialogVisible = computed({
|
|
|
|
|
|
get: () => props.visible,
|
|
|
|
|
|
set: (val) => emit('update:visible', val)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const isEdit = computed(() => !!props.modelData)
|
|
|
|
|
|
|
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
|
const saving = ref(false)
|
|
|
|
|
|
const modelChecked = ref(false)
|
|
|
|
|
|
const modelAvailable = ref(false)
|
|
|
|
|
|
const checking = ref(false)
|
|
|
|
|
|
const remoteChecked = ref(false)
|
|
|
|
|
|
const remoteAvailable = ref(false)
|
|
|
|
|
|
const remoteMessage = ref('')
|
2025-11-07 07:52:52 +00:00
|
|
|
|
const dimensionChecked = ref(false)
|
|
|
|
|
|
const dimensionSuccess = ref(false)
|
|
|
|
|
|
const dimensionMessage = ref('')
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
// Ollama 模型状态
|
|
|
|
|
|
const ollamaModelList = ref<OllamaModelInfo[]>([])
|
|
|
|
|
|
const loadingOllamaModels = ref(false)
|
|
|
|
|
|
const searchKeyword = ref('')
|
|
|
|
|
|
const downloading = ref(false)
|
|
|
|
|
|
const downloadProgress = ref(0)
|
|
|
|
|
|
const currentDownloadModel = ref('')
|
|
|
|
|
|
let downloadInterval: any = null
|
|
|
|
|
|
|
2025-11-20 17:07:28 +00:00
|
|
|
|
// Ollama 服务状态
|
|
|
|
|
|
const ollamaServiceStatus = ref<boolean | null>(null)
|
|
|
|
|
|
const checkingOllamaStatus = ref(false)
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
const formData = ref<ModelFormData>({
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
source: 'local',
|
2025-12-28 17:31:27 +00:00
|
|
|
|
provider: 'openai',
|
2025-11-05 15:18:44 +00:00
|
|
|
|
modelName: '',
|
|
|
|
|
|
baseUrl: '',
|
|
|
|
|
|
apiKey: '',
|
2025-11-07 07:52:52 +00:00
|
|
|
|
dimension: undefined,
|
2025-11-05 15:18:44 +00:00
|
|
|
|
interfaceType: 'ollama',
|
2026-03-11 09:17:32 +00:00
|
|
|
|
isDefault: false,
|
|
|
|
|
|
supportsVision: false
|
2025-11-05 15:18:44 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-11-13 11:34:33 +00:00
|
|
|
|
const rules = computed(() => ({
|
2025-11-06 16:30:15 +00:00
|
|
|
|
modelName: [
|
2025-11-13 11:34:33 +00:00
|
|
|
|
{ required: true, message: t('model.editor.validation.modelNameRequired') },
|
2025-11-06 16:30:15 +00:00
|
|
|
|
{
|
|
|
|
|
|
validator: (val: string) => {
|
|
|
|
|
|
if (!val || !val.trim()) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
return { result: false, message: t('model.editor.validation.modelNameEmpty') }
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (val.trim().length > 100) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
return { result: false, message: t('model.editor.validation.modelNameMax') }
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
return { result: true }
|
|
|
|
|
|
},
|
|
|
|
|
|
trigger: 'blur'
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
2025-11-05 15:18:44 +00:00
|
|
|
|
baseUrl: [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
2025-11-13 11:34:33 +00:00
|
|
|
|
message: t('model.editor.validation.baseUrlRequired'),
|
2025-11-05 15:18:44 +00:00
|
|
|
|
trigger: 'blur'
|
2025-11-06 16:30:15 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
validator: (val: string) => {
|
|
|
|
|
|
if (!val || !val.trim()) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
return { result: false, message: t('model.editor.validation.baseUrlEmpty') }
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
// 简单的 URL 格式校验
|
|
|
|
|
|
try {
|
|
|
|
|
|
new URL(val.trim())
|
|
|
|
|
|
return { result: true }
|
|
|
|
|
|
} catch {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
return { result: false, message: t('model.editor.validation.baseUrlInvalid') }
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
trigger: 'blur'
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
]
|
2025-11-13 11:34:33 +00:00
|
|
|
|
}))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 获取弹窗描述文字
|
|
|
|
|
|
const getModalDescription = () => {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
const key = `model.editor.description.${props.modelType}` as const
|
|
|
|
|
|
return t(key) || t('model.editor.description.default')
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取模型名称占位符
|
|
|
|
|
|
const getModelNamePlaceholder = () => {
|
|
|
|
|
|
if (props.modelType === 'vllm') {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
return formData.value.source === 'local'
|
|
|
|
|
|
? t('model.editor.modelNamePlaceholder.localVllm')
|
|
|
|
|
|
: t('model.editor.modelNamePlaceholder.remoteVllm')
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
2026-04-02 08:43:37 +00:00
|
|
|
|
if (props.modelType === 'asr') {
|
|
|
|
|
|
return t('model.editor.modelNamePlaceholder.remoteAsr')
|
|
|
|
|
|
}
|
2025-11-13 11:34:33 +00:00
|
|
|
|
return formData.value.source === 'local'
|
|
|
|
|
|
? t('model.editor.modelNamePlaceholder.local')
|
|
|
|
|
|
: t('model.editor.modelNamePlaceholder.remote')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getBaseUrlPlaceholder = () => {
|
2026-04-02 08:43:37 +00:00
|
|
|
|
if (props.modelType === 'vllm') {
|
|
|
|
|
|
return t('model.editor.baseUrlPlaceholderVllm')
|
|
|
|
|
|
}
|
|
|
|
|
|
if (props.modelType === 'asr') {
|
|
|
|
|
|
return t('model.editor.baseUrlPlaceholderAsr')
|
|
|
|
|
|
}
|
|
|
|
|
|
return t('model.editor.baseUrlPlaceholder')
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-20 17:07:28 +00:00
|
|
|
|
// 检查Ollama服务状态
|
|
|
|
|
|
const checkOllamaServiceStatus = async () => {
|
|
|
|
|
|
console.log('开始检查Ollama服务状态...')
|
|
|
|
|
|
checkingOllamaStatus.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
const result = await checkOllamaStatus()
|
|
|
|
|
|
ollamaServiceStatus.value = result.available
|
|
|
|
|
|
console.log('Ollama服务状态检查完成:', result.available)
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('检查Ollama服务状态失败:', error)
|
|
|
|
|
|
ollamaServiceStatus.value = false
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
checkingOllamaStatus.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 打开Ollama设置窗口
|
|
|
|
|
|
const goToOllamaSettings = async () => {
|
|
|
|
|
|
console.log('点击跳转到Ollama设置按钮')
|
|
|
|
|
|
// 关闭当前弹窗
|
|
|
|
|
|
emit('update:visible', false)
|
|
|
|
|
|
|
|
|
|
|
|
// 先关闭设置弹窗(如果已打开)
|
|
|
|
|
|
if (uiStore.showSettingsModal) {
|
|
|
|
|
|
uiStore.closeSettings()
|
|
|
|
|
|
// 等待 DOM 更新
|
|
|
|
|
|
await nextTick()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 打开设置窗口并直接跳转到Ollama设置
|
|
|
|
|
|
console.log('调用uiStore.openSettings')
|
|
|
|
|
|
uiStore.openSettings('ollama')
|
|
|
|
|
|
console.log('uiStore.openSettings调用完成')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
// 监听 visible 变化,初始化表单
|
|
|
|
|
|
watch(() => props.visible, (val) => {
|
|
|
|
|
|
if (val) {
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 锁定背景滚动
|
|
|
|
|
|
document.body.style.overflow = 'hidden'
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
|
|
|
|
|
// 检查Ollama服务状态
|
|
|
|
|
|
checkOllamaServiceStatus()
|
|
|
|
|
|
|
2025-12-28 17:31:27 +00:00
|
|
|
|
// 从 API 加载 Model Provider 列表
|
|
|
|
|
|
loadProviders()
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
if (props.modelData) {
|
|
|
|
|
|
formData.value = { ...props.modelData }
|
|
|
|
|
|
} else {
|
|
|
|
|
|
resetForm()
|
|
|
|
|
|
}
|
2025-12-18 02:49:45 +00:00
|
|
|
|
|
|
|
|
|
|
// ReRank 模型强制使用 remote 来源(Ollama 不支持 ReRank)
|
|
|
|
|
|
if (props.modelType === 'rerank') {
|
|
|
|
|
|
formData.value.source = 'remote'
|
|
|
|
|
|
}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
// 恢复背景滚动
|
|
|
|
|
|
document.body.style.overflow = ''
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 重置表单
|
|
|
|
|
|
const resetForm = () => {
|
|
|
|
|
|
formData.value = {
|
|
|
|
|
|
id: generateId(),
|
2025-11-06 16:30:15 +00:00
|
|
|
|
name: '', // 保留字段但不使用,保存时用 modelName
|
2025-11-05 15:18:44 +00:00
|
|
|
|
source: 'local',
|
2025-12-28 17:31:27 +00:00
|
|
|
|
provider: 'generic',
|
2025-11-05 15:18:44 +00:00
|
|
|
|
modelName: '',
|
|
|
|
|
|
baseUrl: '',
|
|
|
|
|
|
apiKey: '',
|
2025-11-07 07:52:52 +00:00
|
|
|
|
dimension: undefined, // 默认不填,让用户手动输入或通过检测按钮获取
|
2025-11-06 16:30:15 +00:00
|
|
|
|
interfaceType: undefined,
|
2026-03-11 09:17:32 +00:00
|
|
|
|
isDefault: false,
|
|
|
|
|
|
supportsVision: false
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
modelChecked.value = false
|
|
|
|
|
|
modelAvailable.value = false
|
|
|
|
|
|
remoteChecked.value = false
|
|
|
|
|
|
remoteAvailable.value = false
|
|
|
|
|
|
remoteMessage.value = ''
|
2025-11-07 07:52:52 +00:00
|
|
|
|
dimensionChecked.value = false
|
|
|
|
|
|
dimensionSuccess.value = false
|
|
|
|
|
|
dimensionMessage.value = ''
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-28 17:31:27 +00:00
|
|
|
|
// 处理厂商选择变化 (自动填充默认 URL)
|
|
|
|
|
|
const handleProviderChange = (value: string) => {
|
|
|
|
|
|
const provider = providerOptions.value.find(opt => opt.value === value)
|
|
|
|
|
|
if (provider && provider.defaultUrls) {
|
|
|
|
|
|
// 根据当前模型类型获取对应的默认 URL
|
|
|
|
|
|
const defaultUrl = provider.defaultUrls[props.modelType]
|
|
|
|
|
|
if (defaultUrl) {
|
|
|
|
|
|
formData.value.baseUrl = defaultUrl
|
|
|
|
|
|
}
|
|
|
|
|
|
// 重置校验状态
|
|
|
|
|
|
remoteChecked.value = false
|
|
|
|
|
|
remoteAvailable.value = false
|
|
|
|
|
|
remoteMessage.value = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
// 监听来源变化,重置校验状态(已合并到下面的 watch)
|
|
|
|
|
|
|
|
|
|
|
|
// 生成唯一ID
|
|
|
|
|
|
const generateId = () => {
|
|
|
|
|
|
return `model_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 过滤后的模型列表
|
|
|
|
|
|
const filteredOllamaModels = computed(() => {
|
|
|
|
|
|
if (!searchKeyword.value) return ollamaModelList.value
|
|
|
|
|
|
return ollamaModelList.value.filter(model =>
|
|
|
|
|
|
model.name.toLowerCase().includes(searchKeyword.value.toLowerCase())
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 是否显示"下载模型"选项
|
|
|
|
|
|
const showDownloadOption = computed(() => {
|
|
|
|
|
|
if (!searchKeyword.value.trim()) return false
|
|
|
|
|
|
// 检查搜索词是否已存在于模型列表中
|
|
|
|
|
|
const exists = ollamaModelList.value.some(model =>
|
|
|
|
|
|
model.name.toLowerCase() === searchKeyword.value.toLowerCase()
|
|
|
|
|
|
)
|
|
|
|
|
|
return !exists
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 自定义过滤逻辑(捕获搜索关键词)
|
|
|
|
|
|
const handleModelFilter = (filterWords: string) => {
|
|
|
|
|
|
searchKeyword.value = filterWords
|
|
|
|
|
|
return true // 让 TDesign 使用我们的 filteredOllamaModels
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 加载 Ollama 模型列表
|
|
|
|
|
|
const loadOllamaModels = async () => {
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 只在选择 local 来源时加载
|
2025-11-05 15:18:44 +00:00
|
|
|
|
if (formData.value.source !== 'local') return
|
|
|
|
|
|
|
|
|
|
|
|
loadingOllamaModels.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
const models = await listOllamaModels()
|
|
|
|
|
|
ollamaModelList.value = models
|
|
|
|
|
|
} catch (error) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
console.error(t('model.editor.loadModelListFailed'), error)
|
|
|
|
|
|
MessagePlugin.error(t('model.editor.loadModelListFailed'))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
} finally {
|
|
|
|
|
|
loadingOllamaModels.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 刷新模型列表
|
|
|
|
|
|
const refreshOllamaModels = async () => {
|
|
|
|
|
|
ollamaModelList.value = [] // 清空以强制重新加载
|
|
|
|
|
|
await loadOllamaModels()
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.success(t('model.editor.listRefreshed'))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 监听下拉框可见性变化
|
|
|
|
|
|
const handleDropdownVisibleChange = (visible: boolean) => {
|
|
|
|
|
|
if (!visible) {
|
|
|
|
|
|
searchKeyword.value = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 格式化模型大小
|
|
|
|
|
|
const formatModelSize = (bytes: number): string => {
|
|
|
|
|
|
if (!bytes || bytes === 0) return ''
|
|
|
|
|
|
const gb = bytes / (1024 * 1024 * 1024)
|
|
|
|
|
|
return gb >= 1 ? `${gb.toFixed(1)} GB` : `${(bytes / (1024 * 1024)).toFixed(0)} MB`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 检查模型状态(Ollama本地模型)
|
|
|
|
|
|
const checkModelStatus = async () => {
|
|
|
|
|
|
if (!formData.value.modelName || formData.value.source !== 'local') {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 调用真实 Ollama API 检查模型是否存在
|
|
|
|
|
|
const result = await checkOllamaModels([formData.value.modelName])
|
|
|
|
|
|
modelChecked.value = true
|
|
|
|
|
|
modelAvailable.value = result.models[formData.value.modelName] || false
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('检查模型状态失败:', error)
|
|
|
|
|
|
modelChecked.value = false
|
|
|
|
|
|
modelAvailable.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-07 07:52:52 +00:00
|
|
|
|
// 检查 Ollama 本地 Embedding 模型维度
|
|
|
|
|
|
const checkOllamaDimension = async () => {
|
|
|
|
|
|
if (!formData.value.modelName || formData.value.source !== 'local' || props.modelType !== 'embedding') {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
checking.value = true
|
|
|
|
|
|
dimensionChecked.value = false
|
|
|
|
|
|
dimensionMessage.value = ''
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const result = await testEmbeddingModel({
|
|
|
|
|
|
source: 'local',
|
|
|
|
|
|
modelName: formData.value.modelName,
|
|
|
|
|
|
dimension: formData.value.dimension
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
dimensionChecked.value = true
|
|
|
|
|
|
dimensionSuccess.value = result.available || false
|
|
|
|
|
|
|
|
|
|
|
|
if (result.available && result.dimension) {
|
|
|
|
|
|
formData.value.dimension = result.dimension
|
2025-11-13 11:34:33 +00:00
|
|
|
|
dimensionMessage.value = t('model.editor.dimensionDetected', { value: result.dimension })
|
2025-11-07 07:52:52 +00:00
|
|
|
|
MessagePlugin.success(dimensionMessage.value)
|
|
|
|
|
|
} else {
|
2026-03-06 13:27:50 +00:00
|
|
|
|
if (result.message) {
|
|
|
|
|
|
console.debug('Backend dimension message:', result.message)
|
|
|
|
|
|
}
|
|
|
|
|
|
dimensionMessage.value = t('model.editor.dimensionFailed')
|
2025-11-07 07:52:52 +00:00
|
|
|
|
MessagePlugin.warning(dimensionMessage.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error: any) {
|
2026-03-06 13:27:50 +00:00
|
|
|
|
console.error('Ollama dimension check failed:', error)
|
2025-11-07 07:52:52 +00:00
|
|
|
|
dimensionChecked.value = true
|
|
|
|
|
|
dimensionSuccess.value = false
|
2026-03-06 13:27:50 +00:00
|
|
|
|
dimensionMessage.value = t('model.editor.dimensionFailed')
|
2025-11-07 07:52:52 +00:00
|
|
|
|
MessagePlugin.error(dimensionMessage.value)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
checking.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
// 检查 Remote API 连接(根据模型类型调用不同的接口)
|
|
|
|
|
|
const checkRemoteAPI = async () => {
|
|
|
|
|
|
if (!formData.value.modelName || !formData.value.baseUrl) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.warning(t('model.editor.fillModelAndUrl'))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
checking.value = true
|
|
|
|
|
|
remoteChecked.value = false
|
|
|
|
|
|
remoteMessage.value = ''
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
let result: any
|
|
|
|
|
|
|
|
|
|
|
|
// 根据模型类型调用不同的校验接口
|
|
|
|
|
|
switch (props.modelType) {
|
|
|
|
|
|
case 'chat':
|
|
|
|
|
|
// 对话模型(KnowledgeQA)
|
|
|
|
|
|
result = await checkRemoteModel({
|
|
|
|
|
|
modelName: formData.value.modelName,
|
|
|
|
|
|
baseUrl: formData.value.baseUrl,
|
|
|
|
|
|
apiKey: formData.value.apiKey || ''
|
|
|
|
|
|
})
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
case 'embedding':
|
|
|
|
|
|
// Embedding 模型
|
|
|
|
|
|
result = await testEmbeddingModel({
|
|
|
|
|
|
source: 'remote',
|
|
|
|
|
|
modelName: formData.value.modelName,
|
|
|
|
|
|
baseUrl: formData.value.baseUrl,
|
|
|
|
|
|
apiKey: formData.value.apiKey || '',
|
2025-12-28 17:31:27 +00:00
|
|
|
|
dimension: formData.value.dimension,
|
|
|
|
|
|
provider: formData.value.provider
|
2025-11-05 15:18:44 +00:00
|
|
|
|
})
|
|
|
|
|
|
// 如果测试成功且返回了维度,自动填充
|
|
|
|
|
|
if (result.available && result.dimension) {
|
|
|
|
|
|
formData.value.dimension = result.dimension
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.info(t('model.editor.remoteDimensionDetected', { value: result.dimension }))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
case 'rerank':
|
|
|
|
|
|
// Rerank 模型
|
|
|
|
|
|
result = await checkRerankModel({
|
|
|
|
|
|
modelName: formData.value.modelName,
|
|
|
|
|
|
baseUrl: formData.value.baseUrl,
|
|
|
|
|
|
apiKey: formData.value.apiKey || ''
|
|
|
|
|
|
})
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
case 'vllm':
|
|
|
|
|
|
// VLLM 模型(多模态)
|
|
|
|
|
|
// VLLM 使用 checkRemoteModel 进行基础连接测试
|
|
|
|
|
|
result = await checkRemoteModel({
|
|
|
|
|
|
modelName: formData.value.modelName,
|
|
|
|
|
|
baseUrl: formData.value.baseUrl,
|
|
|
|
|
|
apiKey: formData.value.apiKey || ''
|
|
|
|
|
|
})
|
|
|
|
|
|
break
|
2026-04-02 08:43:37 +00:00
|
|
|
|
|
|
|
|
|
|
case 'asr':
|
2026-04-02 12:53:44 +00:00
|
|
|
|
// ASR 模型(语音识别)— 使用专用的 ASR 测试接口(/v1/audio/transcriptions)
|
|
|
|
|
|
result = await checkASRModel({
|
2026-04-02 08:43:37 +00:00
|
|
|
|
modelName: formData.value.modelName,
|
|
|
|
|
|
baseUrl: formData.value.baseUrl,
|
|
|
|
|
|
apiKey: formData.value.apiKey || ''
|
|
|
|
|
|
})
|
|
|
|
|
|
break
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
default:
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.error(t('model.editor.unsupportedModelType'))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
remoteChecked.value = true
|
|
|
|
|
|
remoteAvailable.value = result.available || false
|
2026-03-06 13:27:50 +00:00
|
|
|
|
// Always use i18n for display; backend message is for debugging only
|
|
|
|
|
|
if (result.message) {
|
|
|
|
|
|
console.debug('Backend message:', result.message)
|
|
|
|
|
|
}
|
|
|
|
|
|
remoteMessage.value = result.available
|
|
|
|
|
|
? t('model.editor.connectionSuccess')
|
|
|
|
|
|
: t('model.editor.connectionFailed')
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
if (result.available) {
|
|
|
|
|
|
MessagePlugin.success(remoteMessage.value)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
MessagePlugin.error(remoteMessage.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error: any) {
|
2026-03-06 13:27:50 +00:00
|
|
|
|
console.error('Remote API check failed:', error)
|
2025-11-05 15:18:44 +00:00
|
|
|
|
remoteChecked.value = true
|
|
|
|
|
|
remoteAvailable.value = false
|
2026-03-06 13:27:50 +00:00
|
|
|
|
remoteMessage.value = t('model.editor.connectionConfigError')
|
2025-11-05 15:18:44 +00:00
|
|
|
|
MessagePlugin.error(remoteMessage.value)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
checking.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 确认保存
|
|
|
|
|
|
const handleConfirm = async () => {
|
|
|
|
|
|
try {
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 手动校验必填字段
|
|
|
|
|
|
if (!formData.value.modelName || !formData.value.modelName.trim()) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.warning(t('model.editor.validation.modelNameRequired'))
|
2025-11-06 16:30:15 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (formData.value.modelName.trim().length > 100) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.warning(t('model.editor.validation.modelNameMax'))
|
2025-11-06 16:30:15 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果是 remote 类型,必须填写 baseUrl
|
|
|
|
|
|
if (formData.value.source === 'remote') {
|
|
|
|
|
|
if (!formData.value.baseUrl || !formData.value.baseUrl.trim()) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.warning(t('model.editor.remoteBaseUrlRequired'))
|
2025-11-06 16:30:15 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 校验 Base URL 格式
|
|
|
|
|
|
try {
|
|
|
|
|
|
new URL(formData.value.baseUrl.trim())
|
|
|
|
|
|
} catch {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.warning(t('model.editor.validation.baseUrlInvalid'))
|
2025-11-06 16:30:15 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 执行表单验证
|
2025-11-05 15:18:44 +00:00
|
|
|
|
await formRef.value?.validate()
|
|
|
|
|
|
saving.value = true
|
|
|
|
|
|
|
|
|
|
|
|
// 如果是新增且没有 id,生成一个
|
|
|
|
|
|
if (!formData.value.id) {
|
|
|
|
|
|
formData.value.id = generateId()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
emit('confirm', { ...formData.value })
|
|
|
|
|
|
dialogVisible.value = false
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 移除此处的成功提示,由父组件统一处理
|
2025-11-05 15:18:44 +00:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('表单验证失败:', error)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
saving.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-07 07:52:52 +00:00
|
|
|
|
// 监听模型选择变化(处理下载逻辑和自动维度检测提示)
|
|
|
|
|
|
watch(() => formData.value.modelName, async (newValue, oldValue) => {
|
|
|
|
|
|
if (!newValue) return
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-07 07:52:52 +00:00
|
|
|
|
// 处理下载逻辑
|
|
|
|
|
|
if (newValue.startsWith('__download__')) {
|
2025-11-07 08:40:53 +00:00
|
|
|
|
// 提取模型名称
|
|
|
|
|
|
const modelName = newValue.replace('__download__', '')
|
|
|
|
|
|
|
|
|
|
|
|
// 重置选择(避免显示 __download__ 前缀)
|
|
|
|
|
|
formData.value.modelName = ''
|
|
|
|
|
|
|
|
|
|
|
|
// 开始下载
|
|
|
|
|
|
await startDownload(modelName)
|
2025-11-07 07:52:52 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-07 07:52:52 +00:00
|
|
|
|
// 如果是 embedding 模型且选择的是 Ollama 本地模型,且模型名称发生了实际变化
|
|
|
|
|
|
if (props.modelType === 'embedding' &&
|
|
|
|
|
|
formData.value.source === 'local' &&
|
|
|
|
|
|
newValue !== oldValue &&
|
|
|
|
|
|
oldValue !== '') {
|
|
|
|
|
|
// 提示用户可以检测维度
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.info(t('model.editor.dimensionHint'))
|
2025-11-07 07:52:52 +00:00
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 开始下载模型
|
|
|
|
|
|
const startDownload = async (modelName: string) => {
|
|
|
|
|
|
downloading.value = true
|
|
|
|
|
|
downloadProgress.value = 0
|
|
|
|
|
|
currentDownloadModel.value = modelName
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 启动下载
|
|
|
|
|
|
const result = await downloadOllamaModel(modelName)
|
|
|
|
|
|
const taskId = result.taskId
|
|
|
|
|
|
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.success(t('model.editor.downloadStarted', { name: modelName }))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
// 轮询下载进度
|
|
|
|
|
|
downloadInterval = setInterval(async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const progress = await getDownloadProgress(taskId)
|
|
|
|
|
|
downloadProgress.value = progress.progress
|
|
|
|
|
|
|
|
|
|
|
|
if (progress.status === 'completed') {
|
|
|
|
|
|
// 下载完成
|
|
|
|
|
|
clearInterval(downloadInterval)
|
|
|
|
|
|
downloadInterval = null
|
|
|
|
|
|
downloading.value = false
|
|
|
|
|
|
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.success(t('model.editor.downloadCompleted', { name: modelName }))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
// 刷新模型列表
|
|
|
|
|
|
await loadOllamaModels()
|
|
|
|
|
|
|
|
|
|
|
|
// 自动选中新下载的模型
|
|
|
|
|
|
formData.value.modelName = modelName
|
|
|
|
|
|
|
|
|
|
|
|
// 重置状态
|
|
|
|
|
|
downloadProgress.value = 0
|
|
|
|
|
|
currentDownloadModel.value = ''
|
|
|
|
|
|
|
|
|
|
|
|
} else if (progress.status === 'failed') {
|
|
|
|
|
|
// 下载失败
|
|
|
|
|
|
clearInterval(downloadInterval)
|
|
|
|
|
|
downloadInterval = null
|
|
|
|
|
|
downloading.value = false
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.error(progress.message || t('model.editor.downloadFailed', { name: modelName }))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
downloadProgress.value = 0
|
|
|
|
|
|
currentDownloadModel.value = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取下载进度失败:', error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 1000) // 每秒查询一次
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
|
downloading.value = false
|
|
|
|
|
|
downloadProgress.value = 0
|
|
|
|
|
|
currentDownloadModel.value = ''
|
2026-03-06 13:27:50 +00:00
|
|
|
|
console.error('Download start failed:', error)
|
|
|
|
|
|
MessagePlugin.error(t('model.editor.downloadStartFailed'))
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 组件卸载时清理定时器
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
|
if (downloadInterval) {
|
|
|
|
|
|
clearInterval(downloadInterval)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 监听来源变化,清理所有状态
|
|
|
|
|
|
watch(() => formData.value.source, () => {
|
|
|
|
|
|
// 重置校验状态
|
|
|
|
|
|
modelChecked.value = false
|
|
|
|
|
|
modelAvailable.value = false
|
|
|
|
|
|
remoteChecked.value = false
|
|
|
|
|
|
remoteAvailable.value = false
|
|
|
|
|
|
remoteMessage.value = ''
|
2025-11-07 07:52:52 +00:00
|
|
|
|
dimensionChecked.value = false
|
|
|
|
|
|
dimensionSuccess.value = false
|
|
|
|
|
|
dimensionMessage.value = ''
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
// 清理下载状态
|
|
|
|
|
|
searchKeyword.value = ''
|
|
|
|
|
|
if (downloadInterval) {
|
|
|
|
|
|
clearInterval(downloadInterval)
|
|
|
|
|
|
downloadInterval = null
|
|
|
|
|
|
}
|
|
|
|
|
|
downloading.value = false
|
|
|
|
|
|
downloadProgress.value = 0
|
|
|
|
|
|
currentDownloadModel.value = ''
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-11-07 07:52:52 +00:00
|
|
|
|
// 监听模型名称变化,清理维度检测状态
|
|
|
|
|
|
watch(() => formData.value.modelName, () => {
|
|
|
|
|
|
dimensionChecked.value = false
|
|
|
|
|
|
dimensionSuccess.value = false
|
|
|
|
|
|
dimensionMessage.value = ''
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
// 取消
|
|
|
|
|
|
const handleCancel = () => {
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
}
|
2026-03-02 07:19:47 +00:00
|
|
|
|
|
|
|
|
|
|
// 遮罩层点击关闭:只有 mousedown 和 mouseup 都发生在遮罩层上才关闭,
|
|
|
|
|
|
// 防止在输入框中拖选文字时鼠标滑出弹窗导致误关闭
|
|
|
|
|
|
let overlayMouseDownFired = false
|
|
|
|
|
|
const handleOverlayMouseDown = () => {
|
|
|
|
|
|
overlayMouseDownFired = true
|
|
|
|
|
|
}
|
|
|
|
|
|
const handleOverlayMouseUp = () => {
|
|
|
|
|
|
if (overlayMouseDownFired) {
|
|
|
|
|
|
handleCancel()
|
|
|
|
|
|
}
|
|
|
|
|
|
overlayMouseDownFired = false
|
|
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 遮罩层
|
|
|
|
|
|
.model-editor-overlay {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
background: rgba(0, 0, 0, 0.5);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
2025-12-03 03:11:57 +00:00
|
|
|
|
z-index: 1200;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
backdrop-filter: blur(4px);
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
padding: 20px;
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 弹窗主体
|
|
|
|
|
|
.model-editor-modal {
|
|
|
|
|
|
position: relative;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
max-width: 560px;
|
|
|
|
|
|
max-height: 90vh;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-container);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
border-radius: 12px;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
box-shadow: 0 6px 28px rgba(15, 23, 42, 0.08);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 关闭按钮
|
|
|
|
|
|
.close-btn {
|
|
|
|
|
|
position: absolute;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
top: 16px;
|
|
|
|
|
|
right: 16px;
|
2025-11-06 16:30:15 +00:00
|
|
|
|
width: 32px;
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
border: none;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
background: transparent;
|
|
|
|
|
|
border-radius: 6px;
|
2025-11-06 16:30:15 +00:00
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-secondary);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
transition: all 0.15s ease;
|
2025-11-06 16:30:15 +00:00
|
|
|
|
z-index: 10;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-secondarycontainer);
|
|
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 标题区域
|
|
|
|
|
|
.modal-header {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
padding: 24px 24px 16px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-bottom: 1px solid var(--td-component-stroke);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.modal-title {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
margin: 0 0 6px 0;
|
|
|
|
|
|
font-size: 18px;
|
2025-11-06 16:30:15 +00:00
|
|
|
|
font-weight: 600;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.modal-desc {
|
|
|
|
|
|
margin: 0;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 13px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-secondary);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
line-height: 1.5;
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 内容区域
|
|
|
|
|
|
.modal-body {
|
|
|
|
|
|
flex: 1;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
overflow-y: auto;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
padding: 24px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-container);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
// 自定义滚动条
|
|
|
|
|
|
&::-webkit-scrollbar {
|
|
|
|
|
|
width: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&::-webkit-scrollbar-track {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-secondarycontainer);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
border-radius: 3px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&::-webkit-scrollbar-thumb {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-component-disabled);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
border-radius: 3px;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
transition: background 0.15s;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
&:hover {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-component-disabled);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
:deep(.t-form) {
|
|
|
|
|
|
.t-form-item {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
display: none;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 表单项样式
|
|
|
|
|
|
.form-item {
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
&:last-child {
|
2025-11-05 15:18:44 +00:00
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
|
}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
.form-label {
|
|
|
|
|
|
display: block;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
margin-bottom: 8px;
|
2025-11-06 16:30:15 +00:00
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
font-weight: 500;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
&.required::after {
|
|
|
|
|
|
content: '*';
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-error-color);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
margin-left: 4px;
|
2025-11-14 04:09:52 +00:00
|
|
|
|
font-weight: 600;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 输入框样式
|
|
|
|
|
|
:deep(.t-input),
|
|
|
|
|
|
:deep(.t-select),
|
|
|
|
|
|
:deep(.t-textarea),
|
|
|
|
|
|
:deep(.t-input-number) {
|
|
|
|
|
|
width: 100%;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
.t-input__inner,
|
2025-11-20 17:07:28 +00:00
|
|
|
|
.t-input__wrap,
|
|
|
|
|
|
input,
|
|
|
|
|
|
textarea {
|
|
|
|
|
|
font-size: 13px;
|
2025-11-14 04:09:52 +00:00
|
|
|
|
border-radius: 6px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-color: var(--td-component-stroke);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
transition: all 0.15s ease;
|
2025-11-14 04:09:52 +00:00
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
&:hover .t-input__inner,
|
2025-11-20 17:07:28 +00:00
|
|
|
|
&:hover .t-input__wrap,
|
|
|
|
|
|
&:hover input,
|
|
|
|
|
|
&:hover textarea {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-color: var(--td-component-stroke);
|
2025-11-14 04:09:52 +00:00
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
&.t-is-focused .t-input__inner,
|
2025-11-20 17:07:28 +00:00
|
|
|
|
&.t-is-focused .t-input__wrap,
|
|
|
|
|
|
&.t-is-focused input,
|
|
|
|
|
|
&.t-is-focused textarea {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-color: var(--td-brand-color);
|
2025-11-14 04:09:52 +00:00
|
|
|
|
box-shadow: 0 0 0 2px rgba(7, 192, 95, 0.1);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2026-04-02 12:53:44 +00:00
|
|
|
|
// 厂商选择器样式 — 移至非 scoped 块,因为 t-select popup 渲染到 body 下
|
|
|
|
|
|
// .provider-option 样式见文件末尾
|
2025-12-28 17:31:27 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 单选按钮组
|
|
|
|
|
|
:deep(.t-radio-group) {
|
|
|
|
|
|
display: flex;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
gap: 24px;
|
|
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
.t-radio {
|
|
|
|
|
|
margin-right: 0;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
&:hover {
|
|
|
|
|
|
.t-radio__label {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-14 04:09:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
.t-radio__label {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 13px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
transition: color 0.15s ease;
|
2025-11-14 04:09:52 +00:00
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
.t-radio__input:checked + .t-radio__label {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-14 04:09:52 +00:00
|
|
|
|
font-weight: 500;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 复选框
|
|
|
|
|
|
:deep(.t-checkbox) {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 13px;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
.t-checkbox__label {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 13px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 底部按钮区域
|
|
|
|
|
|
.modal-footer {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
padding: 16px 24px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-top: 1px solid var(--td-component-stroke);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
flex-shrink: 0;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-secondarycontainer);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
:deep(.t-button) {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
min-width: 80px;
|
2025-11-14 04:09:52 +00:00
|
|
|
|
height: 36px;
|
|
|
|
|
|
font-weight: 500;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 14px;
|
2025-11-14 04:09:52 +00:00
|
|
|
|
border-radius: 6px;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
transition: all 0.15s ease;
|
|
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
&.t-button--theme-primary {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-brand-color);
|
|
|
|
|
|
border-color: var(--td-brand-color);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
&:hover {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-brand-color);
|
|
|
|
|
|
border-color: var(--td-brand-color);
|
2025-11-14 04:09:52 +00:00
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
|
|
|
|
|
&:active {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-brand-color-active);
|
|
|
|
|
|
border-color: var(--td-brand-color-active);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
}
|
2025-11-14 04:09:52 +00:00
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
&.t-button--variant-outline {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-secondary);
|
|
|
|
|
|
border-color: var(--td-component-stroke);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-14 04:09:52 +00:00
|
|
|
|
&:hover {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-color: var(--td-brand-color);
|
|
|
|
|
|
color: var(--td-brand-color);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
background: rgba(7, 192, 95, 0.04);
|
2025-11-14 04:09:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// 过渡动画
|
|
|
|
|
|
.modal-enter-active,
|
|
|
|
|
|
.modal-leave-active {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
transition: opacity 0.2s ease;
|
|
|
|
|
|
|
|
|
|
|
|
.model-editor-modal {
|
|
|
|
|
|
transition: transform 0.2s ease, opacity 0.2s ease;
|
|
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
.modal-enter-from,
|
|
|
|
|
|
.modal-leave-to {
|
|
|
|
|
|
opacity: 0;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
.model-editor-modal {
|
|
|
|
|
|
transform: scale(0.95);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
opacity: 0;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
// API 测试区域
|
2025-11-05 15:18:44 +00:00
|
|
|
|
.api-test-section {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
|
|
|
|
|
|
.test-message {
|
2025-11-06 16:30:15 +00:00
|
|
|
|
font-size: 13px;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
line-height: 1.5;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
&.success {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color-active);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
&.error {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-error-color);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
:deep(.t-button) {
|
2025-11-20 17:07:28 +00:00
|
|
|
|
min-width: 88px;
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
flex-shrink: 0;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
.status-icon {
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
flex-shrink: 0;
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
&.available {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-06 16:30:15 +00:00
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
|
2025-11-06 16:30:15 +00:00
|
|
|
|
&.unavailable {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-error-color);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Ollama 模型选择器样式
|
|
|
|
|
|
.model-option {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
padding: 4px 0;
|
|
|
|
|
|
|
|
|
|
|
|
.downloaded-icon {
|
|
|
|
|
|
font-size: 14px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.download-icon {
|
|
|
|
|
|
font-size: 14px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.model-name {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
font-size: 13px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.model-size {
|
|
|
|
|
|
font-size: 12px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-placeholder);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
margin-left: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.download {
|
|
|
|
|
|
.model-name {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 下载进度后缀样式
|
|
|
|
|
|
.download-suffix {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
padding: 0 4px;
|
|
|
|
|
|
|
|
|
|
|
|
.spinning {
|
|
|
|
|
|
animation: spin 1s linear infinite;
|
|
|
|
|
|
font-size: 14px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.progress-text {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
font-weight: 500;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 下载中的选择框进度条效果
|
|
|
|
|
|
:deep(.t-select.downloading) {
|
|
|
|
|
|
.t-input {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
|
|
content: '';
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
width: var(--progress, 0%);
|
|
|
|
|
|
background: linear-gradient(90deg, rgba(7, 192, 95, 0.08), rgba(7, 192, 95, 0.15));
|
|
|
|
|
|
transition: width 0.3s ease;
|
|
|
|
|
|
z-index: 0;
|
|
|
|
|
|
border-radius: 5px 0 0 5px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.t-input__inner,
|
|
|
|
|
|
input {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
background: transparent !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-07 07:52:52 +00:00
|
|
|
|
.model-select-row {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
.t-select {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
|
|
|
|
|
:deep(.t-button) {
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
2025-11-07 07:52:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
.refresh-btn {
|
2025-11-07 07:52:52 +00:00
|
|
|
|
margin-top: 0;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 13px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-secondary);
|
2025-11-07 07:52:52 +00:00
|
|
|
|
flex-shrink: 0;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
2025-11-05 15:18:44 +00:00
|
|
|
|
&:hover {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
background: rgba(7, 192, 95, 0.04);
|
2025-11-05 15:18:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@keyframes spin {
|
|
|
|
|
|
from { transform: rotate(0deg); }
|
|
|
|
|
|
to { transform: rotate(360deg); }
|
|
|
|
|
|
}
|
2025-11-07 07:52:52 +00:00
|
|
|
|
|
|
|
|
|
|
// 维度控制样式
|
|
|
|
|
|
.dimension-control {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.t-input) {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.dimension-check-btn {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.dimension-hint {
|
|
|
|
|
|
margin: 8px 0 0 0;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
line-height: 1.5;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-error-color);
|
2025-11-07 07:52:52 +00:00
|
|
|
|
|
|
|
|
|
|
&.success {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-07 07:52:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
|
|
|
|
|
|
// Ollama不可用提示样式
|
|
|
|
|
|
.ollama-unavailable-tip {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
margin-top: 12px;
|
|
|
|
|
|
padding: 10px 12px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-error-color-light);
|
|
|
|
|
|
border: 1px solid var(--td-error-color-focus);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
|
|
|
|
|
|
.tip-icon {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-error-color);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
margin-right: 2px;
|
2025-12-18 02:49:45 +00:00
|
|
|
|
|
|
|
|
|
|
&.info {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-12-18 02:49:45 +00:00
|
|
|
|
}
|
2025-11-20 17:07:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.tip-text {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-error-color);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
flex: 1;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 02:49:45 +00:00
|
|
|
|
// ReRank提示使用主题绿色风格,与主页面保持一致
|
|
|
|
|
|
&.rerank-tip {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-success-color-light);
|
|
|
|
|
|
border: 1px solid var(--td-success-color-focus);
|
|
|
|
|
|
border-left: 3px solid var(--td-brand-color);
|
2025-12-18 02:49:45 +00:00
|
|
|
|
|
|
|
|
|
|
.tip-text {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-success-color);
|
2025-12-18 02:49:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-20 17:07:28 +00:00
|
|
|
|
:deep(.tip-link) {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-20 17:07:28 +00:00
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
padding: 4px 6px 4px 10px !important;
|
|
|
|
|
|
min-height: auto !important;
|
|
|
|
|
|
height: auto !important;
|
|
|
|
|
|
line-height: 1.4 !important;
|
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
display: inline-flex !important;
|
|
|
|
|
|
align-items: center !important;
|
|
|
|
|
|
gap: 1px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
background: rgba(7, 192, 95, 0.08) !important;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color-active) !important;
|
2025-11-20 17:07:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
|
|
background: rgba(7, 192, 95, 0.12) !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.t-icon {
|
|
|
|
|
|
font-size: 14px !important;
|
|
|
|
|
|
margin: 0 !important;
|
|
|
|
|
|
line-height: 1 !important;
|
|
|
|
|
|
display: inline-flex !important;
|
|
|
|
|
|
align-items: center !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-05 15:18:44 +00:00
|
|
|
|
</style>
|
2026-04-02 12:53:44 +00:00
|
|
|
|
|
|
|
|
|
|
<!-- 非 scoped 样式:t-select popup 渲染到 body 下,scoped 样式无法覆盖 -->
|
|
|
|
|
|
<style lang="less">
|
|
|
|
|
|
.provider-select-popup {
|
|
|
|
|
|
// 覆盖 TDesign option 默认固定高度,让两行内容正常展示
|
|
|
|
|
|
.t-select-option {
|
|
|
|
|
|
height: auto !important;
|
|
|
|
|
|
padding: 0 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.provider-option {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 2px;
|
|
|
|
|
|
padding: 6px 0;
|
|
|
|
|
|
|
|
|
|
|
|
.provider-name {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: var(--td-text-color-primary);
|
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.provider-desc {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: var(--td-text-color-placeholder);
|
|
|
|
|
|
line-height: 18px;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|