feat: Add folder upload functionality and enhance document upload experience
- Introduced a new option for users to upload entire folders, improving document management capabilities. - Enhanced file type verification to provide better feedback for unsupported files during uploads. - Updated UI components in the menu for clearer action items related to document uploads. - Improved localization support for new upload messages in English, Russian, and Chinese.
This commit is contained in:
@@ -23,9 +23,29 @@
|
||||
<div class="form-item">
|
||||
<label class="form-label required">{{ $t('model.editor.sourceLabel') }}</label>
|
||||
<t-radio-group v-model="formData.source">
|
||||
<t-radio value="local">{{ $t('model.editor.sourceLocal') }}</t-radio>
|
||||
<t-radio
|
||||
value="local"
|
||||
:disabled="ollamaServiceStatus === false"
|
||||
>
|
||||
{{ $t('model.editor.sourceLocal') }}
|
||||
</t-radio>
|
||||
<t-radio value="remote">{{ $t('model.editor.sourceRemote') }}</t-radio>
|
||||
</t-radio-group>
|
||||
|
||||
<!-- Ollama不可用时的提示信息 -->
|
||||
<div v-if="ollamaServiceStatus === false" 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"
|
||||
theme="primary"
|
||||
@click="goToOllamaSettings"
|
||||
class="tip-link"
|
||||
>
|
||||
{{ $t('model.editor.goToOllamaSettings') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ollama 本地模型选择器 -->
|
||||
@@ -205,10 +225,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed, onUnmounted } from 'vue'
|
||||
import { ref, watch, computed, onUnmounted, nextTick } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { checkOllamaModels, checkRemoteModel, testEmbeddingModel, checkRerankModel, listOllamaModels, downloadOllamaModel, getDownloadProgress, type OllamaModelInfo } from '@/api/initialization'
|
||||
import { checkOllamaModels, checkRemoteModel, testEmbeddingModel, checkRerankModel, listOllamaModels, downloadOllamaModel, getDownloadProgress, checkOllamaStatus, type OllamaModelInfo } from '@/api/initialization'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
|
||||
interface ModelFormData {
|
||||
id: string
|
||||
@@ -229,6 +250,7 @@ interface Props {
|
||||
}
|
||||
|
||||
const { t } = useI18n()
|
||||
const uiStore = useUIStore()
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
visible: false,
|
||||
@@ -268,6 +290,10 @@ const downloadProgress = ref(0)
|
||||
const currentDownloadModel = ref('')
|
||||
let downloadInterval: any = null
|
||||
|
||||
// Ollama 服务状态
|
||||
const ollamaServiceStatus = ref<boolean | null>(null)
|
||||
const checkingOllamaStatus = ref(false)
|
||||
|
||||
const formData = ref<ModelFormData>({
|
||||
id: '',
|
||||
name: '',
|
||||
@@ -344,12 +370,50 @@ const getBaseUrlPlaceholder = () => {
|
||||
: t('model.editor.baseUrlPlaceholder')
|
||||
}
|
||||
|
||||
// 检查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调用完成')
|
||||
}
|
||||
|
||||
// 监听 visible 变化,初始化表单
|
||||
watch(() => props.visible, (val) => {
|
||||
if (val) {
|
||||
// 锁定背景滚动
|
||||
document.body.style.overflow = 'hidden'
|
||||
|
||||
|
||||
// 检查Ollama服务状态
|
||||
checkOllamaServiceStatus()
|
||||
|
||||
if (props.modelData) {
|
||||
formData.value = { ...props.modelData }
|
||||
} else {
|
||||
@@ -781,24 +845,25 @@ const handleCancel = () => {
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
backdrop-filter: blur(6px);
|
||||
overflow: hidden; // 防止背景滚动
|
||||
backdrop-filter: blur(4px);
|
||||
overflow: hidden;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
// 弹窗主体
|
||||
.model-editor-modal {
|
||||
position: relative;
|
||||
width: 90vw;
|
||||
max-width: 600px;
|
||||
max-height: 85vh;
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
max-height: 90vh;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 0 6px 28px rgba(15, 23, 42, 0.08);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
@@ -807,57 +872,53 @@ const handleCancel = () => {
|
||||
// 关闭按钮
|
||||
.close-btn {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
background: #f5f5f5;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #666;
|
||||
transition: background-color 0.2s ease, color 0.2s ease;
|
||||
color: #666666;
|
||||
transition: all 0.15s ease;
|
||||
z-index: 10;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.1);
|
||||
color: #07C05F;
|
||||
background: #f5f5f5;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
// 标题区域
|
||||
.modal-header {
|
||||
padding: 28px 32px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding: 24px 24px 16px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
margin: 0 0 8px 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 20px;
|
||||
margin: 0 0 6px 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
letter-spacing: -0.3px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.modal-desc {
|
||||
margin: 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #666666;
|
||||
line-height: 22px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
// 内容区域
|
||||
.modal-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 28px 32px;
|
||||
padding: 24px;
|
||||
background: #ffffff;
|
||||
|
||||
// 自定义滚动条
|
||||
@@ -873,16 +934,16 @@ const handleCancel = () => {
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: #d0d0d0;
|
||||
border-radius: 3px;
|
||||
transition: background 0.2s;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: #07C05F;
|
||||
background: #b0b0b0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-form) {
|
||||
.t-form-item {
|
||||
display: none; // 隐藏 t-form-item,使用自定义的 form-item
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -898,16 +959,14 @@ const handleCancel = () => {
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
font-family: "PingFang SC";
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
letter-spacing: -0.2px;
|
||||
|
||||
&.required::after {
|
||||
content: '*';
|
||||
color: #FA5151;
|
||||
color: #f56c6c;
|
||||
margin-left: 4px;
|
||||
font-weight: 600;
|
||||
}
|
||||
@@ -919,23 +978,29 @@ const handleCancel = () => {
|
||||
:deep(.t-textarea),
|
||||
:deep(.t-input-number) {
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
font-size: 13px;
|
||||
|
||||
.t-input__inner,
|
||||
input {
|
||||
font-size: 14px;
|
||||
.t-input__wrap,
|
||||
input,
|
||||
textarea {
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
transition: all 0.2s ease;
|
||||
border-color: #d9d9d9;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
|
||||
&:hover .t-input__inner,
|
||||
&:hover input {
|
||||
border-color: #07C05F;
|
||||
&:hover .t-input__wrap,
|
||||
&:hover input,
|
||||
&:hover textarea {
|
||||
border-color: #b3b3b3;
|
||||
}
|
||||
|
||||
|
||||
&.t-is-focused .t-input__inner,
|
||||
&.t-is-focused input {
|
||||
&.t-is-focused .t-input__wrap,
|
||||
&.t-is-focused input,
|
||||
&.t-is-focused textarea {
|
||||
border-color: #07C05F;
|
||||
box-shadow: 0 0 0 2px rgba(7, 192, 95, 0.1);
|
||||
}
|
||||
@@ -944,13 +1009,12 @@ const handleCancel = () => {
|
||||
// 单选按钮组
|
||||
:deep(.t-radio-group) {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
|
||||
gap: 24px;
|
||||
|
||||
.t-radio {
|
||||
margin-right: 0;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
font-size: 13px;
|
||||
|
||||
&:hover {
|
||||
.t-radio__label {
|
||||
color: #07C05F;
|
||||
@@ -959,11 +1023,11 @@ const handleCancel = () => {
|
||||
}
|
||||
|
||||
.t-radio__label {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #333333;
|
||||
transition: color 0.2s ease;
|
||||
transition: color 0.15s ease;
|
||||
}
|
||||
|
||||
|
||||
.t-radio__input:checked + .t-radio__label {
|
||||
color: #07C05F;
|
||||
font-weight: 500;
|
||||
@@ -972,44 +1036,55 @@ const handleCancel = () => {
|
||||
|
||||
// 复选框
|
||||
:deep(.t-checkbox) {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
|
||||
.t-checkbox__label {
|
||||
font-size: 14px;
|
||||
color: #000000e6;
|
||||
font-size: 13px;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
// 底部按钮区域
|
||||
.modal-footer {
|
||||
padding: 20px 32px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding: 16px 24px;
|
||||
border-top: 1px solid #e5e7eb;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
background: #fafafa;
|
||||
|
||||
|
||||
:deep(.t-button) {
|
||||
min-width: 88px;
|
||||
min-width: 80px;
|
||||
height: 36px;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
border-radius: 6px;
|
||||
|
||||
transition: all 0.15s ease;
|
||||
|
||||
&.t-button--theme-primary {
|
||||
background: #07C05F;
|
||||
border-color: #07C05F;
|
||||
|
||||
|
||||
&:hover {
|
||||
background: #06b04d;
|
||||
border-color: #06b04d;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #059642;
|
||||
border-color: #059642;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&.t-button--variant-outline {
|
||||
color: #666666;
|
||||
border-color: #d9d9d9;
|
||||
|
||||
&:hover {
|
||||
border-color: #07C05F;
|
||||
color: #07C05F;
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1018,7 +1093,11 @@ const handleCancel = () => {
|
||||
// 过渡动画
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: all 0.3s ease;
|
||||
transition: opacity 0.2s ease;
|
||||
|
||||
.model-editor-modal {
|
||||
transition: transform 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-enter-from,
|
||||
@@ -1027,6 +1106,7 @@ const handleCancel = () => {
|
||||
|
||||
.model-editor-modal {
|
||||
transform: scale(0.95);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,20 +1119,25 @@ const handleCancel = () => {
|
||||
.test-message {
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
|
||||
flex: 1;
|
||||
|
||||
&.success {
|
||||
color: #07C05F;
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
|
||||
&.error {
|
||||
color: #e34d59;
|
||||
color: #f56c6c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
:deep(.t-button) {
|
||||
min-width: 100px;
|
||||
min-width: 88px;
|
||||
height: 32px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
|
||||
.status-icon {
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
@@ -1062,7 +1147,7 @@ const handleCancel = () => {
|
||||
}
|
||||
|
||||
&.unavailable {
|
||||
color: #e34d59;
|
||||
color: #f56c6c;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1163,16 +1248,24 @@ const handleCancel = () => {
|
||||
.t-select {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
:deep(.t-button) {
|
||||
height: 32px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
margin-top: 0;
|
||||
font-size: 12px;
|
||||
font-size: 13px;
|
||||
color: #666666;
|
||||
flex-shrink: 0;
|
||||
|
||||
|
||||
&:hover {
|
||||
color: #07C05F;
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,5 +1300,65 @@ const handleCancel = () => {
|
||||
color: #07C05F;
|
||||
}
|
||||
}
|
||||
|
||||
// Ollama不可用提示样式
|
||||
.ollama-unavailable-tip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
background: #fef2f2;
|
||||
border: 1px solid #fecaca;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
|
||||
.tip-icon {
|
||||
color: #f56c6c;
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
color: #dc2626;
|
||||
flex: 1;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
:deep(.tip-link) {
|
||||
color: #07C05F;
|
||||
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;
|
||||
color: #05a04f !important;
|
||||
}
|
||||
|
||||
&: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;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -32,10 +32,21 @@
|
||||
<span class="kb-action-title">{{ t('upload.uploadDocument') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu_item kb-action-item" @click.stop="handleDocFolderUploadClick">
|
||||
<div class="kb-action-icon-wrapper">
|
||||
<svg class="kb-action-icon" width="18" height="18" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M22 19C22 19.5304 21.7893 20.0391 21.4142 20.4142C21.0391 20.7893 20.5304 21 20 21H4C3.46957 21 2.96086 20.7893 2.58579 20.4142C2.21071 20.0391 2 19.5304 2 19V5C2 4.46957 2.21071 3.96086 2.58579 3.58579C2.96086 3.21071 3.46957 3 4 3H9L11 6H20C20.5304 6 21.0391 6.21071 21.4142 6.58579C21.7893 6.96086 22 7.46957 22 8V19Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M12 11V17M9 14H15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="kb-action-content">
|
||||
<span class="kb-action-title">{{ t('upload.uploadFolder') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu_item kb-action-item" @click.stop="handleDocURLImport">
|
||||
<div class="kb-action-icon-wrapper">
|
||||
<svg class="kb-action-icon" width="18" height="18" viewBox="0 0 18 18" fill="none">
|
||||
<path d="M7.5 10.5L10.5 7.5M7.875 5.625L6.9375 4.6875C6.15326 3.90326 5.09511 3.46585 3.99 3.46585C2.88489 3.46585 1.82674 3.90326 1.0425 4.6875C0.258257 5.47174 -0.179153 6.52989 -0.179153 7.635C-0.179153 8.74011 0.258257 9.79826 1.0425 10.5825L2.25 11.7975M10.125 12.375L11.0625 13.3125C11.8467 14.0967 12.9049 14.5341 14.01 14.5341C15.1151 14.5341 16.1733 14.0967 16.9575 13.3125C17.7417 12.5283 18.1791 11.4701 18.1791 10.365C18.1791 9.25989 17.7417 8.20174 16.9575 7.4175L15.75 6.2025M5.625 12.375L12.375 5.625" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<svg class="kb-action-icon" width="18" height="18" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M10 13C10.4295 13.5741 10.9774 14.0491 11.6066 14.3929C12.2357 14.7367 12.9315 14.9411 13.6467 14.9923C14.3618 15.0435 15.0796 14.9403 15.7513 14.6897C16.4231 14.4392 17.0331 14.047 17.54 13.54L20.54 10.54C21.4508 9.59695 21.9548 8.33394 21.9434 7.02296C21.932 5.71198 21.4061 4.45791 20.4791 3.53087C19.5521 2.60383 18.298 2.07799 16.987 2.0666C15.676 2.0552 14.413 2.55918 13.47 3.46997L11.75 5.17997M14 11C13.5705 10.4258 13.0226 9.95078 12.3934 9.60703C11.7642 9.26327 11.0685 9.05885 10.3533 9.00763C9.63819 8.95641 8.92037 9.0596 8.24861 9.31018C7.57685 9.56077 6.96685 9.9529 6.45996 10.46L3.45996 13.46C2.54917 14.403 2.04519 15.666 2.05659 16.977C2.06798 18.288 2.59382 19.542 3.52086 20.4691C4.44791 21.3961 5.70197 21.9219 7.01295 21.9333C8.32393 21.9447 9.58694 21.4408 10.53 20.53L12.24 18.82" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="kb-action-content">
|
||||
@@ -127,8 +138,16 @@
|
||||
type="file"
|
||||
class="kb-upload-input"
|
||||
accept=".pdf,.docx,.doc,.txt,.md,.jpg,.jpeg,.png"
|
||||
multiple
|
||||
@change="handleDocFileChange"
|
||||
/>
|
||||
<input
|
||||
ref="docFolderInput"
|
||||
type="file"
|
||||
class="kb-upload-input"
|
||||
webkitdirectory
|
||||
@change="handleDocFolderChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -232,6 +251,7 @@ const bottomMenuItems = computed<MenuItem[]>(() => {
|
||||
const currentKbName = ref<string>('')
|
||||
const currentKbInfo = ref<any>(null)
|
||||
const docUploadInput = ref<HTMLInputElement | null>(null)
|
||||
const docFolderInput = ref<HTMLInputElement | null>(null)
|
||||
const pendingUploadKbId = ref<string | null>(null)
|
||||
|
||||
const showKbActions = computed(() => (isInKnowledgeBase.value && !!currentKbInfo.value) || isInKnowledgeBaseList.value)
|
||||
@@ -596,39 +616,236 @@ const handleDocUploadClick = async () => {
|
||||
|
||||
const handleDocFileChange = async (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input?.files?.[0]
|
||||
if (!file) {
|
||||
pendingUploadKbId.value = null
|
||||
return
|
||||
}
|
||||
if (kbFileTypeVerification(file)) {
|
||||
input.value = ''
|
||||
const files = input?.files
|
||||
if (!files || files.length === 0) {
|
||||
pendingUploadKbId.value = null
|
||||
return
|
||||
}
|
||||
|
||||
const kbId = pendingUploadKbId.value || (await ensureDocKnowledgeBaseReady())
|
||||
pendingUploadKbId.value = null
|
||||
if (!kbId) {
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
try {
|
||||
await uploadKnowledgeFile(kbId, { file })
|
||||
|
||||
// 过滤有效文件
|
||||
const validFiles: File[] = []
|
||||
let invalidCount = 0
|
||||
const isSingleFile = files.length === 1
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i]
|
||||
// 单文件时显示错误,多文件时静默过滤
|
||||
if (kbFileTypeVerification(file, !isSingleFile)) {
|
||||
invalidCount++
|
||||
} else {
|
||||
validFiles.push(file)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有有效文件,多文件时显示汇总提示
|
||||
if (validFiles.length === 0) {
|
||||
if (!isSingleFile && invalidCount > 0) {
|
||||
MessagePlugin.error(t('knowledgeBase.noValidFilesSelected'))
|
||||
}
|
||||
// 单文件的错误已经在 kbFileTypeVerification 中显示了
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
// 批量上传
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
const totalCount = validFiles.length
|
||||
const failedFiles: Array<{ name: string; reason: string }> = []
|
||||
|
||||
// 显示上传提示
|
||||
if (totalCount > 1) {
|
||||
if (invalidCount > 0) {
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingValidFiles', {
|
||||
valid: totalCount,
|
||||
total: files.length
|
||||
}))
|
||||
} else {
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingMultiple', { total: totalCount }))
|
||||
}
|
||||
}
|
||||
|
||||
for (const file of validFiles) {
|
||||
try {
|
||||
await uploadKnowledgeFile(kbId, { file })
|
||||
successCount++
|
||||
} catch (error: any) {
|
||||
failCount++
|
||||
let errorReason = error?.error?.message || error?.message || t('knowledgeBase.uploadFailed')
|
||||
if (error?.code === 'duplicate_file' || error?.error?.code === 'duplicate_file') {
|
||||
errorReason = t('knowledgeBase.fileExists')
|
||||
}
|
||||
|
||||
// 只在单文件上传时显示详细错误
|
||||
if (totalCount === 1) {
|
||||
MessagePlugin.error(errorReason)
|
||||
} else {
|
||||
// 多文件上传时记录失败信息
|
||||
failedFiles.push({ name: file.name, reason: errorReason })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示上传结果
|
||||
if (successCount > 0) {
|
||||
window.dispatchEvent(new CustomEvent('knowledgeFileUploaded', {
|
||||
detail: { kbId }
|
||||
}))
|
||||
MessagePlugin.success(t('knowledgeBase.uploadSuccess'))
|
||||
} catch (error: any) {
|
||||
let errorMessage = error?.error?.message || error?.message || t('knowledgeBase.uploadFailed')
|
||||
if (error?.code === 'duplicate_file' || error?.error?.code === 'duplicate_file') {
|
||||
errorMessage = t('knowledgeBase.fileExists')
|
||||
}
|
||||
|
||||
if (totalCount === 1) {
|
||||
if (successCount === 1) {
|
||||
MessagePlugin.success(t('knowledgeBase.uploadSuccess'))
|
||||
}
|
||||
MessagePlugin.error(errorMessage)
|
||||
} finally {
|
||||
if (input) {
|
||||
input.value = ''
|
||||
// 单文件失败时已经在上面显示了详细错误
|
||||
} else {
|
||||
if (failCount === 0) {
|
||||
MessagePlugin.success(t('knowledgeBase.uploadAllSuccess', { count: successCount }))
|
||||
} else if (successCount > 0) {
|
||||
// 部分成功,显示详细失败信息
|
||||
const failedList = failedFiles.map(f => `• ${f.name}: ${f.reason}`).join('\n')
|
||||
MessagePlugin.warning({
|
||||
content: t('knowledgeBase.uploadPartialSuccess', {
|
||||
success: successCount,
|
||||
fail: failCount
|
||||
}) + '\n\n' + t('knowledgeBase.failedFilesList') + '\n' + failedList,
|
||||
duration: 8000,
|
||||
closeBtn: true
|
||||
})
|
||||
} else {
|
||||
// 全部失败,显示详细失败信息
|
||||
const failedList = failedFiles.slice(0, 5).map(f => `• ${f.name}: ${f.reason}`).join('\n')
|
||||
const moreCount = failedFiles.length > 5 ? failedFiles.length - 5 : 0
|
||||
MessagePlugin.error({
|
||||
content: t('knowledgeBase.uploadAllFailed') + '\n\n' +
|
||||
t('knowledgeBase.failedFilesList') + '\n' + failedList +
|
||||
(moreCount > 0 ? `\n${t('knowledgeBase.andMoreFiles', { count: moreCount })}` : ''),
|
||||
duration: 8000,
|
||||
closeBtn: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
input.value = ''
|
||||
}
|
||||
|
||||
const handleDocFolderUploadClick = async () => {
|
||||
const kbId = await ensureDocKnowledgeBaseReady()
|
||||
if (!kbId) return
|
||||
pendingUploadKbId.value = kbId
|
||||
docFolderInput.value?.click()
|
||||
}
|
||||
|
||||
const handleDocFolderChange = async (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const files = input?.files
|
||||
if (!files || files.length === 0) {
|
||||
pendingUploadKbId.value = null
|
||||
return
|
||||
}
|
||||
|
||||
const kbId = pendingUploadKbId.value || (await ensureDocKnowledgeBaseReady())
|
||||
pendingUploadKbId.value = null
|
||||
if (!kbId) {
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
// 过滤有效文件(文件夹上传始终使用静默模式)
|
||||
const validFiles: File[] = []
|
||||
let invalidCount = 0
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i]
|
||||
// 文件夹上传时始终静默过滤
|
||||
if (kbFileTypeVerification(file, true)) {
|
||||
invalidCount++
|
||||
} else {
|
||||
validFiles.push(file)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有有效文件,直接返回
|
||||
if (validFiles.length === 0) {
|
||||
if (invalidCount > 0) {
|
||||
MessagePlugin.error(t('knowledgeBase.noValidFilesInFolder', { total: files.length }))
|
||||
} else {
|
||||
MessagePlugin.error(t('knowledgeBase.noValidFiles'))
|
||||
}
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
// 显示过滤后的上传提示
|
||||
const totalCount = validFiles.length
|
||||
if (invalidCount > 0) {
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingValidFiles', {
|
||||
valid: totalCount,
|
||||
total: files.length
|
||||
}))
|
||||
} else {
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingFolder', { total: totalCount }))
|
||||
}
|
||||
|
||||
// 批量上传文件夹内容
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
const failedFiles: Array<{ name: string; reason: string }> = []
|
||||
|
||||
for (const file of validFiles) {
|
||||
try {
|
||||
await uploadKnowledgeFile(kbId, { file })
|
||||
successCount++
|
||||
} catch (error: any) {
|
||||
failCount++
|
||||
let errorReason = error?.error?.message || error?.message || t('knowledgeBase.uploadFailed')
|
||||
if (error?.code === 'duplicate_file' || error?.error?.code === 'duplicate_file') {
|
||||
errorReason = t('knowledgeBase.fileExists')
|
||||
}
|
||||
failedFiles.push({ name: file.name, reason: errorReason })
|
||||
}
|
||||
}
|
||||
|
||||
if (successCount > 0) {
|
||||
window.dispatchEvent(new CustomEvent('knowledgeFileUploaded', {
|
||||
detail: { kbId }
|
||||
}))
|
||||
}
|
||||
|
||||
if (failCount === 0) {
|
||||
MessagePlugin.success(t('knowledgeBase.uploadAllSuccess', { count: successCount }))
|
||||
} else if (successCount > 0) {
|
||||
// 部分成功,显示详细失败信息
|
||||
const failedList = failedFiles.map(f => `• ${f.name}: ${f.reason}`).join('\n')
|
||||
MessagePlugin.warning({
|
||||
content: t('knowledgeBase.uploadPartialSuccess', {
|
||||
success: successCount,
|
||||
fail: failCount
|
||||
}) + '\n\n' + t('knowledgeBase.failedFilesList') + '\n' + failedList,
|
||||
duration: 8000,
|
||||
closeBtn: true
|
||||
})
|
||||
} else {
|
||||
// 全部失败,显示详细失败信息
|
||||
const failedList = failedFiles.slice(0, 5).map(f => `• ${f.name}: ${f.reason}`).join('\n')
|
||||
const moreCount = failedFiles.length > 5 ? failedFiles.length - 5 : 0
|
||||
MessagePlugin.error({
|
||||
content: t('knowledgeBase.uploadAllFailed') + '\n\n' +
|
||||
t('knowledgeBase.failedFilesList') + '\n' + failedList +
|
||||
(moreCount > 0 ? `\n${t('knowledgeBase.andMoreFiles', { count: moreCount })}` : ''),
|
||||
duration: 8000,
|
||||
closeBtn: true
|
||||
})
|
||||
}
|
||||
|
||||
input.value = ''
|
||||
}
|
||||
|
||||
const handleDocManualCreate = async () => {
|
||||
@@ -739,19 +956,18 @@ const handleCreateKnowledgeBase = () => {
|
||||
|
||||
.kb-action-wrapper {
|
||||
border: 1px solid #e7e9eb;
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
margin-bottom: 12px;
|
||||
background: #fafcfc;
|
||||
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
|
||||
}
|
||||
|
||||
.kb-action-label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #8b9196;
|
||||
margin-bottom: 8px;
|
||||
padding: 0 6px;
|
||||
margin-bottom: 6px;
|
||||
padding: 0 4px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
@@ -759,29 +975,26 @@ const handleCreateKnowledgeBase = () => {
|
||||
.kb-action-menu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.kb-action-item {
|
||||
background: #fff;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #eef1f2;
|
||||
transition: all 0.12s ease;
|
||||
transition: background-color 0.08s ease, border-color 0.08s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #f0fdf6;
|
||||
border-color: #10b981;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 6px rgba(16, 185, 129, 0.08);
|
||||
|
||||
.kb-action-icon {
|
||||
color: #059669;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.kb-action-title {
|
||||
@@ -790,26 +1003,25 @@ const handleCreateKnowledgeBase = () => {
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 1px 3px rgba(16, 185, 129, 0.1);
|
||||
background: #e6f9f0;
|
||||
}
|
||||
}
|
||||
|
||||
.kb-action-icon-wrapper {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 5px;
|
||||
background: #f0fdf6;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.12s ease;
|
||||
transition: background-color 0.08s ease;
|
||||
}
|
||||
|
||||
.kb-action-icon {
|
||||
color: #10b981;
|
||||
transition: all 0.12s ease;
|
||||
transition: color 0.08s ease;
|
||||
}
|
||||
|
||||
.kb-action-item:hover .kb-action-icon-wrapper {
|
||||
@@ -825,7 +1037,7 @@ const handleCreateKnowledgeBase = () => {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #0f172a;
|
||||
transition: color 0.12s ease;
|
||||
transition: color 0.08s ease;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@@ -50,6 +50,18 @@ export default {
|
||||
uploadFailed: 'File upload failed!',
|
||||
docActionUnsupported: 'This knowledge base type does not support this action',
|
||||
fileExists: 'File already exists',
|
||||
uploadingMultiple: 'Uploading {total} files...',
|
||||
uploadAllSuccess: 'Successfully uploaded {count} files!',
|
||||
uploadPartialSuccess: 'Upload completed: {success} succeeded, {fail} failed',
|
||||
uploadAllFailed: 'All files failed to upload',
|
||||
uploadingFolder: 'Uploading {total} files from folder...',
|
||||
uploadingValidFiles: 'Uploading {valid}/{total} valid files...',
|
||||
noValidFiles: 'No valid files',
|
||||
noValidFilesInFolder: 'All {total} files in folder are unsupported',
|
||||
noValidFilesSelected: 'All selected files are unsupported',
|
||||
unsupportedFileType: 'Unsupported file type',
|
||||
failedFilesList: 'Failed files:',
|
||||
andMoreFiles: '...and {count} more files',
|
||||
uploadFile: 'Upload File',
|
||||
uploadFileDesc: 'Supports PDF, Word, TXT, etc.',
|
||||
importURL: 'Import from URL',
|
||||
@@ -1309,6 +1321,8 @@ export default {
|
||||
downloadCompleted: '{name} downloaded successfully',
|
||||
downloadFailed: 'Failed to download {name}',
|
||||
downloadStartFailed: 'Failed to start download',
|
||||
ollamaUnavailable: 'Ollama service is unavailable, local models cannot be selected',
|
||||
goToOllamaSettings: 'Open Settings',
|
||||
validation: {
|
||||
modelNameRequired: 'Please enter the model name',
|
||||
modelNameEmpty: 'Model name cannot be empty',
|
||||
@@ -1366,6 +1380,7 @@ export default {
|
||||
},
|
||||
upload: {
|
||||
uploadDocument: 'Upload Document',
|
||||
uploadFolder: 'Upload Folder',
|
||||
onlineEdit: 'Online Edit',
|
||||
deleteRecord: 'Delete Record'
|
||||
},
|
||||
|
||||
@@ -50,6 +50,18 @@ export default {
|
||||
uploadFailed: 'Ошибка загрузки файла!',
|
||||
docActionUnsupported: 'Этот тип базы знаний не поддерживает данную операцию',
|
||||
fileExists: 'Файл уже существует',
|
||||
uploadingMultiple: 'Загрузка {total} файлов...',
|
||||
uploadAllSuccess: 'Успешно загружено {count} файлов!',
|
||||
uploadPartialSuccess: 'Загрузка завершена: успешно {success}, ошибка {fail}',
|
||||
uploadAllFailed: 'Все файлы не удалось загрузить',
|
||||
uploadingFolder: 'Загрузка {total} файлов из папки...',
|
||||
uploadingValidFiles: 'Загрузка {valid}/{total} действительных файлов...',
|
||||
noValidFiles: 'Нет действительных файлов',
|
||||
noValidFilesInFolder: 'Все {total} файлов в папке не поддерживаются',
|
||||
noValidFilesSelected: 'Все выбранные файлы не поддерживаются',
|
||||
unsupportedFileType: 'Неподдерживаемый тип файла',
|
||||
failedFilesList: 'Неудавшиеся файлы:',
|
||||
andMoreFiles: '...и ещё {count} файлов',
|
||||
uploadFile: 'Загрузить файл',
|
||||
uploadFileDesc: 'Поддерживает PDF, Word, TXT и т.д.',
|
||||
importURL: 'Импорт из URL',
|
||||
@@ -785,6 +797,8 @@ export default {
|
||||
downloadCompleted: '{name} успешно загружена',
|
||||
downloadFailed: 'Не удалось загрузить {name}',
|
||||
downloadStartFailed: 'Не удалось запустить загрузку',
|
||||
ollamaUnavailable: 'Сервис Ollama недоступен, локальные модели недоступны для выбора',
|
||||
goToOllamaSettings: 'Открыть настройки',
|
||||
validation: {
|
||||
modelNameRequired: 'Введите название модели',
|
||||
modelNameEmpty: 'Название модели не может быть пустым',
|
||||
@@ -1201,6 +1215,7 @@ export default {
|
||||
},
|
||||
upload: {
|
||||
uploadDocument: 'Загрузить документ',
|
||||
uploadFolder: 'Загрузить папку',
|
||||
onlineEdit: 'Онлайн редактирование',
|
||||
deleteRecord: 'Удалить запись'
|
||||
},
|
||||
|
||||
@@ -49,6 +49,18 @@ export default {
|
||||
uploadSuccess: "文件上传成功!",
|
||||
uploadFailed: "文件上传失败!",
|
||||
fileExists: "文件已存在",
|
||||
uploadingMultiple: "正在上传 {total} 个文件...",
|
||||
uploadAllSuccess: "成功上传 {count} 个文件!",
|
||||
uploadPartialSuccess: "上传完成:成功 {success} 个,失败 {fail} 个",
|
||||
uploadAllFailed: "所有文件上传失败",
|
||||
uploadingFolder: "正在上传文件夹中的 {total} 个文件...",
|
||||
uploadingValidFiles: "正在上传 {valid}/{total} 个有效文件...",
|
||||
noValidFiles: "没有有效的文件",
|
||||
noValidFilesInFolder: "文件夹中的 {total} 个文件均不支持",
|
||||
noValidFilesSelected: "选中的文件均不支持",
|
||||
unsupportedFileType: "不支持的文件格式",
|
||||
failedFilesList: "失败文件列表:",
|
||||
andMoreFiles: "...及其他 {count} 个文件",
|
||||
uploadFile: "上传文件",
|
||||
uploadFileDesc: "支持 PDF、Word、TXT 等",
|
||||
importURL: "导入网页",
|
||||
@@ -877,6 +889,8 @@ export default {
|
||||
downloadCompleted: "{name} 下载完成",
|
||||
downloadFailed: "{name} 下载失败",
|
||||
downloadStartFailed: "启动下载失败",
|
||||
ollamaUnavailable: "Ollama服务不可用,无法选择本地模型",
|
||||
goToOllamaSettings: "查看设置",
|
||||
validation: {
|
||||
modelNameRequired: "请输入模型名称",
|
||||
modelNameEmpty: "模型名称不能为空",
|
||||
@@ -934,6 +948,7 @@ export default {
|
||||
},
|
||||
upload: {
|
||||
uploadDocument: "上传文档",
|
||||
uploadFolder: "上传文件夹",
|
||||
onlineEdit: "在线编辑",
|
||||
deleteRecord: "删除记录",
|
||||
},
|
||||
|
||||
@@ -22,22 +22,28 @@ export function formatStringDate(date: any) {
|
||||
year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
|
||||
);
|
||||
}
|
||||
export function kbFileTypeVerification(file: any) {
|
||||
export function kbFileTypeVerification(file: any, silent = false) {
|
||||
let validTypes = ["pdf", "txt", "md", "docx", "doc", "jpg", "jpeg", "png", "csv", "xlsx", "xls"];
|
||||
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||
if (!validTypes.includes(type)) {
|
||||
MessagePlugin.error("文件类型错误!");
|
||||
if (!silent) {
|
||||
MessagePlugin.error("文件类型错误!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
(type == "pdf" || type == "docx" || type == "doc") &&
|
||||
file.size > 31457280
|
||||
) {
|
||||
MessagePlugin.error("pdf/doc文件不能超过30M!");
|
||||
if (!silent) {
|
||||
MessagePlugin.error("pdf/doc文件不能超过30M!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ((type == "txt" || type == "md") && file.size > 31457280) {
|
||||
MessagePlugin.error("txt/md文件不能超过30M!");
|
||||
if (!silent) {
|
||||
MessagePlugin.error("txt/md文件不能超过30M!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -564,20 +564,20 @@ onMounted(() => {
|
||||
.section-description {
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
margin: 0;
|
||||
margin: 0 0 20px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.model-category-section {
|
||||
margin-bottom: 24px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
padding: 24px;
|
||||
background: #ffffff;
|
||||
margin-bottom: 32px;
|
||||
padding-bottom: 32px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,20 +585,20 @@ onMounted(() => {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.header-info {
|
||||
flex: 1;
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #666666;
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
@@ -612,72 +612,65 @@ onMounted(() => {
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
|
||||
height: 32px;
|
||||
padding: 0 16px;
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.add-icon {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.model-list-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 12px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.model-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 12px;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
background: #fafafa;
|
||||
transition: all 0.2s;
|
||||
transition: all 0.15s ease;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
|
||||
&:hover {
|
||||
border-color: #07C05F;
|
||||
background: #ffffff;
|
||||
background: #f9fdfb;
|
||||
box-shadow: 0 1px 4px rgba(7, 192, 95, 0.08);
|
||||
}
|
||||
|
||||
// 内置模型置灰样式
|
||||
// 内置模型样式
|
||||
&.builtin-model {
|
||||
opacity: 0.7;
|
||||
background: #f5f5f5;
|
||||
background: #f8f9fa;
|
||||
border-color: #d9d9d9;
|
||||
cursor: not-allowed;
|
||||
|
||||
&:hover {
|
||||
border-color: #d9d9d9;
|
||||
background: #f5f5f5;
|
||||
opacity: 0.8;
|
||||
border-color: #c0c0c0;
|
||||
background: #f5f6f7;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.model-info {
|
||||
.model-name {
|
||||
color: #999999;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.model-meta {
|
||||
color: #999999;
|
||||
|
||||
.source-tag {
|
||||
background: #e5e5e5;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.model-actions {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +682,7 @@ onMounted(() => {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
margin-bottom: 4px;
|
||||
margin-bottom: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
@@ -698,15 +691,16 @@ onMounted(() => {
|
||||
.model-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 12px;
|
||||
font-size: 12px;
|
||||
color: #666666;
|
||||
|
||||
.source-tag {
|
||||
padding: 1px 6px;
|
||||
padding: 2px 8px;
|
||||
background: #e5e7eb;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.model-id {
|
||||
@@ -726,14 +720,14 @@ onMounted(() => {
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
transition: opacity 0.15s ease;
|
||||
position: relative;
|
||||
z-index: 1001; // 确保高于设置窗口的z-index (9999)
|
||||
z-index: 1001;
|
||||
|
||||
.more-btn {
|
||||
color: #666666;
|
||||
color: #999999;
|
||||
padding: 4px;
|
||||
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
color: #333333;
|
||||
@@ -746,25 +740,25 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 80px 0;
|
||||
padding: 48px 0;
|
||||
text-align: center;
|
||||
|
||||
.empty-text {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #999999;
|
||||
margin: 0 0 16px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.builtin-models-info {
|
||||
margin-top: 20px;
|
||||
margin-top: 16px;
|
||||
|
||||
.info-box {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e5e7eb;
|
||||
background: #f0fdf6;
|
||||
border: 1px solid #d1fae5;
|
||||
border-left: 3px solid #07C05F;
|
||||
border-radius: 4px;
|
||||
padding: 12px 16px;
|
||||
border-radius: 6px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.info-header {
|
||||
@@ -776,42 +770,48 @@ onMounted(() => {
|
||||
.info-icon {
|
||||
font-size: 16px;
|
||||
color: #07C05F;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.info-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
.info-content {
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: #666666;
|
||||
color: #065f46;
|
||||
|
||||
p {
|
||||
margin: 0 0 8px 0;
|
||||
margin: 0 0 6px 0;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&.doc-link {
|
||||
margin-top: 8px;
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
.link-icon {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #07C05F;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #07C05F;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s;
|
||||
transition: color 0.15s;
|
||||
|
||||
&:hover {
|
||||
color: #06b04d;
|
||||
color: #059669;
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
@@ -819,4 +819,111 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TDesign 组件样式覆盖
|
||||
:deep(.t-button) {
|
||||
&.add-model-btn {
|
||||
border-radius: 6px;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: #06b04d;
|
||||
border-color: #06b04d;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #059642;
|
||||
border-color: #059642;
|
||||
}
|
||||
}
|
||||
|
||||
&.t-size-s {
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
|
||||
&.t-button--variant-outline {
|
||||
color: #666666;
|
||||
border-color: #d9d9d9;
|
||||
|
||||
&:hover {
|
||||
color: #07C05F;
|
||||
border-color: #07C05F;
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tag 样式优化
|
||||
:deep(.t-tag) {
|
||||
border-radius: 3px;
|
||||
padding: 2px 8px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
|
||||
&.t-tag--theme-primary {
|
||||
background: #e0f2fe;
|
||||
color: #0369a1;
|
||||
}
|
||||
|
||||
&.t-tag--theme-success {
|
||||
background: #dcfce7;
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
&.t-size-s {
|
||||
height: 20px;
|
||||
line-height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
// Dropdown 菜单样式优化
|
||||
:deep(.t-popup__content) {
|
||||
.t-dropdown__menu {
|
||||
background: #ffffff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
|
||||
padding: 4px;
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
.t-dropdown__item {
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
margin: 2px 0;
|
||||
font-size: 13px;
|
||||
color: #333333;
|
||||
transition: all 0.15s ease;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
color: #07C05F;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #e8f5ed;
|
||||
}
|
||||
|
||||
// 删除按钮特殊样式 - 覆盖默认 hover 样式
|
||||
&.t-dropdown__item--theme-error {
|
||||
color: #f56c6c;
|
||||
|
||||
&:hover {
|
||||
background: #fef0f0;
|
||||
color: #e53e3e !important; // 使用 !important 确保覆盖默认样式
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #fde2e2;
|
||||
color: #c53030;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user