feat: enhance storage engine configuration and user notifications
- Updated the summary length requirement for document summarization to 100-300 words. - Added new localization strings for missing storage engine notifications in English, Korean, Russian, and Chinese. - Implemented UI warnings for users regarding storage engine configuration when files exist, including confirmation dialogs for storage engine changes. - Enhanced backend validation to ensure a storage engine is configured before allowing content uploads. These changes improve user experience by providing clearer guidance on storage engine requirements and enhancing the overall functionality of the knowledge base management system.
This commit is contained in:
@@ -43,6 +43,11 @@ const folderUploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
const uploading = ref(false);
|
||||
const kbLoading = ref(false);
|
||||
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
|
||||
const missingStorageEngine = computed(() => {
|
||||
if (!kbInfo.value || isFAQ.value) return false
|
||||
const spc = kbInfo.value.storage_provider_config
|
||||
return !spc || !spc.provider
|
||||
})
|
||||
const parserEngines = ref<ParserEngineInfo[]>([]);
|
||||
|
||||
const supportedFileTypes = computed<Set<string>>(() => {
|
||||
@@ -947,6 +952,10 @@ const ensureDocumentKbReady = () => {
|
||||
MessagePlugin.warning(t('knowledgeBase.notInitialized'));
|
||||
return false;
|
||||
}
|
||||
if (missingStorageEngine.value) {
|
||||
MessagePlugin.warning(t('knowledgeBase.missingStorageEngineUpload'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -1459,6 +1468,11 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<span>{{ $t('knowledgeBase.unsupportedTypesHint', { types: unsupportedFileTypes.map(t => '.' + t).join('、') }) }}</span>
|
||||
<span class="parser-hint-link">{{ $t('knowledgeBase.goToParserSettings') }} →</span>
|
||||
</p>
|
||||
<div v-if="missingStorageEngine" class="storage-engine-warning" @click="handleOpenKBSettings">
|
||||
<t-icon name="error-circle" class="warning-icon" />
|
||||
<span>{{ $t('knowledgeBase.missingStorageEngine') }}</span>
|
||||
<span class="warning-link">{{ $t('knowledgeBase.goToStorageSettings') }} →</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2714,6 +2728,41 @@ async function createNewSession(value: string): Promise<void> {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.storage-engine-warning {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 8px 0 0;
|
||||
padding: 8px 12px;
|
||||
background: var(--td-warning-color-1, #fff8e6);
|
||||
border: 1px solid var(--td-warning-color-3, #ffcc33);
|
||||
border-radius: 6px;
|
||||
color: var(--td-warning-color);
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-warning-color-2, #fff1c9);
|
||||
|
||||
.warning-link {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
.warning-icon {
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.warning-link {
|
||||
color: var(--td-brand-color);
|
||||
margin-left: 2px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
|
||||
import { createKnowledgeBase, getKnowledgeBaseById, listKnowledgeFiles, updateKnowledgeBase } from '@/api/knowledge-base'
|
||||
import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
|
||||
import { listModels } from '@/api/model'
|
||||
@@ -229,6 +229,7 @@ const saving = ref(false)
|
||||
const loading = ref(false)
|
||||
const allModels = ref<any[]>([])
|
||||
const hasFiles = ref(false)
|
||||
const initialStorageProvider = ref<string>('')
|
||||
|
||||
const navItems = computed(() => {
|
||||
const items = [
|
||||
@@ -401,6 +402,7 @@ const loadKBData = async () => {
|
||||
questionCount: kb.question_generation_config?.question_count || 3
|
||||
},
|
||||
}
|
||||
initialStorageProvider.value = formData.value.storageProvider
|
||||
} catch (error) {
|
||||
console.error('Failed to load knowledge base data:', error)
|
||||
MessagePlugin.error(t('knowledgeEditor.messages.loadDataFailed'))
|
||||
@@ -568,6 +570,34 @@ const handleSubmit = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
// 编辑模式下,若已有文件且存储引擎发生了变化,弹窗确认
|
||||
if (
|
||||
props.mode === 'edit' &&
|
||||
hasFiles.value &&
|
||||
formData.value &&
|
||||
initialStorageProvider.value &&
|
||||
formData.value.storageProvider !== initialStorageProvider.value
|
||||
) {
|
||||
const dialog = DialogPlugin.confirm({
|
||||
header: t('common.confirm'),
|
||||
body: t('knowledgeEditor.messages.storageChangeConfirm'),
|
||||
confirmBtn: t('common.confirm'),
|
||||
cancelBtn: t('common.cancel'),
|
||||
onConfirm: () => {
|
||||
dialog.destroy()
|
||||
doSubmit()
|
||||
},
|
||||
onCancel: () => {
|
||||
dialog.destroy()
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
doSubmit()
|
||||
}
|
||||
|
||||
const doSubmit = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
const data = buildSubmitData()
|
||||
@@ -653,6 +683,7 @@ const resetState = () => {
|
||||
currentSection.value = 'basic'
|
||||
formData.value = null
|
||||
hasFiles.value = false
|
||||
initialStorageProvider.value = ''
|
||||
saving.value = false
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
size="medium"
|
||||
:placeholder="$t('kbSettings.storage.selectPlaceholder')"
|
||||
style="width: 100%; min-width: 220px;"
|
||||
:disabled="props.hasFiles"
|
||||
@change="handleChange"
|
||||
>
|
||||
<t-option
|
||||
@@ -41,7 +40,7 @@
|
||||
</span>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<p v-if="props.hasFiles" class="option-hint locked-hint">{{ $t('kbSettings.storage.lockedHint') }}</p>
|
||||
<p v-if="props.hasFiles" class="option-hint change-warning">{{ $t('kbSettings.storage.changeWarning') }}</p>
|
||||
<p v-else-if="selectedOption?.desc" class="option-hint">{{ selectedOption.desc }}</p>
|
||||
<a v-if="showGoSettings" href="javascript:void(0)" class="go-settings" @click.prevent="goToStorageSettings">{{ $t('kbSettings.storage.goGlobalSettings') }}</a>
|
||||
</div>
|
||||
@@ -253,6 +252,10 @@ onMounted(load)
|
||||
&.locked-hint {
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
|
||||
&.change-warning {
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
}
|
||||
|
||||
.go-settings {
|
||||
|
||||
Reference in New Issue
Block a user