feat: Add tag management and FAQ management APIs, enhance knowledge base functionality with keyword search and custom file naming support
This commit is contained in:
@@ -95,8 +95,12 @@ export function getChunkByIdOnly(chunkId: string) {
|
||||
return get(`/api/v1/chunks/by-id/${chunkId}`);
|
||||
}
|
||||
|
||||
export function listKnowledgeTags(kbId: string) {
|
||||
return get(`/api/v1/knowledge-bases/${kbId}/tags`);
|
||||
export function listKnowledgeTags(
|
||||
kbId: string,
|
||||
params?: { page?: number; page_size?: number; keyword?: string },
|
||||
) {
|
||||
const query = buildQuery(params);
|
||||
return get(`/api/v1/knowledge-bases/${kbId}/tags${query}`);
|
||||
}
|
||||
|
||||
export function createKnowledgeBaseTag(
|
||||
@@ -138,7 +142,10 @@ const buildQuery = (params?: Record<string, any>) => {
|
||||
return queryString ? `?${queryString}` : '';
|
||||
};
|
||||
|
||||
export function listFAQEntries(kbId: string, params?: { page?: number; page_size?: number; tag_id?: string }) {
|
||||
export function listFAQEntries(
|
||||
kbId: string,
|
||||
params?: { page?: number; page_size?: number; tag_id?: string; keyword?: string },
|
||||
) {
|
||||
const query = buildQuery(params);
|
||||
return get(`/api/v1/knowledge-bases/${kbId}/faq/entries${query}`);
|
||||
}
|
||||
|
||||
@@ -1,66 +1,78 @@
|
||||
<template>
|
||||
<div class="tenant-selector">
|
||||
<div v-if="canAccessAllTenants" class="tenant-selector-wrapper">
|
||||
<div class="tenant-menu-item" @click="toggleDropdown" ref="triggerRef">
|
||||
<div class="tenant-item-box">
|
||||
<div class="tenant-icon">
|
||||
<t-icon name="usergroup" size="16px" />
|
||||
</div>
|
||||
<span class="tenant-title">{{ currentTenantName }}</span>
|
||||
<div class="tenant-selector" ref="selectorRef">
|
||||
<div class="tenant-trigger" @click="toggleDropdown">
|
||||
<div class="tenant-info">
|
||||
<div class="tenant-label">{{ $t('tenant.currentTenant') }}</div>
|
||||
<div class="tenant-name-row">
|
||||
<span class="tenant-name">{{ currentTenantName }}</span>
|
||||
<t-icon name="swap" class="tenant-switch-icon" />
|
||||
</div>
|
||||
<t-icon name="chevron-up" class="tenant-arrow" :class="{ rotated: showDropdown }" />
|
||||
</div>
|
||||
<div v-if="showDropdown" class="tenant-overlay" @click="close">
|
||||
<div class="tenant-dropdown" @click.stop :style="dropdownStyle">
|
||||
<div class="tenant-list" ref="tenantList">
|
||||
</div>
|
||||
|
||||
<Transition name="dropdown">
|
||||
<div v-if="showDropdown" class="tenant-dropdown" @click.stop>
|
||||
<div class="dropdown-header">
|
||||
<span class="dropdown-title">{{ $t('tenant.switchTenant') }}</span>
|
||||
<div class="search-box">
|
||||
<t-icon name="search" class="search-icon" />
|
||||
<input
|
||||
ref="searchInput"
|
||||
v-model="searchQuery"
|
||||
type="text"
|
||||
:placeholder="$t('tenant.searchPlaceholder')"
|
||||
class="search-input"
|
||||
@keydown.esc="closeDropdown"
|
||||
@input="handleSearchInput"
|
||||
/>
|
||||
<t-icon
|
||||
v-if="searchQuery"
|
||||
name="close-circle-filled"
|
||||
class="clear-icon"
|
||||
@click="clearSearch"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tenant-list" ref="tenantListRef" @scroll="handleScroll">
|
||||
<div v-if="loading && tenants.length === 0" class="tenant-loading">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('tenant.loading') }}</span>
|
||||
</div>
|
||||
|
||||
<template v-else-if="tenants.length > 0">
|
||||
<div
|
||||
v-for="tenant in tenants"
|
||||
:key="tenant.id"
|
||||
:class="['tenant-item', { selected: isSelected(tenant.id) }]"
|
||||
@click="selectTenant(tenant.id)"
|
||||
>
|
||||
<div class="tenant-item-info">
|
||||
<span class="tenant-item-name">{{ tenant.name }}</span>
|
||||
<span v-if="tenant.description" class="tenant-item-desc">{{ tenant.description }}</span>
|
||||
<span class="tenant-item-id">ID: {{ tenant.id }}</span>
|
||||
<div class="tenant-item-content">
|
||||
<div class="tenant-item-avatar" :class="{ active: isSelected(tenant.id) }">
|
||||
{{ tenant.name.charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<div class="tenant-item-info">
|
||||
<span class="tenant-item-name">{{ tenant.name }}</span>
|
||||
<span class="tenant-item-id">ID: {{ tenant.id }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<t-icon v-if="isSelected(tenant.id)" name="check" size="16px" class="tenant-check-icon" />
|
||||
</div>
|
||||
<div v-if="tenants.length === 0 && !loading" class="tenant-empty">
|
||||
{{ $t('tenant.noMatch') }}
|
||||
</div>
|
||||
<div v-if="loading" class="tenant-loading">
|
||||
{{ $t('tenant.loading') }}
|
||||
</div>
|
||||
<div v-if="hasMore && !loading" class="tenant-load-more" @click="loadMore">
|
||||
{{ $t('tenant.loadMore') }}
|
||||
<t-icon v-if="isSelected(tenant.id)" name="check" size="16px" class="check-icon" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-else class="tenant-empty">
|
||||
<span>{{ $t('tenant.noMatch') }}</span>
|
||||
</div>
|
||||
<div class="tenant-search">
|
||||
<input
|
||||
ref="searchInput"
|
||||
v-model="searchQuery"
|
||||
type="text"
|
||||
:placeholder="$t('tenant.searchPlaceholder')"
|
||||
class="tenant-search-input"
|
||||
@keydown.esc="closeDropdown"
|
||||
@input="handleSearchInput"
|
||||
/>
|
||||
<div class="tenant-search-hint">
|
||||
{{ $t('tenant.searchHint') }}
|
||||
</div>
|
||||
|
||||
<div v-if="loading && tenants.length > 0" class="tenant-loading-more">
|
||||
<t-loading size="small" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="tenant-menu-item readonly">
|
||||
<div class="tenant-item-box">
|
||||
<div class="tenant-icon">
|
||||
<t-icon name="usergroup" size="16px" />
|
||||
</div>
|
||||
<span class="tenant-title">{{ currentTenantName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<!-- 遮罩层 -->
|
||||
<div v-if="showDropdown" class="tenant-overlay" @click="closeDropdown"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -77,10 +89,9 @@ const authStore = useAuthStore()
|
||||
const showDropdown = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const tenants = ref<TenantInfo[]>([])
|
||||
const triggerRef = ref<HTMLElement | null>(null)
|
||||
const tenantList = ref<HTMLElement | null>(null)
|
||||
const selectorRef = ref<HTMLElement | null>(null)
|
||||
const tenantListRef = ref<HTMLElement | null>(null)
|
||||
const searchInput = ref<HTMLInputElement | null>(null)
|
||||
const dropdownStyle = ref<Record<string, string>>({})
|
||||
|
||||
// 分页相关
|
||||
const currentPage = ref(1)
|
||||
@@ -89,7 +100,6 @@ const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const searchTimer = ref<number | null>(null)
|
||||
|
||||
const canAccessAllTenants = computed(() => authStore.canAccessAllTenants)
|
||||
const selectedTenantId = computed(() => authStore.selectedTenantId)
|
||||
const defaultTenantId = computed(() => authStore.tenant?.id ? Number(authStore.tenant.id) : null)
|
||||
|
||||
@@ -112,48 +122,15 @@ const isSelected = (tenantId: number) => {
|
||||
return currentTenantId.value === tenantId
|
||||
}
|
||||
|
||||
const updateDropdownPosition = () => {
|
||||
if (!triggerRef.value) return
|
||||
|
||||
const rect = triggerRef.value.getBoundingClientRect()
|
||||
const dropdownMaxHeight = 400 // max-height
|
||||
const spaceAbove = rect.top
|
||||
const padding = 16
|
||||
|
||||
// 计算可用高度,确保有足够空间显示搜索框
|
||||
const availableHeight = Math.min(dropdownMaxHeight, spaceAbove - padding)
|
||||
|
||||
// 确保最小高度(至少能显示搜索框和一些列表项)
|
||||
const minHeight = 200
|
||||
const finalHeight = Math.max(minHeight, availableHeight)
|
||||
|
||||
// 向上弹出,确保不遮挡用户头像
|
||||
dropdownStyle.value = {
|
||||
bottom: `${window.innerHeight - rect.top + 8}px`,
|
||||
left: `${rect.left}px`,
|
||||
width: '280px',
|
||||
height: `${finalHeight}px`,
|
||||
maxHeight: `${finalHeight}px`
|
||||
}
|
||||
}
|
||||
|
||||
const toggleDropdown = () => {
|
||||
if (!canAccessAllTenants.value) return
|
||||
showDropdown.value = !showDropdown.value
|
||||
if (showDropdown.value) {
|
||||
if (tenants.value.length === 0) {
|
||||
loadTenants()
|
||||
}
|
||||
nextTick(() => {
|
||||
updateDropdownPosition()
|
||||
searchInput.value?.focus()
|
||||
})
|
||||
} else {
|
||||
// 关闭时重置搜索
|
||||
searchQuery.value = ''
|
||||
currentPage.value = 1
|
||||
tenants.value = []
|
||||
total.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,30 +138,27 @@ const closeDropdown = () => {
|
||||
showDropdown.value = false
|
||||
searchQuery.value = ''
|
||||
currentPage.value = 1
|
||||
tenants.value = []
|
||||
total.value = 0
|
||||
if (searchTimer.value) {
|
||||
clearTimeout(searchTimer.value)
|
||||
searchTimer.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const close = (event: MouseEvent) => {
|
||||
const target = event.target as HTMLElement
|
||||
if (!target.closest('.tenant-dropdown') && !target.closest('.tenant-menu-item')) {
|
||||
closeDropdown()
|
||||
}
|
||||
const clearSearch = () => {
|
||||
searchQuery.value = ''
|
||||
currentPage.value = 1
|
||||
tenants.value = []
|
||||
total.value = 0
|
||||
loadTenants()
|
||||
}
|
||||
|
||||
const selectTenant = (tenantId: number) => {
|
||||
// 如果选择的是默认租户,清除选择
|
||||
if (tenantId === defaultTenantId.value) {
|
||||
authStore.setSelectedTenant(null)
|
||||
} else {
|
||||
authStore.setSelectedTenant(tenantId)
|
||||
}
|
||||
closeDropdown()
|
||||
// 触发页面刷新以加载新租户的数据
|
||||
MessagePlugin.success(t('tenant.switchSuccess'))
|
||||
setTimeout(() => {
|
||||
window.location.reload()
|
||||
@@ -196,14 +170,12 @@ const loadTenants = async (append = false) => {
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
// 解析搜索关键词,判断是否是租户ID
|
||||
let keyword = searchQuery.value.trim()
|
||||
let tenantID: number | undefined = undefined
|
||||
|
||||
// 如果搜索关键词是纯数字,尝试作为租户ID查询
|
||||
if (keyword && /^\d+$/.test(keyword)) {
|
||||
tenantID = Number(keyword)
|
||||
keyword = '' // 清空关键词,使用租户ID查询
|
||||
keyword = ''
|
||||
}
|
||||
|
||||
const response = await searchTenants({
|
||||
@@ -233,7 +205,6 @@ const loadTenants = async (append = false) => {
|
||||
}
|
||||
|
||||
const handleSearchInput = () => {
|
||||
// 防抖处理,延迟500ms后搜索
|
||||
if (searchTimer.value) {
|
||||
clearTimeout(searchTimer.value)
|
||||
}
|
||||
@@ -243,50 +214,27 @@ const handleSearchInput = () => {
|
||||
tenants.value = []
|
||||
total.value = 0
|
||||
loadTenants()
|
||||
}, 500)
|
||||
}, 300)
|
||||
}
|
||||
|
||||
const loadMore = () => {
|
||||
if (hasMore.value && !loading.value) {
|
||||
const handleScroll = () => {
|
||||
if (!tenantListRef.value) return
|
||||
|
||||
const { scrollTop, scrollHeight, clientHeight } = tenantListRef.value
|
||||
const isNearBottom = scrollHeight - scrollTop - clientHeight < 50
|
||||
|
||||
if (isNearBottom && hasMore.value && !loading.value) {
|
||||
currentPage.value++
|
||||
loadTenants(true)
|
||||
}
|
||||
}
|
||||
|
||||
const handleClickOutside = (event: MouseEvent) => {
|
||||
const target = event.target as HTMLElement
|
||||
if (!target.closest('.tenant-selector-wrapper')) {
|
||||
closeDropdown()
|
||||
}
|
||||
}
|
||||
|
||||
const handleResize = () => {
|
||||
if (showDropdown.value) {
|
||||
updateDropdownPosition()
|
||||
}
|
||||
}
|
||||
|
||||
watch(showDropdown, (newVal) => {
|
||||
if (newVal) {
|
||||
document.addEventListener('click', handleClickOutside)
|
||||
window.addEventListener('resize', handleResize)
|
||||
window.addEventListener('scroll', handleResize, true)
|
||||
updateDropdownPosition()
|
||||
} else {
|
||||
document.removeEventListener('click', handleClickOutside)
|
||||
window.removeEventListener('resize', handleResize)
|
||||
window.removeEventListener('scroll', handleResize, true)
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 不再自动加载,等用户打开下拉框时再加载
|
||||
// 预加载租户列表
|
||||
loadTenants()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('click', handleClickOutside)
|
||||
window.removeEventListener('resize', handleResize)
|
||||
window.removeEventListener('scroll', handleResize, true)
|
||||
if (searchTimer.value) {
|
||||
clearTimeout(searchTimer.value)
|
||||
}
|
||||
@@ -295,84 +243,59 @@ onUnmounted(() => {
|
||||
|
||||
<style scoped lang="less">
|
||||
.tenant-selector {
|
||||
width: 100%;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.tenant-selector-wrapper {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
margin: 0 8px 12px;
|
||||
}
|
||||
|
||||
.tenant-menu-item {
|
||||
cursor: pointer;
|
||||
.tenant-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 48px;
|
||||
padding: 13px 8px 13px 16px;
|
||||
box-sizing: border-box;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
background: #f8faf9;
|
||||
border: 1px solid #e8ebe9;
|
||||
|
||||
&:hover {
|
||||
border-radius: 4px;
|
||||
background: #30323605;
|
||||
color: #00000099;
|
||||
|
||||
.tenant-icon,
|
||||
.tenant-title {
|
||||
color: #00000099;
|
||||
}
|
||||
}
|
||||
|
||||
&.readonly {
|
||||
cursor: default;
|
||||
|
||||
&:hover {
|
||||
background: transparent;
|
||||
}
|
||||
background: #f0f5f2;
|
||||
border-color: #d0d8d3;
|
||||
}
|
||||
}
|
||||
|
||||
.tenant-item-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.tenant-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tenant-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 12px;
|
||||
color: #00000099;
|
||||
flex-shrink: 0;
|
||||
.tenant-label {
|
||||
font-size: 11px;
|
||||
color: #8b9196;
|
||||
margin-bottom: 2px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.tenant-title {
|
||||
.tenant-name-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.tenant-name {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
color: #000000e6;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tenant-arrow {
|
||||
font-size: 16px;
|
||||
color: #00000066;
|
||||
.tenant-switch-icon {
|
||||
font-size: 14px;
|
||||
color: #07c05f;
|
||||
flex-shrink: 0;
|
||||
margin-left: 8px;
|
||||
transition: transform 0.2s;
|
||||
|
||||
&.rotated {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
|
||||
.tenant-overlay {
|
||||
@@ -385,72 +308,123 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
.tenant-dropdown {
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
top: calc(100% + 4px);
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #e7e9eb;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
transform-origin: bottom left;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tenant-search {
|
||||
padding: 8px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
background: #fafafa;
|
||||
flex-shrink: 0;
|
||||
box-sizing: border-box;
|
||||
.dropdown-header {
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.tenant-search-input {
|
||||
width: 100%;
|
||||
padding: 6px 8px;
|
||||
border: 1px solid #e7e9eb;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
background: #fff;
|
||||
color: #333;
|
||||
transition: border-color 0.2s;
|
||||
box-sizing: border-box;
|
||||
.dropdown-title {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
.search-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 7px 10px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 6px;
|
||||
border: 1px solid transparent;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:focus-within {
|
||||
background: #fff;
|
||||
border-color: #07c05f;
|
||||
box-shadow: 0 0 0 2px rgba(7, 192, 95, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
min-width: 0;
|
||||
|
||||
&::placeholder {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.clear-icon {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: color 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
.tenant-list {
|
||||
flex: 1;
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 4px 0;
|
||||
min-height: 0;
|
||||
max-height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 6px;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: #e0e0e0;
|
||||
border-radius: 2px;
|
||||
|
||||
&:hover {
|
||||
background: #ccc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tenant-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 16px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
transition: all 0.15s;
|
||||
margin-bottom: 2px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background: #07c05f1a;
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
|
||||
.tenant-item-name {
|
||||
color: #07c05f;
|
||||
@@ -459,26 +433,45 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.tenant-item-info {
|
||||
flex: 1;
|
||||
.tenant-item-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tenant-item-name {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
font-weight: 400;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
.tenant-item-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
background: #f0f0f0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.2s;
|
||||
|
||||
&.active {
|
||||
background: linear-gradient(135deg, #07C05F 0%, #05A34E 100%);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.tenant-item-desc {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
.tenant-item-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.tenant-item-name {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -487,48 +480,46 @@ onUnmounted(() => {
|
||||
.tenant-item-id {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.tenant-loading {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.tenant-load-more {
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
color: #07c05f;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
transition: background 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
}
|
||||
}
|
||||
|
||||
.tenant-search-hint {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
margin-top: 4px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.tenant-check-icon {
|
||||
.check-icon {
|
||||
color: #07c05f;
|
||||
flex-shrink: 0;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.tenant-loading,
|
||||
.tenant-empty {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px 12px;
|
||||
gap: 8px;
|
||||
color: #999;
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.tenant-loading-more {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
// 下拉动画
|
||||
.dropdown-enter-active,
|
||||
.dropdown-leave-active {
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.dropdown-enter-from,
|
||||
.dropdown-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-6px);
|
||||
}
|
||||
|
||||
.dropdown-enter-to,
|
||||
.dropdown-leave-from {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
<img class="logo" src="@/assets/img/weknora.png" alt="">
|
||||
</div>
|
||||
|
||||
<!-- 租户选择器:仅在用户可切换租户时显示 -->
|
||||
<TenantSelector v-if="canAccessAllTenants" />
|
||||
|
||||
<!-- 上半部分:知识库和对话 -->
|
||||
<div class="menu_top">
|
||||
<div v-if="showKbActions" class="kb-action-wrapper">
|
||||
@@ -161,7 +164,6 @@
|
||||
|
||||
<!-- 下半部分:用户菜单 -->
|
||||
<div class="menu_bottom">
|
||||
<TenantSelector />
|
||||
<UserMenu />
|
||||
</div>
|
||||
|
||||
@@ -218,6 +220,9 @@ type MenuItem = { title: string; icon: string; path: string; childrenPath?: stri
|
||||
const { menuArr } = storeToRefs(usemenuStore);
|
||||
let activeSubmenu = ref<string>('');
|
||||
|
||||
// 是否可以访问所有租户
|
||||
const canAccessAllTenants = computed(() => authStore.canAccessAllTenants);
|
||||
|
||||
// 是否处于知识库详情页(不包括全局聊天)
|
||||
const isInKnowledgeBase = computed<boolean>(() => {
|
||||
return route.name === 'knowledgeBaseDetail' ||
|
||||
|
||||
@@ -905,6 +905,7 @@ export default {
|
||||
noNegative: 'No negative examples',
|
||||
emptyTitle: 'No FAQ entries',
|
||||
emptyDesc: 'Click "Create FAQ Entry" above to get started',
|
||||
searchPlaceholder: 'Search standard questions...',
|
||||
searchTest: 'Search Test',
|
||||
searchTestTitle: 'FAQ Search Test',
|
||||
queryLabel: 'Query',
|
||||
@@ -1150,6 +1151,7 @@ export default {
|
||||
tenant: {
|
||||
title: 'Tenant Information',
|
||||
currentTenant: 'Current Tenant',
|
||||
switchTenant: 'Switch Tenant',
|
||||
sectionDescription: 'View detailed configuration for the tenant',
|
||||
apiDocument: 'API Document',
|
||||
name: 'Tenant Name',
|
||||
|
||||
@@ -641,6 +641,7 @@ export default {
|
||||
tenant: {
|
||||
title: 'Информация об арендаторе',
|
||||
currentTenant: 'Текущий арендатор',
|
||||
switchTenant: 'Сменить арендатора',
|
||||
sectionDescription: 'Просмотр детальной конфигурации арендатора',
|
||||
apiDocument: 'Документация API',
|
||||
name: 'Имя арендатора',
|
||||
@@ -1001,6 +1002,7 @@ export default {
|
||||
noNegative: 'Нет негативных примеров',
|
||||
emptyTitle: 'Нет записей FAQ',
|
||||
emptyDesc: 'Нажмите "Создать FAQ запись" выше, чтобы начать',
|
||||
searchPlaceholder: 'Поиск стандартных вопросов...',
|
||||
searchTest: 'Тест поиска',
|
||||
searchTestTitle: 'Тест поиска FAQ',
|
||||
queryLabel: 'Запрос',
|
||||
|
||||
@@ -37,7 +37,7 @@ export default {
|
||||
tagCreateSuccess: "标签创建成功",
|
||||
tagEditSuccess: "标签更新成功",
|
||||
tagDeleteTitle: "删除标签",
|
||||
tagDeleteDesc: "确定删除标签“{name}”?已关联的 FAQ 将被标记为未分类",
|
||||
tagDeleteDesc: '确定删除标签"{name}"?已关联的 FAQ 将被标记为未分类',
|
||||
tagDeleteSuccess: "标签已删除",
|
||||
tagEditAction: "重命名",
|
||||
tagDeleteAction: "删除",
|
||||
@@ -733,6 +733,7 @@ export default {
|
||||
tenant: {
|
||||
title: "租户信息",
|
||||
currentTenant: "当前租户",
|
||||
switchTenant: "切换租户",
|
||||
sectionDescription: "查看租户的详细配置信息",
|
||||
apiDocument: "API文档",
|
||||
name: "租户名称",
|
||||
@@ -939,7 +940,7 @@ export default {
|
||||
dimensionDetected: "检测成功,向量维度:{value}",
|
||||
dimensionFailed: "检测失败,请手动输入维度",
|
||||
remoteDimensionDetected: "检测到向量维度:{value}",
|
||||
dimensionHint: "模型已选择,点击“检测维度”按钮自动获取向量维度",
|
||||
dimensionHint: '模型已选择,点击"检测维度"按钮自动获取向量维度',
|
||||
loadModelListFailed: "加载模型列表失败",
|
||||
listRefreshed: "列表已刷新",
|
||||
fillModelAndUrl: "请先填写模型标识和 Base URL",
|
||||
@@ -1123,11 +1124,11 @@ export default {
|
||||
"部分知识库尚未初始化,需要先在设置中配置模型信息才能添加知识文档",
|
||||
empty: {
|
||||
title: "暂无知识库",
|
||||
description: "点击左侧快捷操作“新建知识库”按钮创建第一个知识库",
|
||||
description: '点击左侧快捷操作"新建知识库"按钮创建第一个知识库',
|
||||
},
|
||||
delete: {
|
||||
confirmTitle: "删除确认",
|
||||
confirmMessage: "确认要删除知识库“{name}”?删除后不可恢复",
|
||||
confirmMessage: '确认要删除知识库"{name}"?删除后不可恢复',
|
||||
confirmButton: "确认删除",
|
||||
},
|
||||
messages: {
|
||||
@@ -1239,7 +1240,8 @@ export default {
|
||||
noSimilar: "暂无相似问",
|
||||
noNegative: "暂无反例",
|
||||
emptyTitle: "暂无 FAQ 条目",
|
||||
emptyDesc: "点击上方“新增 FAQ 条目”按钮开始创建",
|
||||
emptyDesc: '点击上方"新增 FAQ 条目"按钮开始创建',
|
||||
searchPlaceholder: "搜索问题和答案...",
|
||||
searchTest: "检索测试",
|
||||
searchTestTitle: "FAQ 检索测试",
|
||||
queryLabel: "查询内容",
|
||||
@@ -1441,7 +1443,7 @@ export default {
|
||||
label: "Agent 状态",
|
||||
ready: "可用",
|
||||
notReady: "未就绪",
|
||||
hint: "配置完成后,Agent 状态将自动变为“可用”,此时可在对话界面开启 Agent 模式",
|
||||
hint: '配置完成后,Agent 状态将自动变为"可用",此时可在对话界面开启 Agent 模式',
|
||||
missingThinkingModel: "思考模型",
|
||||
missingSummaryModel: "对话模型(Summary Model)",
|
||||
missingRerankModel: "Rerank 模型",
|
||||
@@ -1690,7 +1692,7 @@ export default {
|
||||
deleted: "MCP 服务已删除",
|
||||
deleteFailed: "删除 MCP 服务失败",
|
||||
},
|
||||
deleteConfirmBody: "确定要删除 MCP 服务“{name}”吗?此操作无法撤销。",
|
||||
deleteConfirmBody: '确定要删除 MCP 服务"{name}"吗?此操作无法撤销。',
|
||||
unnamed: "未命名",
|
||||
},
|
||||
|
||||
@@ -1748,7 +1750,7 @@ export default {
|
||||
description: "管理本地 Ollama 服务,查看和下载模型",
|
||||
status: {
|
||||
label: "Ollama 服务状态",
|
||||
desc: "自动检测本地 Ollama 服务是否可用。如果服务未运行或地址配置错误,将显示“不可用”状态",
|
||||
desc: '自动检测本地 Ollama 服务是否可用。如果服务未运行或地址配置错误,将显示"不可用"状态',
|
||||
testing: "检测中",
|
||||
available: "可用",
|
||||
unavailable: "不可用",
|
||||
|
||||
@@ -51,6 +51,12 @@ const tagList = ref<any[]>([]);
|
||||
const tagLoading = ref(false);
|
||||
const overallKnowledgeTotal = ref(0);
|
||||
const tagSearchQuery = ref('');
|
||||
const TAG_PAGE_SIZE = 50;
|
||||
const tagPage = ref(1);
|
||||
const tagHasMore = ref(false);
|
||||
const tagLoadingMore = ref(false);
|
||||
const tagTotal = ref(0);
|
||||
let tagSearchDebounce: ReturnType<typeof setTimeout> | null = null;
|
||||
type TagInputInstance = ComponentPublicInstance<{ focus: () => void; select: () => void }>;
|
||||
const tagDropdownOptions = computed(() => {
|
||||
const options = [
|
||||
@@ -146,22 +152,57 @@ const loadKnowledgeFiles = (kbIdValue: string) => {
|
||||
);
|
||||
};
|
||||
|
||||
const loadTags = async (kbIdValue: string) => {
|
||||
const loadTags = async (kbIdValue: string, reset = false) => {
|
||||
if (!kbIdValue) {
|
||||
tagList.value = [];
|
||||
tagTotal.value = 0;
|
||||
tagHasMore.value = false;
|
||||
tagPage.value = 1;
|
||||
return;
|
||||
}
|
||||
tagLoading.value = true;
|
||||
|
||||
if (reset) {
|
||||
tagPage.value = 1;
|
||||
tagList.value = [];
|
||||
tagTotal.value = 0;
|
||||
tagHasMore.value = false;
|
||||
}
|
||||
|
||||
const currentPage = tagPage.value || 1;
|
||||
tagLoading.value = currentPage === 1;
|
||||
tagLoadingMore.value = currentPage > 1;
|
||||
|
||||
try {
|
||||
const res: any = await listKnowledgeTags(kbIdValue);
|
||||
tagList.value = (res?.data || []).map((tag: any) => ({
|
||||
const res: any = await listKnowledgeTags(kbIdValue, {
|
||||
page: currentPage,
|
||||
page_size: TAG_PAGE_SIZE,
|
||||
keyword: tagSearchQuery.value || undefined,
|
||||
});
|
||||
const pageData = (res?.data || {}) as {
|
||||
data?: any[];
|
||||
total?: number;
|
||||
};
|
||||
const pageTags = (pageData.data || []).map((tag: any) => ({
|
||||
...tag,
|
||||
id: String(tag.id),
|
||||
}));
|
||||
|
||||
if (currentPage === 1) {
|
||||
tagList.value = pageTags;
|
||||
} else {
|
||||
tagList.value = [...tagList.value, ...pageTags];
|
||||
}
|
||||
|
||||
tagTotal.value = pageData.total || tagList.value.length;
|
||||
tagHasMore.value = tagList.value.length < tagTotal.value;
|
||||
if (tagHasMore.value) {
|
||||
tagPage.value = currentPage + 1;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load tags', error);
|
||||
} finally {
|
||||
tagLoading.value = false;
|
||||
tagLoadingMore.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -345,7 +386,7 @@ const loadKnowledgeBaseInfo = async (targetKbId: string) => {
|
||||
cardList.value = [];
|
||||
total.value = 0;
|
||||
}
|
||||
loadTags(targetKbId);
|
||||
loadTags(targetKbId, true);
|
||||
overallKnowledgeTotal.value = total.value;
|
||||
} catch (error) {
|
||||
console.error('Failed to load knowledge base info:', error);
|
||||
@@ -371,6 +412,8 @@ const loadKnowledgeList = async () => {
|
||||
// 监听路由参数变化,重新获取知识库内容
|
||||
watch(() => kbId.value, (newKbId, oldKbId) => {
|
||||
if (newKbId && newKbId !== oldKbId) {
|
||||
tagSearchQuery.value = '';
|
||||
tagPage.value = 1;
|
||||
loadKnowledgeBaseInfo(newKbId);
|
||||
}
|
||||
}, { immediate: false });
|
||||
@@ -388,6 +431,18 @@ watch(total, (val) => {
|
||||
}
|
||||
});
|
||||
|
||||
watch(tagSearchQuery, (newVal, oldVal) => {
|
||||
if (newVal === oldVal) return;
|
||||
if (tagSearchDebounce) {
|
||||
clearTimeout(tagSearchDebounce);
|
||||
}
|
||||
tagSearchDebounce = window.setTimeout(() => {
|
||||
if (kbId.value) {
|
||||
loadTags(kbId.value, true);
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
|
||||
// 监听文件上传事件
|
||||
const handleFileUploaded = (event: CustomEvent) => {
|
||||
const uploadedKbId = event.detail.kbId;
|
||||
@@ -1033,6 +1088,16 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<div v-else class="tag-empty-state">
|
||||
{{ $t('knowledgeBase.tagEmptyResult') }}
|
||||
</div>
|
||||
<div v-if="tagHasMore" class="tag-load-more">
|
||||
<t-button
|
||||
variant="text"
|
||||
size="small"
|
||||
:loading="tagLoadingMore"
|
||||
@click.stop="kbId && loadTags(kbId)"
|
||||
>
|
||||
{{ $t('tenant.loadMore') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</t-loading>
|
||||
</aside>
|
||||
@@ -1321,6 +1386,8 @@ async function createNewSession(value: string): Promise<void> {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
max-height: 100%;
|
||||
min-height: 0;
|
||||
|
||||
.sidebar-header {
|
||||
display: flex;
|
||||
@@ -1387,7 +1454,21 @@ async function createNewSession(value: string): Promise<void> {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
overflow: auto;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
|
||||
.tag-load-more {
|
||||
padding: 8px 0 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
:deep(.t-button) {
|
||||
padding: 0;
|
||||
font-size: 12px;
|
||||
color: #00a870;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-list-item {
|
||||
display: flex;
|
||||
|
||||
@@ -58,36 +58,40 @@
|
||||
<div v-if="importState.taskId && importState.taskStatus" class="faq-import-progress-bar">
|
||||
<div class="progress-bar-content">
|
||||
<div class="progress-bar-header">
|
||||
<t-icon
|
||||
:name="importState.taskStatus.status === 'running' ? 'loading' :
|
||||
importState.taskStatus.status === 'success' ? 'check-circle' :
|
||||
importState.taskStatus.status === 'failed' ? 'error-circle' : 'time'"
|
||||
size="16px"
|
||||
class="progress-icon"
|
||||
:class="{
|
||||
'icon-loading': importState.taskStatus.status === 'running',
|
||||
'icon-success': importState.taskStatus.status === 'success',
|
||||
'icon-error': importState.taskStatus.status === 'failed'
|
||||
}"
|
||||
/>
|
||||
<span class="progress-title">
|
||||
{{ importState.taskStatus.status === 'running' ? '导入中...' :
|
||||
importState.taskStatus.status === 'success' ? '导入完成' :
|
||||
importState.taskStatus.status === 'failed' ? '导入失败' : '等待中...' }}
|
||||
</span>
|
||||
<span class="progress-count">
|
||||
{{ importState.taskStatus.processed }}/{{ importState.taskStatus.total }}
|
||||
</span>
|
||||
<t-button
|
||||
v-if="importState.taskStatus.status === 'success' || importState.taskStatus.status === 'failed'"
|
||||
variant="text"
|
||||
theme="default"
|
||||
size="small"
|
||||
class="progress-close-btn"
|
||||
@click="handleCloseProgress"
|
||||
>
|
||||
<t-icon name="close" size="14px" />
|
||||
</t-button>
|
||||
<div class="progress-left">
|
||||
<t-icon
|
||||
:name="importState.taskStatus.status === 'running' ? 'loading' :
|
||||
importState.taskStatus.status === 'success' ? 'check-circle' :
|
||||
importState.taskStatus.status === 'failed' ? 'error-circle' : 'time'"
|
||||
size="18px"
|
||||
class="progress-icon"
|
||||
:class="{
|
||||
'icon-loading': importState.taskStatus.status === 'running',
|
||||
'icon-success': importState.taskStatus.status === 'success',
|
||||
'icon-error': importState.taskStatus.status === 'failed'
|
||||
}"
|
||||
/>
|
||||
<span class="progress-title">
|
||||
{{ importState.taskStatus.status === 'running' ? '导入中...' :
|
||||
importState.taskStatus.status === 'success' ? '导入完成' :
|
||||
importState.taskStatus.status === 'failed' ? '导入失败' : '等待中...' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="progress-right">
|
||||
<span class="progress-count">
|
||||
{{ importState.taskStatus.processed }}/{{ importState.taskStatus.total }} 条
|
||||
</span>
|
||||
<t-button
|
||||
v-if="importState.taskStatus.status === 'success' || importState.taskStatus.status === 'failed'"
|
||||
variant="text"
|
||||
theme="default"
|
||||
size="small"
|
||||
class="progress-close-btn"
|
||||
@click="handleCloseProgress"
|
||||
>
|
||||
<t-icon name="close" size="14px" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<t-progress
|
||||
:percentage="importState.taskStatus.progress"
|
||||
@@ -103,7 +107,7 @@
|
||||
</div>
|
||||
|
||||
<div class="faq-main">
|
||||
<aside class="faq-tag-panel">
|
||||
<aside class="faq-tag-panel">
|
||||
<div class="sidebar-header">
|
||||
<div class="sidebar-title">
|
||||
<span>{{ $t('knowledgeBase.faqCategoryTitle') }}</span>
|
||||
@@ -135,7 +139,7 @@
|
||||
</t-input>
|
||||
</div>
|
||||
<t-loading :loading="tagLoading" size="small">
|
||||
<div class="faq-tag-list">
|
||||
<div ref="tagListRef" class="faq-tag-list" @scroll="handleTagListScroll">
|
||||
<div
|
||||
class="faq-tag-item"
|
||||
:class="{ active: selectedTagId === '' }"
|
||||
@@ -260,11 +264,28 @@
|
||||
<div v-else class="tag-empty-state">
|
||||
{{ $t('knowledgeBase.tagEmptyResult') }}
|
||||
</div>
|
||||
<div v-if="tagLoadingMore" class="tag-loading-more">
|
||||
<t-loading size="small" />
|
||||
</div>
|
||||
</div>
|
||||
</t-loading>
|
||||
</aside>
|
||||
|
||||
<div class="faq-card-area">
|
||||
<!-- 搜索栏 -->
|
||||
<div class="faq-search-bar">
|
||||
<t-input
|
||||
v-model.trim="entrySearchKeyword"
|
||||
:placeholder="$t('knowledgeEditor.faq.searchPlaceholder')"
|
||||
clearable
|
||||
@clear="loadEntries()"
|
||||
@keydown.enter="loadEntries()"
|
||||
>
|
||||
<template #prefix-icon>
|
||||
<t-icon name="search" size="16px" />
|
||||
</template>
|
||||
</t-input>
|
||||
</div>
|
||||
<!-- Card List Container with Scroll -->
|
||||
<div ref="scrollContainer" class="faq-scroll-container" @scroll="handleScroll">
|
||||
<t-loading :loading="loading && entries.length === 0" size="medium">
|
||||
@@ -1132,13 +1153,22 @@ const cardListRef = ref<HTMLElement | null>(null)
|
||||
const hasMore = ref(true)
|
||||
const pageSize = 20
|
||||
let currentPage = 1
|
||||
const entrySearchKeyword = ref('')
|
||||
let entrySearchDebounce: ReturnType<typeof setTimeout> | null = null
|
||||
type TagInputInstance = ComponentPublicInstance<{ focus: () => void; select: () => void }>
|
||||
|
||||
const tagList = ref<any[]>([])
|
||||
const tagLoading = ref(false)
|
||||
const tagListRef = ref<HTMLElement | null>(null)
|
||||
const selectedTagId = ref<string>('')
|
||||
const overallFAQTotal = ref(0)
|
||||
const tagSearchQuery = ref('')
|
||||
const TAG_PAGE_SIZE = 20
|
||||
const tagPage = ref(1)
|
||||
const tagHasMore = ref(false)
|
||||
const tagLoadingMore = ref(false)
|
||||
const tagTotal = ref(0)
|
||||
let tagSearchDebounce: ReturnType<typeof setTimeout> | null = null
|
||||
const editingTagInputRefs = new Map<string, TagInputInstance | null>()
|
||||
const setEditingTagInputRef = (el: TagInputInstance | null, tagId: string) => {
|
||||
if (el) {
|
||||
@@ -1338,22 +1368,70 @@ const handleToolbarAction = (data: { value: string }) => {
|
||||
}
|
||||
}
|
||||
|
||||
const loadTags = async () => {
|
||||
// 标签列表滚动加载更多
|
||||
const handleTagListScroll = () => {
|
||||
const container = tagListRef.value
|
||||
if (!container) return
|
||||
if (tagLoadingMore.value || !tagHasMore.value) return
|
||||
|
||||
const { scrollTop, scrollHeight, clientHeight } = container
|
||||
// 距离底部 50px 时触发加载
|
||||
if (scrollTop + clientHeight >= scrollHeight - 50) {
|
||||
loadTags()
|
||||
}
|
||||
}
|
||||
|
||||
const loadTags = async (reset = false) => {
|
||||
if (!props.kbId) {
|
||||
tagList.value = []
|
||||
tagTotal.value = 0
|
||||
tagHasMore.value = false
|
||||
tagPage.value = 1
|
||||
return
|
||||
}
|
||||
tagLoading.value = true
|
||||
|
||||
if (reset) {
|
||||
tagPage.value = 1
|
||||
tagList.value = []
|
||||
tagTotal.value = 0
|
||||
tagHasMore.value = false
|
||||
}
|
||||
|
||||
const currentPage = tagPage.value || 1
|
||||
tagLoading.value = currentPage === 1
|
||||
tagLoadingMore.value = currentPage > 1
|
||||
|
||||
try {
|
||||
const res: any = await listKnowledgeTags(props.kbId)
|
||||
tagList.value = (res?.data || []).map((tag: any) => ({
|
||||
const res: any = await listKnowledgeTags(props.kbId, {
|
||||
page: currentPage,
|
||||
page_size: TAG_PAGE_SIZE,
|
||||
keyword: tagSearchQuery.value || undefined,
|
||||
})
|
||||
const pageData = (res?.data || {}) as {
|
||||
data?: any[]
|
||||
total?: number
|
||||
}
|
||||
const pageTags = (pageData.data || []).map((tag: any) => ({
|
||||
...tag,
|
||||
id: String(tag.id),
|
||||
}))
|
||||
|
||||
if (currentPage === 1) {
|
||||
tagList.value = pageTags
|
||||
} else {
|
||||
tagList.value = [...tagList.value, ...pageTags]
|
||||
}
|
||||
|
||||
tagTotal.value = pageData.total || tagList.value.length
|
||||
tagHasMore.value = tagList.value.length < tagTotal.value
|
||||
if (tagHasMore.value) {
|
||||
tagPage.value = currentPage + 1
|
||||
}
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('common.operationFailed'))
|
||||
} finally {
|
||||
tagLoading.value = false
|
||||
tagLoadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1645,6 +1723,7 @@ const loadEntries = async (append = false) => {
|
||||
page: currentPage,
|
||||
page_size: pageSize,
|
||||
tag_id: selectedTagId.value || undefined,
|
||||
keyword: entrySearchKeyword.value ? entrySearchKeyword.value.trim() : undefined,
|
||||
})
|
||||
const pageData = (res.data || {}) as {
|
||||
data: FAQEntry[]
|
||||
@@ -1653,7 +1732,7 @@ const loadEntries = async (append = false) => {
|
||||
const newEntries = (pageData.data || []).map(entry => ({
|
||||
...entry,
|
||||
showMore: false,
|
||||
similarCollapsed: false, // 相似问默认展开
|
||||
similarCollapsed: true, // 相似问默认折叠
|
||||
negativeCollapsed: true, // 反例默认折叠
|
||||
answersCollapsed: true, // 答案默认折叠
|
||||
tag_id: entry.tag_id ? String(entry.tag_id) : '',
|
||||
@@ -1680,6 +1759,12 @@ const loadEntries = async (append = false) => {
|
||||
} finally {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
|
||||
// 检查是否需要继续加载以填满可视区域
|
||||
// 延迟执行以确保 arrangeCards 的 requestAnimationFrame 完成
|
||||
setTimeout(() => {
|
||||
checkAndLoadMore()
|
||||
}, 350)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1697,6 +1782,22 @@ const handleScroll = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 检查内容是否填满可视区域,如果没有且还有更多数据,继续加载
|
||||
const checkAndLoadMore = () => {
|
||||
if (!scrollContainer.value) return
|
||||
if (loadingMore.value || loading.value) return
|
||||
if (!hasMore.value) return
|
||||
|
||||
const container = scrollContainer.value
|
||||
const scrollHeight = container.scrollHeight
|
||||
const clientHeight = container.clientHeight
|
||||
|
||||
// 如果内容高度小于容器高度 + 50px 的缓冲,说明可能没有滚动条或接近底部,需要继续加载
|
||||
if (scrollHeight <= clientHeight + 50) {
|
||||
loadEntries(true)
|
||||
}
|
||||
}
|
||||
|
||||
const handleCardSelect = (entryId: string, checked: boolean) => {
|
||||
if (checked) {
|
||||
if (!selectedRowKeys.value.includes(entryId)) {
|
||||
@@ -2097,6 +2198,9 @@ const startPolling = (taskId: string) => {
|
||||
// 保存taskId到localStorage,以便刷新后恢复
|
||||
saveTaskIdToStorage(taskId)
|
||||
|
||||
// 记录上次已处理数量,用于判断是否需要刷新列表
|
||||
let lastProcessed = 0
|
||||
|
||||
importState.pollingInterval = setInterval(async () => {
|
||||
try {
|
||||
const res: any = await getKnowledgeDetails(taskId)
|
||||
@@ -2126,6 +2230,12 @@ const startPolling = (taskId: string) => {
|
||||
error: error,
|
||||
}
|
||||
|
||||
// 进度更新时刷新FAQ列表(每增加一些条目就刷新一次)
|
||||
if (processed > lastProcessed) {
|
||||
lastProcessed = processed
|
||||
await loadEntries()
|
||||
}
|
||||
|
||||
// 任务完成或失败,停止轮询(但不自动关闭进度条,让用户手动关闭)
|
||||
if (status === 'success' || status === 'failed') {
|
||||
stopPolling()
|
||||
@@ -2477,7 +2587,7 @@ watch(
|
||||
}
|
||||
|
||||
loadEntries()
|
||||
loadTags()
|
||||
loadTags(true)
|
||||
// 恢复导入任务状态(如果存在)
|
||||
await restoreImportTask()
|
||||
},
|
||||
@@ -2494,6 +2604,27 @@ watch(selectedTagId, (newVal, oldVal) => {
|
||||
}
|
||||
})
|
||||
|
||||
watch(tagSearchQuery, (newVal, oldVal) => {
|
||||
if (newVal === oldVal) return
|
||||
if (tagSearchDebounce) {
|
||||
clearTimeout(tagSearchDebounce)
|
||||
}
|
||||
tagSearchDebounce = window.setTimeout(() => {
|
||||
loadTags(true)
|
||||
}, 300)
|
||||
})
|
||||
|
||||
// 监听FAQ搜索关键词变化
|
||||
watch(entrySearchKeyword, (newVal, oldVal) => {
|
||||
if (newVal === oldVal) return
|
||||
if (entrySearchDebounce) {
|
||||
clearTimeout(entrySearchDebounce)
|
||||
}
|
||||
entrySearchDebounce = window.setTimeout(() => {
|
||||
loadEntries()
|
||||
}, 300)
|
||||
})
|
||||
|
||||
const handleSearch = async () => {
|
||||
if (!searchForm.query.trim()) {
|
||||
MessagePlugin.warning(t('knowledgeEditor.faq.queryPlaceholder'))
|
||||
@@ -2510,7 +2641,7 @@ const handleSearch = async () => {
|
||||
})
|
||||
const results = (res.data || []).map((entry: FAQEntry) => ({
|
||||
...entry,
|
||||
similarCollapsed: false, // 相似问默认展开
|
||||
similarCollapsed: true, // 相似问默认折叠
|
||||
negativeCollapsed: true, // 反例默认折叠
|
||||
answersCollapsed: true, // 答案默认折叠
|
||||
expanded: false,
|
||||
@@ -2656,6 +2787,10 @@ const handleResize = () => {
|
||||
}
|
||||
resizeTimer = setTimeout(() => {
|
||||
arrangeCards()
|
||||
// 窗口变大时可能需要加载更多,延迟执行确保布局完成
|
||||
setTimeout(() => {
|
||||
checkAndLoadMore()
|
||||
}, 350)
|
||||
resizeTimer = null
|
||||
}, 150)
|
||||
}
|
||||
@@ -2832,6 +2967,19 @@ watch(() => entries.value.map(e => ({
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
|
||||
// t-loading 包裹容器需要撑满剩余空间
|
||||
> .t-loading__parent,
|
||||
> .t-loading {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
display: flex;
|
||||
@@ -2913,7 +3061,17 @@ watch(() => entries.value.map(e => ({
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
overflow: auto;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
.tag-loading-more {
|
||||
padding: 12px 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.faq-tag-item {
|
||||
display: flex;
|
||||
@@ -3144,6 +3302,25 @@ watch(() => entries.value.map(e => ({
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.faq-search-bar {
|
||||
padding: 0px 0px 10px 0px;
|
||||
flex-shrink: 0;
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 13px;
|
||||
background-color: #f7f9fc;
|
||||
border-color: #e5e9f2;
|
||||
border-radius: 6px;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&.t-is-focused {
|
||||
background-color: #fff;
|
||||
border-color: #00a870;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.tag-menu) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -3199,25 +3376,37 @@ watch(() => entries.value.map(e => ({
|
||||
// 导入进度条样式(显示在列表页面顶部)
|
||||
.faq-import-progress-bar {
|
||||
margin-bottom: 16px;
|
||||
background: #fff;
|
||||
border: 1px solid #e7ebf0;
|
||||
border-radius: 8px;
|
||||
padding: 12px 16px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||||
background: linear-gradient(135deg, #f8fffe 0%, #f5fff9 100%);
|
||||
border: 1px solid #d4f0e0;
|
||||
border-radius: 10px;
|
||||
padding: 14px 18px;
|
||||
box-shadow: 0 2px 12px rgba(0, 168, 112, 0.08);
|
||||
|
||||
.progress-bar-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.progress-bar-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
color: #000000e6;
|
||||
|
||||
.progress-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.progress-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.progress-icon {
|
||||
flex-shrink: 0;
|
||||
|
||||
@@ -3236,19 +3425,29 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
|
||||
.progress-title {
|
||||
font-weight: 500;
|
||||
flex: 1;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: #1d2129;
|
||||
}
|
||||
|
||||
.progress-count {
|
||||
color: #86909c;
|
||||
color: #4e5969;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
background: rgba(0, 168, 112, 0.1);
|
||||
padding: 2px 10px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.progress-close-btn {
|
||||
flex-shrink: 0;
|
||||
padding: 4px;
|
||||
margin-left: 8px;
|
||||
margin-left: 4px;
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3262,6 +3461,13 @@ watch(() => entries.value.map(e => ({
|
||||
|
||||
:deep(.t-progress__bar) {
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
border-radius: 4px;
|
||||
background: rgba(0, 168, 112, 0.15);
|
||||
}
|
||||
|
||||
:deep(.t-progress__inner) {
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3270,6 +3476,9 @@ watch(() => entries.value.map(e => ({
|
||||
font-size: 13px;
|
||||
color: #fa5151;
|
||||
line-height: 1.5;
|
||||
background: rgba(250, 81, 81, 0.08);
|
||||
padding: 8px 12px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ onUnmounted(() => {
|
||||
.settings-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
z-index: 1100;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user