feat(contextualGuides): add multiple contextual guide components for agent and knowledge base creation
- Introduced new components: AgentCreateContextualGuide, KbCreateContextualGuide, TenantModelsGuide, and SpotlightGuide to enhance user onboarding. - Implemented dynamic step configurations for each guide, allowing tailored user experiences based on context. - Enhanced the existing NewUserGuide component to utilize the new SpotlightGuide for improved visual guidance. - Updated localization files to include new strings for contextual guides, ensuring a comprehensive user experience across languages. - Refactored existing components to integrate with the new guide system, improving maintainability and user interaction.
This commit is contained in:
@@ -16,11 +16,12 @@
|
||||
<div class="sidebar-header">
|
||||
<h2 class="sidebar-title">{{ mode === 'create' ? $t('knowledgeEditor.titleCreate') : $t('knowledgeEditor.titleEdit') }}</h2>
|
||||
</div>
|
||||
<div class="settings-nav">
|
||||
<div class="settings-nav" data-guide="kb-editor-sidebar">
|
||||
<div
|
||||
v-for="(item, index) in navItems"
|
||||
:key="index"
|
||||
:class="['nav-item', { 'active': currentSection === item.key }]"
|
||||
:data-guide="`kb-editor-nav-${item.key}`"
|
||||
@click="currentSection = item.key"
|
||||
>
|
||||
<t-icon :name="item.icon" class="nav-icon" />
|
||||
@@ -60,6 +61,7 @@
|
||||
<t-radio-group
|
||||
v-model="formData.type"
|
||||
:disabled="mode === 'edit'"
|
||||
data-guide="kb-create-type"
|
||||
>
|
||||
<t-radio-button value="document">{{ $t('knowledgeEditor.basic.typeDocument') }}</t-radio-button>
|
||||
<t-radio-button value="faq">{{ $t('knowledgeEditor.basic.typeFAQ') }}</t-radio-button>
|
||||
@@ -71,7 +73,8 @@
|
||||
<div v-if="!isFAQ" class="form-item">
|
||||
<label class="form-label required">{{ $t('knowledgeEditor.indexing.title') }}</label>
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.indexing.description') }}</p>
|
||||
<div class="indexing-checks" :class="{ 'is-locked': isIndexingLocked }">
|
||||
<div class="indexing-checks" :class="{ 'is-locked': isIndexingLocked }"
|
||||
data-guide="kb-create-indexing">
|
||||
<div
|
||||
class="indexing-check-item"
|
||||
:class="{ 'is-checked': formData.indexingStrategy.vectorEnabled, 'is-disabled': isIndexingLocked }"
|
||||
@@ -129,7 +132,7 @@
|
||||
<p class="form-tip granularity-hint">{{ granularityHint }}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-item">
|
||||
<div class="form-item" data-guide="kb-create-name">
|
||||
<label class="form-label required">{{ $t('knowledgeEditor.basic.nameLabel') }}</label>
|
||||
<t-input
|
||||
v-model="formData.name"
|
||||
@@ -251,7 +254,7 @@
|
||||
|
||||
<div class="settings-group">
|
||||
<!-- 多模态开关 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-row" data-guide="kb-create-multimodal-toggle">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.label') }}</label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.description') }}</p>
|
||||
@@ -266,7 +269,8 @@
|
||||
</div>
|
||||
|
||||
<!-- VLLM 模型选择(多模态启用时) -->
|
||||
<div v-if="formData.multimodalConfig.enabled" class="setting-row">
|
||||
<div v-if="formData.multimodalConfig.enabled" class="setting-row"
|
||||
data-guide="kb-create-multimodal-vllm">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.vllmLabel') }} <span class="required">*</span></label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.vllmDescription') }}</p>
|
||||
@@ -369,7 +373,7 @@
|
||||
<t-button theme="default" variant="outline" @click="handleClose">
|
||||
{{ $t('common.cancel') }}
|
||||
</t-button>
|
||||
<t-button theme="primary" @click="handleSubmit" :loading="saving">
|
||||
<t-button theme="primary" data-guide="kb-create-submit" @click="handleSubmit" :loading="saving">
|
||||
{{ mode === 'create' ? $t('knowledgeEditor.buttons.create') : $t('knowledgeEditor.buttons.save') }}
|
||||
</t-button>
|
||||
</div>
|
||||
@@ -379,14 +383,19 @@
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
|
||||
<KbCreateContextualGuide :when="visible && mode === 'create'" :is-faq="isFAQ"
|
||||
:needs-embedding="kbCreateNeedsEmbedding" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { ref, computed, watch, onMounted, onBeforeUnmount } from 'vue'
|
||||
import KbCreateContextualGuide from '@/components/KbCreateContextualGuide.vue'
|
||||
import { KB_EDITOR_FOCUS_SECTION_EVENT, markContextualGuideDone } from '@/config/contextualGuides'
|
||||
import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
|
||||
import { createKnowledgeBase, getKnowledgeBaseById, listKnowledgeFiles, updateKnowledgeBase, rebuildKBIndex } from '@/api/knowledge-base'
|
||||
import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
|
||||
import { listModels } from '@/api/model'
|
||||
import { listModels, type ModelConfig } from '@/api/model'
|
||||
import { getStorageEngineConfig } from '@/api/system'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
@@ -445,6 +454,21 @@ const copyKbId = async () => {
|
||||
}
|
||||
|
||||
const currentSection = ref<string>('basic')
|
||||
|
||||
const onKbEditorFocusSection = (event: Event) => {
|
||||
const section = (event as CustomEvent<{ section?: string }>).detail?.section
|
||||
if (section) {
|
||||
currentSection.value = section
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener(KB_EDITOR_FOCUS_SECTION_EVENT, onKbEditorFocusSection)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener(KB_EDITOR_FOCUS_SECTION_EVENT, onKbEditorFocusSection)
|
||||
})
|
||||
const saving = ref(false)
|
||||
const loading = ref(false)
|
||||
const allModels = ref<any[]>([])
|
||||
@@ -530,6 +554,28 @@ const advancedSettingsRef = ref<InstanceType<typeof KBAdvancedSettings>>()
|
||||
const formData = ref<any>(null)
|
||||
const isFAQ = computed(() => formData.value?.type === 'faq')
|
||||
|
||||
const kbCreateNeedsEmbedding = computed(() => {
|
||||
if (!formData.value || formData.value.type === 'faq') return false
|
||||
const s = formData.value.indexingStrategy
|
||||
return Boolean(s?.vectorEnabled || s?.keywordEnabled)
|
||||
})
|
||||
|
||||
const applyDefaultModelsIfEmpty = () => {
|
||||
if (!formData.value || props.mode !== 'create') return
|
||||
const pick = (type: ModelConfig['type']) => {
|
||||
const list = allModels.value.filter((m) => m.type === type)
|
||||
return list.find((m) => m.is_default) || list[0]
|
||||
}
|
||||
const chat = pick('KnowledgeQA')
|
||||
const embedding = pick('Embedding')
|
||||
if (!formData.value.modelConfig.llmModelId && chat?.id) {
|
||||
formData.value.modelConfig.llmModelId = chat.id
|
||||
}
|
||||
if (!formData.value.modelConfig.embeddingModelId && embedding?.id) {
|
||||
formData.value.modelConfig.embeddingModelId = embedding.id
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formData.value?.type,
|
||||
(newType, oldType) => {
|
||||
@@ -1133,6 +1179,7 @@ const doSubmit = async () => {
|
||||
throw new Error(result.message || t('knowledgeEditor.messages.createFailed'))
|
||||
}
|
||||
MessagePlugin.success(t('knowledgeEditor.messages.createSuccess'))
|
||||
markContextualGuideDone('kbCreate')
|
||||
emit('success', result.data.id)
|
||||
} else {
|
||||
// 编辑模式:分别更新基本信息和配置
|
||||
@@ -1316,6 +1363,7 @@ watch(() => props.visible, async (newVal) => {
|
||||
formData.value = initFormData(props.initialType || 'document')
|
||||
formData.value.storageProvider = tenantDefaultStorageProvider.value
|
||||
hasFiles.value = false
|
||||
applyDefaultModelsIfEmpty()
|
||||
}
|
||||
} else {
|
||||
// 关闭弹窗时,延迟重置状态(等待动画结束)
|
||||
|
||||
Reference in New Issue
Block a user