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:
wizardchen
2025-11-21 01:07:28 +08:00
parent 21649b62c7
commit c678094724
7 changed files with 704 additions and 181 deletions
+231 -78
View File
@@ -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>
+252 -40
View File
@@ -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;