feat: 将未分类FAQ条目转为"未分类"标签
This commit is contained in:
@@ -1114,6 +1114,7 @@ export default {
|
||||
questionIndexModeDescription: 'Combined: Standard and similar questions are indexed together. Separate: Each question is indexed independently for more precise retrieval but requires more storage.',
|
||||
entryGuide: 'Each FAQ entry contains a primary question, similar questions, negative examples, and multiple answers. Manage them in the FAQ knowledge base detail view.',
|
||||
tagDesc: 'Select category for FAQ entries',
|
||||
tagPlaceholder: 'Please select a category',
|
||||
modes: {
|
||||
questionOnly: 'Questions only',
|
||||
questionAnswer: 'Question + answer',
|
||||
|
||||
@@ -1238,6 +1238,7 @@ export default {
|
||||
questionIndexModeDescription: "병합 인덱스: 표준 질문과 유사 질문을 병합 인덱싱; 개별 인덱스: 표준 질문과 각 유사 질문을 독립적으로 인덱싱하여 더 정확하게 검색하지만 더 많은 저장 공간이 필요합니다",
|
||||
entryGuide: "FAQ 항목은 표준 질문, 유사 질문, 반례 및 여러 답변으로 구성됩니다. 지식베이스 세부 정보에서 일괄 가져오기 및 편집할 수 있습니다.",
|
||||
tagDesc: "FAQ 항목에 분류 선택",
|
||||
tagPlaceholder: "분류를 선택하세요",
|
||||
modes: {
|
||||
questionOnly: "표준 질문/유사 질문만",
|
||||
questionAnswer: "표준 질문 + 답변",
|
||||
|
||||
@@ -1056,6 +1056,7 @@ export default {
|
||||
questionIndexModeDescription: 'Объединенная: стандартные и похожие вопросы индексируются вместе. Раздельная: каждый вопрос индексируется независимо для более точного поиска, но требует больше места.',
|
||||
entryGuide: 'Каждый FAQ включает основной вопрос, похожие вопросы, негативные примеры и несколько ответов. Управляйте ими в деталях FAQ-базы.',
|
||||
tagDesc: 'Выберите категорию для записей FAQ',
|
||||
tagPlaceholder: 'Пожалуйста, выберите категорию',
|
||||
modes: {
|
||||
questionOnly: 'Только вопросы',
|
||||
questionAnswer: 'Вопрос + ответ',
|
||||
|
||||
@@ -1463,6 +1463,7 @@ export default {
|
||||
questionIndexModeDescription: "合并索引:标准问和相似问合并索引;分别索引:标准问和每个相似问独立索引,检索更精确但需要更多存储",
|
||||
entryGuide: "FAQ 条目由标准问、相似问、反例和多个答案组成,可在知识库详情中批量导入、编辑。",
|
||||
tagDesc: "为 FAQ 条目选择分类",
|
||||
tagPlaceholder: "请选择分类",
|
||||
modes: {
|
||||
questionOnly: "仅标准问/相似问",
|
||||
questionAnswer: "标准问 + 答案",
|
||||
|
||||
@@ -46,7 +46,7 @@ let knowledgeScroll = ref()
|
||||
let page = 1;
|
||||
let pageSize = 35;
|
||||
|
||||
const selectedTagId = ref<string>("__untagged__");
|
||||
const selectedTagId = ref<string>('');
|
||||
const tagList = ref<any[]>([]);
|
||||
const tagLoading = ref(false);
|
||||
const tagSearchQuery = ref('');
|
||||
@@ -59,7 +59,6 @@ let tagSearchDebounce: ReturnType<typeof setTimeout> | null = null;
|
||||
let docSearchDebounce: ReturnType<typeof setTimeout> | null = null;
|
||||
const docSearchKeyword = ref('');
|
||||
const selectedFileType = ref('');
|
||||
const UNTAGGED_TAG_ID = '__untagged__';
|
||||
const fileTypeOptions = computed(() => [
|
||||
{ content: t('knowledgeBase.allFileTypes') || '全部类型', value: '' },
|
||||
{ content: 'PDF', value: 'pdf' },
|
||||
@@ -71,18 +70,12 @@ const fileTypeOptions = computed(() => [
|
||||
{ content: t('knowledgeBase.typeManual') || '手动创建', value: 'manual' },
|
||||
]);
|
||||
type TagInputInstance = ComponentPublicInstance<{ focus: () => void; select: () => void }>;
|
||||
const tagDropdownOptions = computed(() => {
|
||||
const options = [
|
||||
{ content: t('knowledgeBase.untagged') || '未分类', value: UNTAGGED_TAG_ID },
|
||||
...tagList.value
|
||||
.filter((tag: any) => tag.id !== UNTAGGED_TAG_ID)
|
||||
.map((tag: any) => ({
|
||||
content: tag.name,
|
||||
value: tag.id,
|
||||
})),
|
||||
];
|
||||
return options;
|
||||
});
|
||||
const tagDropdownOptions = computed(() =>
|
||||
tagList.value.map((tag: any) => ({
|
||||
content: tag.name,
|
||||
value: tag.id,
|
||||
})),
|
||||
);
|
||||
const tagMap = computed<Record<string, any>>(() => {
|
||||
const map: Record<string, any> = {};
|
||||
tagList.value.forEach((tag) => {
|
||||
@@ -124,10 +117,9 @@ const getPageSize = () => {
|
||||
getPageSize()
|
||||
// 直接调用 API 获取知识库文件列表
|
||||
const getTagName = (tagId?: string | number) => {
|
||||
if (!tagId && tagId !== 0) return t('knowledgeBase.untagged') || '未分类';
|
||||
if (tagId === UNTAGGED_TAG_ID) return t('knowledgeBase.untagged') || '未分类';
|
||||
if (!tagId && tagId !== 0) return '';
|
||||
const key = String(tagId);
|
||||
return tagMap.value[key]?.name || (t('knowledgeBase.untagged') || '未分类');
|
||||
return tagMap.value[key]?.name || '';
|
||||
};
|
||||
|
||||
const formatDocTime = (time?: string) => {
|
||||
@@ -225,22 +217,6 @@ const handleTagFilterChange = (value: string) => {
|
||||
};
|
||||
|
||||
const handleTagRowClick = (tagId: string) => {
|
||||
const normalizedId = String(tagId);
|
||||
if (editingTagId.value && editingTagId.value !== normalizedId) {
|
||||
editingTagId.value = null;
|
||||
editingTagName.value = '';
|
||||
}
|
||||
if (creatingTag.value) {
|
||||
creatingTag.value = false;
|
||||
newTagName.value = '';
|
||||
}
|
||||
if (selectedTagId.value === normalizedId) {
|
||||
return;
|
||||
}
|
||||
handleTagFilterChange(normalizedId);
|
||||
};
|
||||
|
||||
const handleUntaggedClick = () => {
|
||||
if (creatingTag.value) {
|
||||
creatingTag.value = false;
|
||||
newTagName.value = '';
|
||||
@@ -249,8 +225,8 @@ const handleUntaggedClick = () => {
|
||||
editingTagId.value = null;
|
||||
editingTagName.value = '';
|
||||
}
|
||||
if (selectedTagId.value === UNTAGGED_TAG_ID) return;
|
||||
handleTagFilterChange(UNTAGGED_TAG_ID);
|
||||
if (selectedTagId.value === tagId) return;
|
||||
handleTagFilterChange(tagId);
|
||||
};
|
||||
|
||||
const startCreateTag = () => {
|
||||
@@ -360,7 +336,9 @@ const confirmDeleteTag = (tag: any) => {
|
||||
.then(() => {
|
||||
MessagePlugin.success(t('knowledgeBase.tagDeleteSuccess'));
|
||||
if (selectedTagId.value === tag.id) {
|
||||
handleTagFilterChange(UNTAGGED_TAG_ID);
|
||||
// Reset to show all entries when current tag is deleted
|
||||
selectedTagId.value = '';
|
||||
handleTagFilterChange('');
|
||||
}
|
||||
loadTags(kbId.value);
|
||||
loadKnowledgeFiles(kbId.value);
|
||||
@@ -372,8 +350,8 @@ const confirmDeleteTag = (tag: any) => {
|
||||
|
||||
const handleKnowledgeTagChange = async (knowledgeId: string, tagValue: string) => {
|
||||
try {
|
||||
// When selecting "untagged", pass null to clear the tag
|
||||
const tagIdToUpdate = tagValue === UNTAGGED_TAG_ID ? null : (tagValue || null);
|
||||
// Pass the tag value directly (empty string means no tag)
|
||||
const tagIdToUpdate = tagValue || null;
|
||||
await updateKnowledgeTagBatch({ updates: { [knowledgeId]: tagIdToUpdate } });
|
||||
MessagePlugin.success(t('knowledgeBase.tagUpdateSuccess') || '分类已更新');
|
||||
loadKnowledgeFiles(kbId.value);
|
||||
@@ -392,7 +370,7 @@ const loadKnowledgeBaseInfo = async (targetKbId: string) => {
|
||||
try {
|
||||
const res: any = await getKnowledgeBaseById(targetKbId);
|
||||
kbInfo.value = res?.data || null;
|
||||
selectedTagId.value = UNTAGGED_TAG_ID;
|
||||
selectedTagId.value = '';
|
||||
if (!isFAQ.value) {
|
||||
loadKnowledgeFiles(targetKbId);
|
||||
} else {
|
||||
@@ -1042,16 +1020,12 @@ async function createNewSession(value: string): Promise<void> {
|
||||
v-for="tag in filteredTags"
|
||||
:key="tag.id"
|
||||
class="tag-list-item"
|
||||
:class="{ active: selectedTagId === tag.id, editing: editingTagId === tag.id && tag.id !== UNTAGGED_TAG_ID }"
|
||||
@click="tag.id === UNTAGGED_TAG_ID ? handleUntaggedClick() : handleTagRowClick(tag.id)"
|
||||
:class="{ active: selectedTagId === tag.id, editing: editingTagId === tag.id }"
|
||||
@click="handleTagRowClick(tag.id)"
|
||||
>
|
||||
<div class="tag-list-left">
|
||||
<t-icon name="folder" size="18px" />
|
||||
<!-- Untagged pseudo-tag: show translated name, no editing -->
|
||||
<template v-if="tag.id === UNTAGGED_TAG_ID">
|
||||
<span class="tag-name">{{ $t('knowledgeBase.untagged') || '未分类' }}</span>
|
||||
</template>
|
||||
<template v-else-if="editingTagId === tag.id">
|
||||
<template v-if="editingTagId === tag.id">
|
||||
<div class="tag-edit-input" @click.stop>
|
||||
<t-input
|
||||
:ref="setEditingTagInputRefByTag(tag.id)"
|
||||
@@ -1069,11 +1043,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</div>
|
||||
<div class="tag-list-right">
|
||||
<span class="tag-count">{{ tag.knowledge_count || 0 }}</span>
|
||||
<!-- Untagged pseudo-tag: no edit/delete actions -->
|
||||
<template v-if="tag.id === UNTAGGED_TAG_ID">
|
||||
<!-- Empty placeholder for alignment -->
|
||||
</template>
|
||||
<template v-else-if="editingTagId === tag.id">
|
||||
<template v-if="editingTagId === tag.id">
|
||||
<div class="tag-inline-actions" @click.stop>
|
||||
<t-button
|
||||
variant="text"
|
||||
|
||||
@@ -183,16 +183,12 @@
|
||||
v-for="tag in filteredTags"
|
||||
:key="tag.id"
|
||||
class="faq-tag-item"
|
||||
:class="{ active: selectedTagId === tag.id, editing: editingTagId === tag.id && tag.id !== UNTAGGED_FILTER }"
|
||||
@click="tag.id === UNTAGGED_FILTER ? handleUntaggedClick() : handleTagRowClick(tag.id)"
|
||||
:class="{ active: selectedTagId === tag.id, editing: editingTagId === tag.id }"
|
||||
@click="handleTagRowClick(tag.id)"
|
||||
>
|
||||
<div class="faq-tag-left">
|
||||
<t-icon name="folder" size="18px" />
|
||||
<!-- Untagged pseudo-tag: show translated name, no editing -->
|
||||
<template v-if="tag.id === UNTAGGED_FILTER">
|
||||
<span class="tag-name">{{ $t('knowledgeBase.untagged') }}</span>
|
||||
</template>
|
||||
<template v-else-if="editingTagId === tag.id">
|
||||
<template v-if="editingTagId === tag.id">
|
||||
<div class="tag-edit-input" @click.stop>
|
||||
<t-input
|
||||
:ref="setEditingTagInputRefByTag(tag.id)"
|
||||
@@ -210,11 +206,7 @@
|
||||
</div>
|
||||
<div class="faq-tag-right">
|
||||
<span class="faq-tag-count">{{ tag.chunk_count || 0 }}</span>
|
||||
<!-- Untagged pseudo-tag: no edit/delete actions, just a placeholder -->
|
||||
<template v-if="tag.id === UNTAGGED_FILTER">
|
||||
<div class="tag-more-placeholder"></div>
|
||||
</template>
|
||||
<template v-else-if="editingTagId === tag.id">
|
||||
<template v-if="editingTagId === tag.id">
|
||||
<div class="tag-inline-actions" @click.stop>
|
||||
<t-button
|
||||
variant="text"
|
||||
@@ -1185,9 +1177,8 @@ type TagInputInstance = ComponentPublicInstance<{ focus: () => void; select: ()
|
||||
const tagList = ref<any[]>([])
|
||||
const tagLoading = ref(false)
|
||||
const tagListRef = ref<HTMLElement | null>(null)
|
||||
// Special value to represent "untagged" filter - must match backend constant
|
||||
const UNTAGGED_FILTER = '__untagged__'
|
||||
const selectedTagId = ref<string>(UNTAGGED_FILTER)
|
||||
// Selected tag ID for filtering (empty string means show all)
|
||||
const selectedTagId = ref<string>('')
|
||||
const overallFAQTotal = ref(0)
|
||||
const tagSearchQuery = ref('')
|
||||
const TAG_PAGE_SIZE = 20
|
||||
@@ -1221,16 +1212,14 @@ const tagMap = computed<Record<string, any>>(() => {
|
||||
})
|
||||
return map
|
||||
})
|
||||
// Filter out the __untagged__ pseudo-tag for tag select options (when assigning tags)
|
||||
const regularTags = computed(() => tagList.value.filter((tag) => tag.id !== UNTAGGED_FILTER))
|
||||
const tagDropdownOptions = computed(() => [
|
||||
{ content: t('knowledgeBase.untagged') || '未分类', value: '' },
|
||||
...regularTags.value.map((tag: any) => ({ content: tag.name, value: tag.id })),
|
||||
])
|
||||
const tagSelectOptions = computed(() => [
|
||||
{ label: t('knowledgeBase.untagged') || '未分类', value: '' },
|
||||
...regularTags.value.map((tag: any) => ({ label: tag.name, value: tag.id })),
|
||||
])
|
||||
// All tags are now regular tags (no pseudo-tag)
|
||||
const regularTags = computed(() => tagList.value)
|
||||
const tagDropdownOptions = computed(() =>
|
||||
regularTags.value.map((tag: any) => ({ content: tag.name, value: tag.id })),
|
||||
)
|
||||
const tagSelectOptions = computed(() =>
|
||||
regularTags.value.map((tag: any) => ({ label: tag.name, value: tag.id })),
|
||||
)
|
||||
const sidebarCategoryCount = computed(() => tagList.value.length)
|
||||
const filteredTags = computed(() => {
|
||||
const query = tagSearchQuery.value.trim().toLowerCase()
|
||||
@@ -1418,17 +1407,6 @@ const handleTagRowClick = (tagId: string) => {
|
||||
handleTagFilterChange(normalizedId)
|
||||
}
|
||||
|
||||
const handleUntaggedClick = () => {
|
||||
if (creatingTag.value) {
|
||||
cancelCreateTag()
|
||||
}
|
||||
if (editingTagId.value) {
|
||||
cancelEditTag()
|
||||
}
|
||||
if (selectedTagId.value === UNTAGGED_FILTER) return
|
||||
handleTagFilterChange(UNTAGGED_FILTER)
|
||||
}
|
||||
|
||||
const startCreateTag = () => {
|
||||
if (!props.kbId) {
|
||||
MessagePlugin.warning(t('knowledgeEditor.messages.missingId'))
|
||||
@@ -1536,7 +1514,9 @@ const confirmDeleteTag = (tag: any) => {
|
||||
await deleteKnowledgeBaseTag(props.kbId, tag.id, { force: true })
|
||||
MessagePlugin.success(t('knowledgeBase.tagDeleteSuccess'))
|
||||
if (selectedTagId.value === tag.id) {
|
||||
handleTagFilterChange(UNTAGGED_FILTER)
|
||||
// Reset to show all entries when current tag is deleted
|
||||
selectedTagId.value = ''
|
||||
handleTagFilterChange('')
|
||||
}
|
||||
await loadTags()
|
||||
await loadEntries()
|
||||
@@ -2253,7 +2233,7 @@ const startPolling = (taskId: string) => {
|
||||
if (status === 'success') {
|
||||
MessagePlugin.success(t('knowledgeEditor.faqImport.importSuccess'))
|
||||
// 清除筛选条件,确保用户能看到所有新导入的数据
|
||||
selectedTagId.value = UNTAGGED_FILTER
|
||||
selectedTagId.value = ''
|
||||
entrySearchKeyword.value = ''
|
||||
overallFAQTotal.value = 0 // Reset to trigger re-fetch
|
||||
await loadEntries()
|
||||
@@ -2610,7 +2590,7 @@ watch(
|
||||
async (newKbId) => {
|
||||
currentPage = 1
|
||||
hasMore.value = true
|
||||
selectedTagId.value = UNTAGGED_FILTER
|
||||
selectedTagId.value = ''
|
||||
overallFAQTotal.value = 0 // Reset to trigger re-fetch
|
||||
cancelCreateTag()
|
||||
cancelEditTag()
|
||||
|
||||
Reference in New Issue
Block a user