feat(frontend): introduce KBSwitcherDropdown component for improved knowledge base selection

Added a new KBSwitcherDropdown component to enhance the user experience when selecting knowledge bases. This component displays a list of knowledge bases with the current selection highlighted, allowing users to easily switch between them. Integrated the dropdown into both KnowledgeBase.vue and FAQEntryManager.vue, replacing the previous dropdown implementation for a more streamlined and consistent UI. The new component supports dynamic updates and maintains the order of knowledge bases while ensuring the current selection is always visible at the top.
This commit is contained in:
wizardchen
2026-05-26 10:18:17 +08:00
committed by lyingbug
parent 257766545e
commit 91e4fe8b6b
3 changed files with 178 additions and 26 deletions
@@ -10,10 +10,13 @@
{{ $t('menu.knowledgeBase') }}
</button>
<t-icon name="chevron-right" class="breadcrumb-separator" />
<t-dropdown v-if="knowledgeDropdownOptions.length" :options="knowledgeDropdownOptions" trigger="click"
placement="bottom-left" @click="handleKnowledgeDropdownSelect">
<button type="button" class="breadcrumb-link dropdown" :disabled="!props.kbId"
@click.stop="handleNavigateToCurrentKB">
<KBSwitcherDropdown
v-if="knowledgeList.length"
:kb-list="knowledgeList"
:current-kb-id="props.kbId"
@select="(id) => handleKnowledgeDropdownSelect({ value: id })"
>
<button type="button" class="breadcrumb-link dropdown" :disabled="!props.kbId">
<template v-if="!kbInfo">
<t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '20px' }]" />
</template>
@@ -22,7 +25,7 @@
<t-icon name="chevron-down" />
</template>
</button>
</t-dropdown>
</KBSwitcherDropdown>
<button v-else type="button" class="breadcrumb-link" :disabled="!props.kbId"
@click="handleNavigateToCurrentKB">
<template v-if="!kbInfo">
@@ -944,6 +947,7 @@ import * as XLSX from 'xlsx'
import Papa from 'papaparse'
import FAQTagTooltip from '@/components/FAQTagTooltip.vue'
import KBInfoPopover from '@/components/KBInfoPopover.vue'
import KBSwitcherDropdown from '@/components/KBSwitcherDropdown.vue'
import { useUIStore } from '@/stores/ui'
interface FAQEntry {
@@ -1150,14 +1154,6 @@ const filteredTags = computed(() => {
const kbInfo = ref<any>(null)
const knowledgeList = ref<Array<{ id: string; name: string; type?: string }>>([])
const knowledgeDropdownOptions = computed(() =>
knowledgeList.value
.map((item) => ({
content: item.name,
value: item.id,
prefixIcon: () => h(TIcon, { name: item.type === 'document' ? 'folder' : 'chat-bubble-help', size: '16px' }),
})),
)
const loadKnowledgeInfo = async (kbId: string) => {
if (!kbId) {