feat(frontend): redesign tag sidebar chips and tag edit dialog
Compact chip sidebar with single-select filter, document counts, context-menu actions, and refreshed TagEditDialog with selected/available sections. Add i18n, component tests, and exclude soft-deleted rows from multi-tag migration backfill.
This commit is contained in:
@@ -370,8 +370,13 @@ export default {
|
|||||||
publishToWeb: 'Publish to Web',
|
publishToWeb: 'Publish to Web',
|
||||||
documentCategoryTitle: 'Document Categories',
|
documentCategoryTitle: 'Document Categories',
|
||||||
tagUpdateSuccess: 'Tag updated successfully',
|
tagUpdateSuccess: 'Tag updated successfully',
|
||||||
|
tagEditDialogHeading: 'Edit tags',
|
||||||
tagEditDialogTitle: 'Edit Tags — {name}',
|
tagEditDialogTitle: 'Edit Tags — {name}',
|
||||||
tagEditSearch: 'Search tags...',
|
tagEditSearch: 'Search tags...',
|
||||||
|
tagEditSelectedSection: 'Selected',
|
||||||
|
tagEditAvailableSection: 'Available',
|
||||||
|
tagEditNoSelected: 'None selected',
|
||||||
|
tagFilterAll: 'All documents',
|
||||||
tagSelectedCount: '{count} selected',
|
tagSelectedCount: '{count} selected',
|
||||||
tagOverflowTip: 'Click to edit tags',
|
tagOverflowTip: 'Click to edit tags',
|
||||||
tagNewPlaceholder: 'New tag name, press Enter to add',
|
tagNewPlaceholder: 'New tag name, press Enter to add',
|
||||||
|
|||||||
@@ -372,8 +372,13 @@ export default {
|
|||||||
untagged: "미분류",
|
untagged: "미분류",
|
||||||
tagClearAction: "분류 해제",
|
tagClearAction: "분류 해제",
|
||||||
tagUpdateSuccess: "태그 업데이트 성공",
|
tagUpdateSuccess: "태그 업데이트 성공",
|
||||||
|
tagEditDialogHeading: "태그 편집",
|
||||||
tagEditDialogTitle: '태그 편집 — {name}',
|
tagEditDialogTitle: '태그 편집 — {name}',
|
||||||
tagEditSearch: '태그 검색...',
|
tagEditSearch: '태그 검색...',
|
||||||
|
tagEditSelectedSection: '선택된 태그',
|
||||||
|
tagEditAvailableSection: '선택 가능',
|
||||||
|
tagEditNoSelected: '선택 없음',
|
||||||
|
tagFilterAll: '전체 문서',
|
||||||
tagSelectedCount: '{count}개 선택됨',
|
tagSelectedCount: '{count}개 선택됨',
|
||||||
tagOverflowTip: '클릭하여 태그 편집',
|
tagOverflowTip: '클릭하여 태그 편집',
|
||||||
tagNewPlaceholder: '새 태그 이름 입력, Enter로 추가',
|
tagNewPlaceholder: '새 태그 이름 입력, Enter로 추가',
|
||||||
|
|||||||
@@ -313,8 +313,13 @@ export default {
|
|||||||
tagClearAction: 'Снять категорию',
|
tagClearAction: 'Снять категорию',
|
||||||
tagSearchTooltip: 'Поиск тегов',
|
tagSearchTooltip: 'Поиск тегов',
|
||||||
tagUpdateSuccess: 'Тег успешно обновлен',
|
tagUpdateSuccess: 'Тег успешно обновлен',
|
||||||
|
tagEditDialogHeading: 'Редактировать теги',
|
||||||
tagEditDialogTitle: 'Редактировать теги — {name}',
|
tagEditDialogTitle: 'Редактировать теги — {name}',
|
||||||
tagEditSearch: 'Поиск тегов...',
|
tagEditSearch: 'Поиск тегов...',
|
||||||
|
tagEditSelectedSection: 'Выбранные',
|
||||||
|
tagEditAvailableSection: 'Доступные',
|
||||||
|
tagEditNoSelected: 'Ничего не выбрано',
|
||||||
|
tagFilterAll: 'Все документы',
|
||||||
tagSelectedCount: 'Выбрано: {count}',
|
tagSelectedCount: 'Выбрано: {count}',
|
||||||
tagOverflowTip: 'Нажмите, чтобы изменить теги',
|
tagOverflowTip: 'Нажмите, чтобы изменить теги',
|
||||||
tagNewPlaceholder: 'Название нового тега, Enter для добавления',
|
tagNewPlaceholder: 'Название нового тега, Enter для добавления',
|
||||||
|
|||||||
@@ -373,8 +373,13 @@ export default {
|
|||||||
untagged: "未分类",
|
untagged: "未分类",
|
||||||
tagClearAction: "取消分类",
|
tagClearAction: "取消分类",
|
||||||
tagUpdateSuccess: "标签更新成功",
|
tagUpdateSuccess: "标签更新成功",
|
||||||
|
tagEditDialogHeading: "编辑标签",
|
||||||
tagEditDialogTitle: '编辑标签 — {name}',
|
tagEditDialogTitle: '编辑标签 — {name}',
|
||||||
tagEditSearch: "搜索标签...",
|
tagEditSearch: "搜索标签...",
|
||||||
|
tagEditSelectedSection: "已选标签",
|
||||||
|
tagEditAvailableSection: "可选标签",
|
||||||
|
tagEditNoSelected: "暂未选择",
|
||||||
|
tagFilterAll: "全部文档",
|
||||||
tagSelectedCount: "已选 {count} 个标签",
|
tagSelectedCount: "已选 {count} 个标签",
|
||||||
tagOverflowTip: "点击编辑标签",
|
tagOverflowTip: "点击编辑标签",
|
||||||
tagNewPlaceholder: "输入新标签名称,回车添加",
|
tagNewPlaceholder: "输入新标签名称,回车添加",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import DocumentListView from './components/DocumentListView.vue';
|
|||||||
import DocumentBatchBar from './components/DocumentBatchBar.vue';
|
import DocumentBatchBar from './components/DocumentBatchBar.vue';
|
||||||
import KbUploadSourceDropdown from './components/KbUploadSourceDropdown.vue';
|
import KbUploadSourceDropdown from './components/KbUploadSourceDropdown.vue';
|
||||||
import TagEditDialog from './components/TagEditDialog.vue';
|
import TagEditDialog from './components/TagEditDialog.vue';
|
||||||
|
import { useTagChipsOverflow } from '@/composables/useTagChipsOverflow';
|
||||||
import type { KnowledgeProcessOverrides } from '@/types/knowledgeProcess';
|
import type { KnowledgeProcessOverrides } from '@/types/knowledgeProcess';
|
||||||
import { useUploadConfirmStore, type UploadConfirmResult } from '@/stores/uploadConfirm';
|
import { useUploadConfirmStore, type UploadConfirmResult } from '@/stores/uploadConfirm';
|
||||||
import WikiBrowser from './wiki/WikiBrowser.vue';
|
import WikiBrowser from './wiki/WikiBrowser.vue';
|
||||||
@@ -567,26 +568,6 @@ const filterParams = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
type TagInputInstance = ComponentPublicInstance<{ focus: () => void; select: () => void }>;
|
type TagInputInstance = ComponentPublicInstance<{ focus: () => void; select: () => void }>;
|
||||||
const onPickTag = (item: any, tagId: string | number) => {
|
|
||||||
if (item) item.isTagPopup = false;
|
|
||||||
const currentTags = item?.tags || [];
|
|
||||||
const tagIdStr = tagId ? String(tagId) : '';
|
|
||||||
let updatedTags: string[];
|
|
||||||
if (!tagIdStr) {
|
|
||||||
// Clear all tags
|
|
||||||
updatedTags = [];
|
|
||||||
} else {
|
|
||||||
const idx = currentTags.findIndex((t: any) => t.id === tagIdStr);
|
|
||||||
if (idx >= 0) {
|
|
||||||
// Remove tag
|
|
||||||
updatedTags = currentTags.filter((t: any) => t.id !== tagIdStr).map((t: any) => t.id);
|
|
||||||
} else {
|
|
||||||
// Add tag
|
|
||||||
updatedTags = [...currentTags.map((t: any) => t.id), tagIdStr];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handleKnowledgeTagChange(item.id, updatedTags);
|
|
||||||
};
|
|
||||||
const tagMap = computed<Record<string, any>>(() => {
|
const tagMap = computed<Record<string, any>>(() => {
|
||||||
const map: Record<string, any> = {};
|
const map: Record<string, any> = {};
|
||||||
tagList.value.forEach((tag) => {
|
tagList.value.forEach((tag) => {
|
||||||
@@ -594,13 +575,30 @@ const tagMap = computed<Record<string, any>>(() => {
|
|||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
const sidebarCategoryCount = computed(() => tagList.value.length);
|
const sidebarCategoryCount = computed(() => tagTotal.value || tagList.value.length);
|
||||||
const filteredTags = computed(() => {
|
const sidebarTags = computed(() => {
|
||||||
const query = tagSearchQuery.value.trim().toLowerCase();
|
const list = tagList.value;
|
||||||
if (!query) return tagList.value;
|
const selectedId = selectedTagIds.value[0];
|
||||||
return tagList.value.filter((tag) => (tag.name || '').toLowerCase().includes(query));
|
if (!selectedId || list.some((tag) => tag.id === selectedId)) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
const selected = tagMap.value[selectedId];
|
||||||
|
return selected ? [selected, ...list] : list;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const tagChipMenuOptions = computed(() => [
|
||||||
|
{ content: t('knowledgeBase.tagEditAction'), value: 'edit' },
|
||||||
|
{ content: t('knowledgeBase.tagDeleteAction'), value: 'delete', theme: 'error' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const handleTagChipMenu = (data: { value: string }, tag: any) => {
|
||||||
|
if (data.value === 'edit') {
|
||||||
|
startEditTag(tag);
|
||||||
|
} else if (data.value === 'delete') {
|
||||||
|
confirmDeleteTag(tag);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const editingTagInputRefs = new Map<string, TagInputInstance | null>();
|
const editingTagInputRefs = new Map<string, TagInputInstance | null>();
|
||||||
const setEditingTagInputRef = (el: TagInputInstance | null, tagId: string) => {
|
const setEditingTagInputRef = (el: TagInputInstance | null, tagId: string) => {
|
||||||
if (el) {
|
if (el) {
|
||||||
@@ -623,59 +621,12 @@ const editingTagSubmitting = ref(false);
|
|||||||
const tagEditDialogVisible = ref(false);
|
const tagEditDialogVisible = ref(false);
|
||||||
const tagEditTarget = ref<KnowledgeCard | null>(null);
|
const tagEditTarget = ref<KnowledgeCard | null>(null);
|
||||||
|
|
||||||
// 动态标签可见数量(根据卡片容器宽度自适应)
|
const {
|
||||||
const TAG_EST_WIDTH = 82; // 单个标签估算宽度(含间距)
|
setupTagChipsObserver,
|
||||||
const TAG_OVERFLOW_MIN = 32; // +N 徽章预留宽度
|
getTagLimit,
|
||||||
const tagVisibleLimit = reactive<Record<string, number>>({});
|
hasTagOverflow,
|
||||||
const tagItemTotalMap = new Map<string, number>();
|
getOverflowCount,
|
||||||
let tagChipsRO: ResizeObserver | null = null;
|
} = useTagChipsOverflow('tagItemId');
|
||||||
|
|
||||||
function setupTagChipsObserver(el: Element | null, itemId: string, totalCount: number) {
|
|
||||||
if (!el) return;
|
|
||||||
const htmlEl = el as HTMLElement;
|
|
||||||
htmlEl.dataset.tagItemId = itemId;
|
|
||||||
tagItemTotalMap.set(itemId, totalCount);
|
|
||||||
if (!tagChipsRO) {
|
|
||||||
tagChipsRO = new ResizeObserver((entries) => {
|
|
||||||
for (const entry of entries) {
|
|
||||||
const target = entry.target as HTMLElement;
|
|
||||||
const id = target.dataset.tagItemId;
|
|
||||||
if (!id) continue;
|
|
||||||
const w = entry.contentRect.width;
|
|
||||||
const total = tagItemTotalMap.get(id) ?? 0;
|
|
||||||
if (total <= 0) { tagVisibleLimit[id] = 99; continue; }
|
|
||||||
// 计算能容纳几个标签:总宽 - 溢出徽章预留,除以单标签宽
|
|
||||||
const maxFit = Math.floor((w - TAG_OVERFLOW_MIN) / TAG_EST_WIDTH);
|
|
||||||
const limit = Math.max(1, Math.min(maxFit, total));
|
|
||||||
tagVisibleLimit[id] = limit >= total ? 99 : limit;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
tagChipsRO.observe(htmlEl);
|
|
||||||
// 初始计算
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
const w = htmlEl.clientWidth;
|
|
||||||
const total = totalCount;
|
|
||||||
if (total <= 0) { tagVisibleLimit[itemId] = 99; return; }
|
|
||||||
const maxFit = Math.floor((w - TAG_OVERFLOW_MIN) / TAG_EST_WIDTH);
|
|
||||||
const limit = Math.max(1, Math.min(maxFit, total));
|
|
||||||
tagVisibleLimit[itemId] = limit >= total ? 99 : limit;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTagLimit(itemId: string): number {
|
|
||||||
return tagVisibleLimit[itemId] ?? 99;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasTagOverflow(itemId: string, total: number): boolean {
|
|
||||||
const limit = tagVisibleLimit[itemId] ?? 99;
|
|
||||||
return total > limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getOverflowCount(itemId: string, total: number): number {
|
|
||||||
const limit = tagVisibleLimit[itemId] ?? 99;
|
|
||||||
return Math.max(0, total - limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openTagEditDialog(item: KnowledgeCard) {
|
function openTagEditDialog(item: KnowledgeCard) {
|
||||||
tagEditTarget.value = item;
|
tagEditTarget.value = item;
|
||||||
@@ -819,7 +770,6 @@ const handleTagFilterChange = (tagIds: string[]) => {
|
|||||||
uiStore.clearSelectedTagIds();
|
uiStore.clearSelectedTagIds();
|
||||||
tagIds.forEach(id => uiStore.toggleSelectedTagId(id));
|
tagIds.forEach(id => uiStore.toggleSelectedTagId(id));
|
||||||
resetPage();
|
resetPage();
|
||||||
loadKnowledgeFiles(kbId.value);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTagRowClick = (tagId: string) => {
|
const handleTagRowClick = (tagId: string) => {
|
||||||
@@ -831,14 +781,22 @@ const handleTagRowClick = (tagId: string) => {
|
|||||||
editingTagId.value = null;
|
editingTagId.value = null;
|
||||||
editingTagName.value = '';
|
editingTagName.value = '';
|
||||||
}
|
}
|
||||||
// Toggle selection
|
const next = selectedTagIds.value.length === 1 && selectedTagIds.value[0] === tagId
|
||||||
const idx = selectedTagIds.value.indexOf(tagId);
|
? []
|
||||||
if (idx >= 0) {
|
: [tagId];
|
||||||
selectedTagIds.value.splice(idx, 1);
|
handleTagFilterChange(next);
|
||||||
} else {
|
};
|
||||||
selectedTagIds.value.push(tagId);
|
|
||||||
|
const clearTagFilter = () => {
|
||||||
|
if (creatingTag.value) {
|
||||||
|
creatingTag.value = false;
|
||||||
|
newTagName.value = '';
|
||||||
}
|
}
|
||||||
handleTagFilterChange([...selectedTagIds.value]);
|
if (editingTagId.value) {
|
||||||
|
editingTagId.value = null;
|
||||||
|
editingTagName.value = '';
|
||||||
|
}
|
||||||
|
handleTagFilterChange([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const startCreateTag = () => {
|
const startCreateTag = () => {
|
||||||
@@ -954,15 +912,13 @@ const confirmDeleteTag = (tag: any) => {
|
|||||||
handleTagFilterChange([...selectedTagIds.value]);
|
handleTagFilterChange([...selectedTagIds.value]);
|
||||||
}
|
}
|
||||||
loadTags(kbId.value, true);
|
loadTags(kbId.value, true);
|
||||||
// 由于后端是异步删除文档,延迟刷新文档列表
|
void (async () => {
|
||||||
setTimeout(() => {
|
await new Promise((resolve) => setTimeout(resolve, 800));
|
||||||
resetPage(); // Reset page counter when reloading files after tag deletion
|
if (!kbId.value) return;
|
||||||
loadKnowledgeFiles(kbId.value);
|
resetPage();
|
||||||
}, 800);
|
await loadKnowledgeFiles(kbId.value);
|
||||||
// 再次延迟刷新标签列表,确保异步删除完成后其他标签的数量正确更新
|
await loadTags(kbId.value, true);
|
||||||
setTimeout(() => {
|
})();
|
||||||
loadTags(kbId.value, true);
|
|
||||||
}, 2500);
|
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
MessagePlugin.error(error?.message || t('common.operationFailed'));
|
MessagePlugin.error(error?.message || t('common.operationFailed'));
|
||||||
@@ -1083,11 +1039,11 @@ watch(() => kbId.value, (newKbId, oldKbId) => {
|
|||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
watch(selectedTagIds, (newVal, oldVal) => {
|
watch(selectedTagIds, (newVal, oldVal) => {
|
||||||
if (oldVal === undefined) return
|
if (oldVal === undefined) return;
|
||||||
if (kbId.value) {
|
if (kbId.value) {
|
||||||
loadKnowledgeFiles(kbId.value);
|
loadKnowledgeFiles(kbId.value);
|
||||||
}
|
}
|
||||||
});
|
}, { deep: true });
|
||||||
|
|
||||||
watch(tagSearchQuery, (newVal, oldVal) => {
|
watch(tagSearchQuery, (newVal, oldVal) => {
|
||||||
if (newVal === oldVal) return;
|
if (newVal === oldVal) return;
|
||||||
@@ -2279,93 +2235,74 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
</template>
|
</template>
|
||||||
</t-input>
|
</t-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="tag-list">
|
<div class="tag-sidebar-body">
|
||||||
<template v-if="tagLoading && !filteredTags.length">
|
<template v-if="tagLoading && !sidebarTags.length">
|
||||||
<div v-for="n in 8" :key="'skel-tag-' + n" class="tag-list-item"
|
<div class="tag-sidebar-chips">
|
||||||
style="cursor: default; pointer-events: none;">
|
<div v-for="n in 6" :key="'skel-tag-' + n" class="tag-sidebar-chip-skeleton">
|
||||||
<div class="tag-list-left" style="gap: 12px; width: 100%;">
|
<t-skeleton animation="gradient" :row-col="[{ width: '52px', height: '26px', type: 'rect' }]" />
|
||||||
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '18px' }]" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div v-if="creatingTag" class="tag-list-item tag-editing" @click.stop>
|
<div class="tag-sidebar-chips">
|
||||||
<div class="tag-list-left">
|
<button type="button" class="tag-sidebar-chip" :class="{ active: selectedTagIds.length === 0 }"
|
||||||
<span class="tag-hash-icon">#</span>
|
@click="clearTagFilter">
|
||||||
|
{{ $t('knowledgeBase.tagFilterAll') }}
|
||||||
|
</button>
|
||||||
|
<template v-for="tag in sidebarTags" :key="tag.id">
|
||||||
|
<div v-if="editingTagId === tag.id" class="tag-sidebar-edit-row" @click.stop>
|
||||||
|
<div class="tag-edit-input">
|
||||||
|
<t-input :ref="setEditingTagInputRefByTag(tag.id)" v-model="editingTagName" size="small"
|
||||||
|
:maxlength="40" @enter="submitEditTag"
|
||||||
|
@keydown="(_v, ctx) => { if (ctx?.e?.key === 'Escape') { ctx.e.stopPropagation(); ctx.e.preventDefault(); cancelEditTag() } }" />
|
||||||
|
</div>
|
||||||
|
<div class="tag-inline-actions">
|
||||||
|
<t-button variant="text" theme="default" size="small" class="tag-action-btn confirm"
|
||||||
|
:loading="editingTagSubmitting" @click.stop="submitEditTag">
|
||||||
|
<t-icon name="check" size="14px" />
|
||||||
|
</t-button>
|
||||||
|
<t-button variant="text" theme="default" size="small" class="tag-action-btn cancel"
|
||||||
|
@click.stop="cancelEditTag">
|
||||||
|
<t-icon name="close" size="14px" />
|
||||||
|
</t-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<t-dropdown v-else-if="canEdit" trigger="context-menu" placement="bottom-left"
|
||||||
|
:options="tagChipMenuOptions" @click="(data: any) => handleTagChipMenu(data, tag)">
|
||||||
|
<button type="button" class="tag-sidebar-chip"
|
||||||
|
:class="{ active: selectedTagIds.length === 1 && selectedTagIds[0] === tag.id }"
|
||||||
|
@click="handleTagRowClick(tag.id)">
|
||||||
|
<span class="tag-chip-label">{{ tag.name }}</span>
|
||||||
|
<span class="tag-chip-count">({{ tag.knowledge_count || 0 }})</span>
|
||||||
|
</button>
|
||||||
|
</t-dropdown>
|
||||||
|
<button v-else type="button" class="tag-sidebar-chip"
|
||||||
|
:class="{ active: selectedTagIds.length === 1 && selectedTagIds[0] === tag.id }"
|
||||||
|
@click="handleTagRowClick(tag.id)">
|
||||||
|
<span class="tag-chip-label">{{ tag.name }}</span>
|
||||||
|
<span class="tag-chip-count">({{ tag.knowledge_count || 0 }})</span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
<div v-if="creatingTag" class="tag-sidebar-create-row" @click.stop>
|
||||||
<div class="tag-edit-input">
|
<div class="tag-edit-input">
|
||||||
<t-input ref="newTagInputRef" v-model="newTagName" size="small" :maxlength="40"
|
<t-input ref="newTagInputRef" v-model="newTagName" size="small" :maxlength="40"
|
||||||
:placeholder="$t('knowledgeBase.tagNamePlaceholder')" @enter="submitCreateTag"
|
:placeholder="$t('knowledgeBase.tagNamePlaceholder')" @enter="submitCreateTag"
|
||||||
@keydown="(_v, ctx) => { if (ctx?.e?.key === 'Escape') { ctx.e.stopPropagation(); ctx.e.preventDefault(); cancelCreateTag() } }" />
|
@keydown="(_v, ctx) => { if (ctx?.e?.key === 'Escape') { ctx.e.stopPropagation(); ctx.e.preventDefault(); cancelCreateTag() } }" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="tag-inline-actions">
|
<div class="tag-inline-actions">
|
||||||
<t-button variant="text" theme="default" size="small" class="tag-action-btn confirm"
|
<t-button variant="text" theme="default" size="small" class="tag-action-btn confirm"
|
||||||
:loading="creatingTagLoading" @click.stop="submitCreateTag">
|
:loading="creatingTagLoading" @click.stop="submitCreateTag">
|
||||||
<t-icon name="check" size="16px" />
|
<t-icon name="check" size="14px" />
|
||||||
</t-button>
|
</t-button>
|
||||||
<t-button variant="text" theme="default" size="small" class="tag-action-btn cancel"
|
<t-button variant="text" theme="default" size="small" class="tag-action-btn cancel"
|
||||||
@click.stop="cancelCreateTag">
|
@click.stop="cancelCreateTag">
|
||||||
<t-icon name="close" size="16px" />
|
<t-icon name="close" size="14px" />
|
||||||
</t-button>
|
</t-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<template v-if="filteredTags.length">
|
<div v-if="!creatingTag && !sidebarTags.length" class="tag-empty-state">
|
||||||
<div v-for="tag in filteredTags" :key="tag.id" class="tag-list-item"
|
|
||||||
:class="{ active: selectedTagIds.includes(tag.id), editing: editingTagId === tag.id }"
|
|
||||||
@click="handleTagRowClick(tag.id)">
|
|
||||||
<div class="tag-list-left">
|
|
||||||
<span class="tag-hash-icon">#</span>
|
|
||||||
<template v-if="editingTagId === tag.id">
|
|
||||||
<div class="tag-edit-input" @click.stop>
|
|
||||||
<t-input :ref="setEditingTagInputRefByTag(tag.id)" v-model="editingTagName" size="small"
|
|
||||||
:maxlength="40" @enter="submitEditTag"
|
|
||||||
@keydown="(_v, ctx) => { if (ctx?.e?.key === 'Escape') { ctx.e.stopPropagation(); ctx.e.preventDefault(); cancelEditTag() } }" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span class="tag-name" :title="tag.name">{{ tag.name }}</span>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
<div class="tag-list-right">
|
|
||||||
<span class="tag-count">{{ tag.knowledge_count || 0 }}</span>
|
|
||||||
<template v-if="editingTagId === tag.id">
|
|
||||||
<div class="tag-inline-actions" @click.stop>
|
|
||||||
<t-button variant="text" theme="default" size="small" class="tag-action-btn confirm"
|
|
||||||
:loading="editingTagSubmitting" @click.stop="submitEditTag">
|
|
||||||
<t-icon name="check" size="16px" />
|
|
||||||
</t-button>
|
|
||||||
<t-button variant="text" theme="default" size="small" class="tag-action-btn cancel"
|
|
||||||
@click.stop="cancelEditTag">
|
|
||||||
<t-icon name="close" size="16px" />
|
|
||||||
</t-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<div v-if="canEdit" class="tag-more" @click.stop>
|
|
||||||
<t-popup trigger="click" placement="top-right" overlayClassName="tag-more-popup">
|
|
||||||
<div class="tag-more-btn">
|
|
||||||
<t-icon name="more" size="14px" />
|
|
||||||
</div>
|
|
||||||
<template #content>
|
|
||||||
<div class="tag-menu">
|
|
||||||
<div class="tag-menu-item" @click="startEditTag(tag)">
|
|
||||||
<t-icon class="menu-icon" name="edit" />
|
|
||||||
<span>{{ $t('knowledgeBase.tagEditAction') }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="tag-menu-item danger" @click="confirmDeleteTag(tag)">
|
|
||||||
<t-icon class="menu-icon" name="delete" />
|
|
||||||
<span>{{ $t('knowledgeBase.tagDeleteAction') }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</t-popup>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div v-else class="tag-empty-state">
|
|
||||||
{{ $t('knowledgeBase.tagEmptyResult') }}
|
{{ $t('knowledgeBase.tagEmptyResult') }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="tagHasMore" class="tag-load-more">
|
<div v-if="tagHasMore" class="tag-load-more">
|
||||||
@@ -2626,41 +2563,24 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
<!-- 可编辑模式:点击打开弹窗 -->
|
<!-- 可编辑模式:点击打开弹窗 -->
|
||||||
<template v-if="canEdit">
|
<template v-if="canEdit">
|
||||||
<template v-if="(item.tags || []).length > 0">
|
<template v-if="(item.tags || []).length > 0">
|
||||||
<t-tooltip
|
<t-tooltip v-if="hasTagOverflow(item.id, (item.tags || []).length)"
|
||||||
v-if="hasTagOverflow(item.id, (item.tags || []).length)"
|
:content="(item.tags || []).map((t: any) => t.name).join(', ')" placement="top">
|
||||||
:content="(item.tags || []).map((t: any) => t.name).join(', ')"
|
<div class="card-tag-chips"
|
||||||
placement="top"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="card-tag-chips"
|
|
||||||
:ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
|
:ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
|
||||||
@click="openTagEditDialog(item)"
|
@click="openTagEditDialog(item)">
|
||||||
>
|
<t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id"
|
||||||
<t-tag
|
size="small" variant="light-outline" class="card-tag-chip">
|
||||||
v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))"
|
|
||||||
:key="tag.id"
|
|
||||||
size="small"
|
|
||||||
variant="light-outline"
|
|
||||||
class="card-tag-chip"
|
|
||||||
>
|
|
||||||
<span class="tag-text">{{ tag.name }}</span>
|
<span class="tag-text">{{ tag.name }}</span>
|
||||||
</t-tag>
|
</t-tag>
|
||||||
<span class="card-tag-overflow">+{{ getOverflowCount(item.id, (item.tags || []).length) }}</span>
|
<span class="card-tag-overflow">+{{ getOverflowCount(item.id, (item.tags ||
|
||||||
|
[]).length) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</t-tooltip>
|
</t-tooltip>
|
||||||
<div
|
<div v-else class="card-tag-chips"
|
||||||
v-else
|
|
||||||
class="card-tag-chips"
|
|
||||||
:ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
|
:ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
|
||||||
@click="openTagEditDialog(item)"
|
@click="openTagEditDialog(item)">
|
||||||
>
|
<t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id"
|
||||||
<t-tag
|
size="small" variant="light-outline" class="card-tag-chip">
|
||||||
v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))"
|
|
||||||
:key="tag.id"
|
|
||||||
size="small"
|
|
||||||
variant="light-outline"
|
|
||||||
class="card-tag-chip"
|
|
||||||
>
|
|
||||||
<span class="tag-text">{{ tag.name }}</span>
|
<span class="tag-text">{{ tag.name }}</span>
|
||||||
</t-tag>
|
</t-tag>
|
||||||
</div>
|
</div>
|
||||||
@@ -2672,39 +2592,22 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
</template>
|
</template>
|
||||||
<!-- 只读模式 -->
|
<!-- 只读模式 -->
|
||||||
<template v-else-if="(item.tags || []).length > 0">
|
<template v-else-if="(item.tags || []).length > 0">
|
||||||
<t-tooltip
|
<t-tooltip v-if="hasTagOverflow(item.id, (item.tags || []).length)"
|
||||||
v-if="hasTagOverflow(item.id, (item.tags || []).length)"
|
:content="(item.tags || []).map((t: any) => t.name).join(', ')" placement="top">
|
||||||
:content="(item.tags || []).map((t: any) => t.name).join(', ')"
|
<div class="card-tag-chips"
|
||||||
placement="top"
|
:ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)">
|
||||||
>
|
<t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id"
|
||||||
<div
|
size="small" variant="light-outline" class="card-tag-chip">
|
||||||
class="card-tag-chips"
|
|
||||||
:ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
|
|
||||||
>
|
|
||||||
<t-tag
|
|
||||||
v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))"
|
|
||||||
:key="tag.id"
|
|
||||||
size="small"
|
|
||||||
variant="light-outline"
|
|
||||||
class="card-tag-chip"
|
|
||||||
>
|
|
||||||
<span class="tag-text">{{ tag.name }}</span>
|
<span class="tag-text">{{ tag.name }}</span>
|
||||||
</t-tag>
|
</t-tag>
|
||||||
<span class="card-tag-overflow">+{{ getOverflowCount(item.id, (item.tags || []).length) }}</span>
|
<span class="card-tag-overflow">+{{ getOverflowCount(item.id, (item.tags ||
|
||||||
|
[]).length) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</t-tooltip>
|
</t-tooltip>
|
||||||
<div
|
<div v-else class="card-tag-chips"
|
||||||
v-else
|
:ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)">
|
||||||
class="card-tag-chips"
|
<t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id"
|
||||||
:ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
|
size="small" variant="light-outline" class="card-tag-chip">
|
||||||
>
|
|
||||||
<t-tag
|
|
||||||
v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))"
|
|
||||||
:key="tag.id"
|
|
||||||
size="small"
|
|
||||||
variant="light-outline"
|
|
||||||
class="card-tag-chip"
|
|
||||||
>
|
|
||||||
<span class="tag-text">{{ tag.name }}</span>
|
<span class="tag-text">{{ tag.name }}</span>
|
||||||
</t-tag>
|
</t-tag>
|
||||||
</div>
|
</div>
|
||||||
@@ -2757,7 +2660,8 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
}}</span>
|
}}</span>
|
||||||
<span v-if="(hoveredCardItem as any).channel && (hoveredCardItem as any).channel !== 'web'"
|
<span v-if="(hoveredCardItem as any).channel && (hoveredCardItem as any).channel !== 'web'"
|
||||||
class="card-popover-channel">{{ getChannelLabel((hoveredCardItem as any).channel) }}</span>
|
class="card-popover-channel">{{ getChannelLabel((hoveredCardItem as any).channel) }}</span>
|
||||||
<span v-if="(hoveredCardItem as any).tags && (hoveredCardItem as any).tags.length > 0" class="card-popover-tag">{{
|
<span v-if="(hoveredCardItem as any).tags && (hoveredCardItem as any).tags.length > 0"
|
||||||
|
class="card-popover-tag">{{
|
||||||
(hoveredCardItem as any).tags.map((t: any) => t.name).join(', ')
|
(hoveredCardItem as any).tags.map((t: any) => t.name).join(', ')
|
||||||
}}</span>
|
}}</span>
|
||||||
<span class="card-popover-type">{{ getKnowledgeType(hoveredCardItem) }}</span>
|
<span class="card-popover-type">{{ getKnowledgeType(hoveredCardItem) }}</span>
|
||||||
@@ -2770,8 +2674,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
<template v-else-if="cardList.length && viewMode === 'list'">
|
<template v-else-if="cardList.length && viewMode === 'list'">
|
||||||
<DocumentListView :items="cardList" :selected-ids="selectedIds" :tag-list="tagList"
|
<DocumentListView :items="cardList" :selected-ids="selectedIds" :tag-list="tagList"
|
||||||
:can-edit="canEdit" @open="(item: any) => openKnowledgeItem(item)" @toggle-row="toggleSelectRow"
|
:can-edit="canEdit" @open="(item: any) => openKnowledgeItem(item)" @toggle-row="toggleSelectRow"
|
||||||
@toggle-all="toggleSelectAll"
|
@toggle-all="toggleSelectAll" @action="(action: any, item: any) => handleListAction(action, item)"
|
||||||
@action="(action: any, item: any) => handleListAction(action, item)"
|
|
||||||
@tag-edit="(item: any) => openTagEditDialog(item)" />
|
@tag-edit="(item: any) => openTagEditDialog(item)" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="!docListLoading">
|
<template v-else-if="!docListLoading">
|
||||||
@@ -2810,16 +2713,10 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
<ContextualGuide tour="kbDetail" :when="showKbDetailContextualGuide" />
|
<ContextualGuide tour="kbDetail" :when="showKbDetailContextualGuide" />
|
||||||
|
|
||||||
<!-- 标签编辑弹窗 -->
|
<!-- 标签编辑弹窗 -->
|
||||||
<TagEditDialog
|
<TagEditDialog :visible="tagEditDialogVisible"
|
||||||
:visible="tagEditDialogVisible"
|
|
||||||
:knowledge-name="tagEditTarget?.display_name || tagEditTarget?.file_name || tagEditTarget?.title || ''"
|
:knowledge-name="tagEditTarget?.display_name || tagEditTarget?.file_name || tagEditTarget?.title || ''"
|
||||||
:kb-id="kbId"
|
:kb-id="kbId" :tag-list="tagList" :selected-tags="tagEditTarget?.tags || []"
|
||||||
:tag-list="tagList"
|
@update:visible="tagEditDialogVisible = $event" @confirm="onTagEditConfirm" @tag-created="loadTags(kbId, true)" />
|
||||||
:selected-tags="tagEditTarget?.tags || []"
|
|
||||||
@update:visible="tagEditDialogVisible = $event"
|
|
||||||
@confirm="onTagEditConfirm"
|
|
||||||
@tag-created="loadTags(kbId, true)"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
<style>
|
<style>
|
||||||
/* 下拉菜单容器样式已统一至 @/assets/dropdown-menu.less */
|
/* 下拉菜单容器样式已统一至 @/assets/dropdown-menu.less */
|
||||||
@@ -2898,7 +2795,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
border: none;
|
border: none;
|
||||||
border-right: 1px solid var(--td-component-stroke);
|
border-right: 1px solid var(--td-component-stroke);
|
||||||
box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
|
box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
|
||||||
padding: 0 16px 0 0;
|
padding: 0 16px 0 4px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@@ -2910,7 +2807,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
padding: 0 4px;
|
padding: 0;
|
||||||
color: var(--td-text-color-primary);
|
color: var(--td-text-color-primary);
|
||||||
|
|
||||||
.sidebar-title {
|
.sidebar-title {
|
||||||
@@ -2950,7 +2847,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--td-bg-color-secondarycontainer);
|
background: var(--td-bg-color-secondarycontainer);
|
||||||
color: var(--td-brand-color);
|
color: var(--td-text-color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2958,7 +2855,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
|
|
||||||
.tag-search-bar {
|
.tag-search-bar {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
padding: 0 4px;
|
padding: 0;
|
||||||
|
|
||||||
:deep(.t-input) {
|
:deep(.t-input) {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@@ -2970,209 +2867,145 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
&:hover,
|
&:hover,
|
||||||
&:focus,
|
&:focus,
|
||||||
&.t-is-focused {
|
&.t-is-focused {
|
||||||
border-color: var(--td-brand-color);
|
border-color: var(--td-component-border);
|
||||||
background-color: var(--td-bg-color-container);
|
background-color: var(--td-bg-color-container);
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.t-input__inner) {
|
||||||
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-list {
|
:deep(.t-input__prefix-icon) {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-sidebar-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 5px;
|
gap: 8px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
scrollbar-width: none;
|
scrollbar-width: thin;
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
display: none;
|
width: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-load-more {
|
&::-webkit-scrollbar-thumb {
|
||||||
padding: 8px 0 0;
|
border-radius: 2px;
|
||||||
|
background: var(--td-scrollbar-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-sidebar-chips {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
:deep(.t-button) {
|
align-content: flex-start;
|
||||||
padding: 0;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--td-success-color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-list-item {
|
.tag-sidebar-chip-skeleton {
|
||||||
display: flex;
|
height: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-sidebar-chip {
|
||||||
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: center;
|
||||||
padding: 8px 8px;
|
gap: 4px;
|
||||||
border-radius: 6px;
|
box-sizing: border-box;
|
||||||
color: var(--td-text-color-primary);
|
flex-shrink: 0;
|
||||||
cursor: pointer;
|
max-width: 100%;
|
||||||
transition: all 0.2s ease;
|
height: 26px;
|
||||||
|
padding: 0 8px;
|
||||||
|
border: 1px solid var(--td-component-stroke);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
font-family: var(--app-font-family);
|
font-family: var(--app-font-family);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 26px;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
|
|
||||||
.tag-list-left {
|
&:hover:not(.active) {
|
||||||
display: flex;
|
background: color-mix(in srgb, var(--td-bg-color-secondarycontainer) 45%, transparent);
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
min-width: 0;
|
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
.t-icon,
|
|
||||||
.tag-hash-icon {
|
|
||||||
flex-shrink: 0;
|
|
||||||
color: var(--td-text-color-secondary);
|
|
||||||
transition: color 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.t-icon {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-hash-icon {
|
|
||||||
font-family: var(--app-font-family-mono);
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 500;
|
|
||||||
width: 16px;
|
|
||||||
text-align: center;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-name {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
font-family: var(--app-font-family);
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-list-right {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
margin-left: 8px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-count {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--td-text-color-placeholder);
|
|
||||||
font-weight: 400;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
text-align: right;
|
|
||||||
padding-left: 8px;
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: var(--td-bg-color-secondarycontainer);
|
|
||||||
color: var(--td-text-color-primary);
|
|
||||||
|
|
||||||
.tag-list-left .t-icon,
|
|
||||||
.tag-list-left .tag-hash-icon {
|
|
||||||
color: var(--td-text-color-secondary);
|
color: var(--td-text-color-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-count {
|
&:focus-visible {
|
||||||
color: var(--td-text-color-secondary);
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--td-component-stroke) 60%, transparent);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
background: var(--td-brand-color-light);
|
border-color: var(--td-component-stroke);
|
||||||
|
color: var(--td-brand-color);
|
||||||
|
background-color: transparent;
|
||||||
|
background-image: none;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.tag-chip-count {
|
||||||
|
color: color-mix(in srgb, var(--td-brand-color) 72%, var(--td-text-color-secondary));
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border-color: var(--td-component-stroke);
|
||||||
|
background-color: color-mix(in srgb, var(--td-bg-color-secondarycontainer) 45%, transparent);
|
||||||
color: var(--td-brand-color);
|
color: var(--td-brand-color);
|
||||||
|
|
||||||
.tag-list-left .t-icon,
|
.tag-chip-count {
|
||||||
.tag-list-left .tag-hash-icon {
|
color: color-mix(in srgb, var(--td-brand-color) 72%, var(--td-text-color-secondary));
|
||||||
color: var(--td-brand-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-name {
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-count {
|
|
||||||
color: var(--td-brand-color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.editing {
|
.tag-chip-label {
|
||||||
background: transparent;
|
overflow: hidden;
|
||||||
border: none;
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tag-editing {
|
.tag-chip-count {
|
||||||
cursor: default;
|
flex-shrink: 0;
|
||||||
padding-right: 8px;
|
font-size: 12px;
|
||||||
background: transparent;
|
font-variant-numeric: tabular-nums;
|
||||||
border: none;
|
color: var(--td-text-color-placeholder);
|
||||||
|
|
||||||
.tag-edit-input {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tag-editing .tag-edit-input {
|
.tag-sidebar-edit-row,
|
||||||
width: 100%;
|
.tag-sidebar-create-row {
|
||||||
}
|
|
||||||
|
|
||||||
.tag-inline-actions {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
margin-left: auto;
|
width: 100%;
|
||||||
|
min-height: 28px;
|
||||||
:deep(.t-button) {
|
padding: 3px 6px;
|
||||||
padding: 0 4px;
|
border: 1px dashed var(--td-component-stroke);
|
||||||
height: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.tag-action-btn) {
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
transition: all 0.2s ease;
|
box-sizing: border-box;
|
||||||
|
flex: 1 1 100%;
|
||||||
.t-icon {
|
max-width: 100%;
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.tag-action-btn.confirm) {
|
|
||||||
background: transparent;
|
|
||||||
color: var(--td-text-color-secondary);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: var(--td-bg-color-secondarycontainer);
|
|
||||||
color: var(--td-brand-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.tag-action-btn.cancel) {
|
|
||||||
background: transparent;
|
|
||||||
color: var(--td-text-color-secondary);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: var(--td-bg-color-secondarycontainer);
|
|
||||||
color: var(--td-error-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-input {
|
.tag-edit-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
max-width: 100%;
|
|
||||||
|
|
||||||
:deep(.t-input) {
|
:deep(.t-input) {
|
||||||
font-size: 13px;
|
font-size: 12px;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
@@ -3190,7 +3023,6 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
:deep(.t-input__inner) {
|
:deep(.t-input__inner) {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
color: var(--td-text-color-primary);
|
color: var(--td-text-color-primary);
|
||||||
caret-color: var(--td-brand-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.t-input:hover),
|
:deep(.t-input:hover),
|
||||||
@@ -3201,75 +3033,64 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-more {
|
.tag-inline-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
gap: 2px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
:deep(.t-button) {
|
||||||
|
padding: 0 2px;
|
||||||
|
height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-more-btn {
|
:deep(.tag-action-btn) {
|
||||||
width: 22px;
|
|
||||||
height: 22px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
color: var(--td-text-color-placeholder);
|
transition: all 0.15s ease;
|
||||||
transition: all 0.2s ease;
|
|
||||||
|
.t-icon {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.tag-action-btn.confirm) {
|
||||||
|
background: transparent;
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--td-bg-color-secondarycontainer);
|
background: var(--td-bg-color-secondarycontainer);
|
||||||
color: var(--td-text-color-secondary);
|
color: var(--td-text-color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.tag-action-btn.cancel) {
|
||||||
|
background: transparent;
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--td-bg-color-secondarycontainer);
|
||||||
|
color: var(--td-error-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-load-more {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding-top: 2px;
|
||||||
|
|
||||||
|
:deep(.t-button) {
|
||||||
|
padding: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--td-text-color-placeholder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-empty-state {
|
.tag-empty-state {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 10px 6px;
|
padding: 6px 0;
|
||||||
color: var(--td-text-color-placeholder);
|
color: var(--td-text-color-placeholder);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.tag-menu) {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.tag-menu-item) {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 8px 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
color: var(--td-text-color-primary);
|
|
||||||
font-family: var(--app-font-family);
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 400;
|
|
||||||
|
|
||||||
.menu-icon {
|
|
||||||
margin-right: 8px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: var(--td-bg-color-secondarycontainer);
|
|
||||||
color: var(--td-text-color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.danger {
|
|
||||||
color: var(--td-text-color-primary);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: var(--td-error-color-light);
|
|
||||||
color: var(--td-error-color);
|
|
||||||
|
|
||||||
.menu-icon {
|
|
||||||
color: var(--td-error-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-content {
|
.tag-content {
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import test from 'node:test'
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
|
|
||||||
|
const component = readFileSync(new URL('./TagEditDialog.vue', import.meta.url), 'utf8')
|
||||||
|
const zhCN = readFileSync(new URL('../../../i18n/locales/zh-CN.ts', import.meta.url), 'utf8')
|
||||||
|
const enUS = readFileSync(new URL('../../../i18n/locales/en-US.ts', import.meta.url), 'utf8')
|
||||||
|
const koKR = readFileSync(new URL('../../../i18n/locales/ko-KR.ts', import.meta.url), 'utf8')
|
||||||
|
const ruRU = readFileSync(new URL('../../../i18n/locales/ru-RU.ts', import.meta.url), 'utf8')
|
||||||
|
|
||||||
|
test('uses a compact flat dialog with selected and available sections', () => {
|
||||||
|
assert.match(component, /dialog-class-name="tag-edit-dialog"/)
|
||||||
|
assert.match(component, /width="400px"/)
|
||||||
|
assert.match(component, /<template #header>/)
|
||||||
|
assert.match(component, /class="tag-edit-heading-icon"/)
|
||||||
|
assert.match(component, /name="discount"/)
|
||||||
|
assert.match(component, /class="setting-drawer__section"/)
|
||||||
|
assert.match(component, /class="setting-drawer__section-title"/)
|
||||||
|
assert.match(component, /tagEditSelectedSection/)
|
||||||
|
assert.match(component, /tagEditAvailableSection/)
|
||||||
|
assert.match(component, /selectedTagsList/)
|
||||||
|
assert.match(component, /availableTagsList/)
|
||||||
|
assert.match(component, /class="tag-edit-chip"/)
|
||||||
|
assert.match(component, /class="tag-edit-create-row"/)
|
||||||
|
assert.match(component, /class="tag-edit-footer"/)
|
||||||
|
assert.doesNotMatch(component, /class="tag-edit-create"/)
|
||||||
|
assert.doesNotMatch(component, /class="tag-edit-count"/)
|
||||||
|
assert.doesNotMatch(component, /:header="title"/)
|
||||||
|
assert.doesNotMatch(component, /<t-checkbox/)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('defines the short dialog heading in every supported locale', () => {
|
||||||
|
for (const locale of [zhCN, enUS, koKR, ruRU]) {
|
||||||
|
assert.match(locale, /tagEditDialogHeading:/)
|
||||||
|
assert.match(locale, /tagEditSelectedSection:/)
|
||||||
|
assert.match(locale, /tagEditAvailableSection:/)
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,110 +1,67 @@
|
|||||||
<template>
|
<template>
|
||||||
<t-dialog
|
<t-dialog :visible="visible" :footer="false" width="400px" dialog-class-name="tag-edit-dialog"
|
||||||
:visible="visible"
|
:close-on-overlay-click="false" destroy-on-close @close="handleClose">
|
||||||
:header="title"
|
<template #header>
|
||||||
:footer="false"
|
<div class="tag-edit-heading">
|
||||||
width="480px"
|
<div class="tag-edit-heading-row">
|
||||||
:close-on-overlay-click="false"
|
<t-icon name="discount" size="16px" class="tag-edit-heading-icon" aria-hidden="true" />
|
||||||
destroy-on-close
|
<span class="tag-edit-title">{{ $t('knowledgeBase.tagEditDialogHeading') }}</span>
|
||||||
@close="handleClose"
|
|
||||||
>
|
|
||||||
<!-- 搜索框 -->
|
|
||||||
<div class="tag-edit-search">
|
|
||||||
<t-input
|
|
||||||
v-model="searchQuery"
|
|
||||||
:placeholder="$t('knowledgeBase.tagEditSearch')"
|
|
||||||
clearable
|
|
||||||
size="medium"
|
|
||||||
>
|
|
||||||
<template #prefix-icon>
|
|
||||||
<t-icon name="search" />
|
|
||||||
</template>
|
|
||||||
</t-input>
|
|
||||||
</div>
|
</div>
|
||||||
|
<p class="tag-edit-document-name" :title="knowledgeName">{{ knowledgeName }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- 标签列表 -->
|
<div class="tag-edit-body">
|
||||||
<div class="tag-edit-list">
|
<section class="setting-drawer__section">
|
||||||
<template v-if="filteredTags.length > 0">
|
<div class="tag-edit-section-head">
|
||||||
<div
|
<h4 class="setting-drawer__section-title">{{ $t('knowledgeBase.tagEditSelectedSection') }}</h4>
|
||||||
v-for="tag in filteredTags"
|
<t-button v-if="selectedSet.size > 0" variant="text" size="small" theme="default" @click="clearAll">
|
||||||
:key="tag.id"
|
|
||||||
class="tag-edit-item"
|
|
||||||
:class="{ 'is-selected': selectedSet.has(tag.id) }"
|
|
||||||
@click="toggleTag(tag.id)"
|
|
||||||
>
|
|
||||||
<t-checkbox
|
|
||||||
:checked="selectedSet.has(tag.id)"
|
|
||||||
:value="tag.id"
|
|
||||||
@change="toggleTag(tag.id)"
|
|
||||||
@click.stop
|
|
||||||
/>
|
|
||||||
<span class="tag-edit-name">{{ tag.name }}</span>
|
|
||||||
<span v-if="tag.knowledge_count !== undefined" class="tag-edit-count">{{ tag.knowledge_count }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<div class="tag-edit-empty">
|
|
||||||
<template v-if="searchQuery.trim()">
|
|
||||||
<p class="tag-edit-empty-text">{{ $t('knowledgeBase.tagEmptyResult') }}</p>
|
|
||||||
<t-button
|
|
||||||
variant="text"
|
|
||||||
theme="primary"
|
|
||||||
size="small"
|
|
||||||
:loading="creatingTag"
|
|
||||||
@click="handleCreateTag"
|
|
||||||
>
|
|
||||||
<t-icon name="add" />
|
|
||||||
{{ $t('knowledgeBase.tagCreateAction') }} "{{ searchQuery.trim() }}"
|
|
||||||
</t-button>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<p class="tag-edit-empty-text">{{ $t('knowledgeBase.noTags') }}</p>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 新增标签栏 -->
|
|
||||||
<div class="tag-edit-new-bar">
|
|
||||||
<t-input
|
|
||||||
v-model="newTagName"
|
|
||||||
:placeholder="$t('knowledgeBase.tagNewPlaceholder')"
|
|
||||||
size="small"
|
|
||||||
clearable
|
|
||||||
:disabled="creatingTag"
|
|
||||||
@keydown.enter.prevent="handleAddNewTag"
|
|
||||||
>
|
|
||||||
<template #suffix>
|
|
||||||
<t-button
|
|
||||||
theme="primary"
|
|
||||||
variant="text"
|
|
||||||
size="small"
|
|
||||||
:loading="creatingTag"
|
|
||||||
:disabled="!newTagName.trim()"
|
|
||||||
@click="handleAddNewTag"
|
|
||||||
>
|
|
||||||
<t-icon name="add" />
|
|
||||||
</t-button>
|
|
||||||
</template>
|
|
||||||
</t-input>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 底部操作栏 -->
|
|
||||||
<div class="tag-edit-footer">
|
|
||||||
<div class="tag-edit-footer-left">
|
|
||||||
<span class="tag-edit-selected-count">
|
|
||||||
{{ $t('knowledgeBase.tagSelectedCount', { count: selectedSet.size }) }}
|
|
||||||
</span>
|
|
||||||
<t-button
|
|
||||||
v-if="selectedSet.size > 0"
|
|
||||||
variant="text"
|
|
||||||
size="small"
|
|
||||||
theme="default"
|
|
||||||
@click="clearAll"
|
|
||||||
>
|
|
||||||
{{ $t('knowledgeBase.tagClearAction') }}
|
{{ $t('knowledgeBase.tagClearAction') }}
|
||||||
</t-button>
|
</t-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="selectedTagsList.length > 0" class="tag-edit-chips">
|
||||||
|
<button v-for="tag in selectedTagsList" :key="tag.id" type="button" class="tag-edit-chip is-selected"
|
||||||
|
:title="tag.name" @click="toggleTag(tag.id)">
|
||||||
|
{{ tag.name }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p v-else class="tag-edit-section-empty">{{ $t('knowledgeBase.tagEditNoSelected') }}</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="setting-drawer__section">
|
||||||
|
<h4 class="setting-drawer__section-title">{{ $t('knowledgeBase.tagEditAvailableSection') }}</h4>
|
||||||
|
<div class="tag-edit-search-bar">
|
||||||
|
<t-input v-model="searchQuery" :placeholder="$t('knowledgeBase.tagEditSearch')" clearable size="small">
|
||||||
|
<template #prefix-icon>
|
||||||
|
<t-icon name="search" size="14px" />
|
||||||
|
</template>
|
||||||
|
</t-input>
|
||||||
|
</div>
|
||||||
|
<div v-if="availableTagsList.length > 0" class="tag-edit-chips">
|
||||||
|
<button v-for="tag in availableTagsList" :key="tag.id" type="button" class="tag-edit-chip"
|
||||||
|
:title="tag.knowledge_count !== undefined ? `${tag.name} (${tag.knowledge_count})` : tag.name"
|
||||||
|
@click="toggleTag(tag.id)">
|
||||||
|
{{ tag.name }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div v-else class="tag-edit-section-empty tag-edit-section-empty--row">
|
||||||
|
<span>{{ searchQuery.trim() ? $t('knowledgeBase.tagEmptyResult') : $t('knowledgeBase.noTags') }}</span>
|
||||||
|
<t-button v-if="searchQuery.trim()" variant="text" theme="default" size="small" :loading="creatingTag"
|
||||||
|
@click="handleCreateTag">
|
||||||
|
{{ $t('knowledgeBase.tagCreateAction') }} “{{ searchQuery.trim() }}”
|
||||||
|
</t-button>
|
||||||
|
</div>
|
||||||
|
<div class="tag-edit-create-row">
|
||||||
|
<t-input v-model="newTagName" :placeholder="$t('knowledgeBase.tagNewPlaceholder')" size="small"
|
||||||
|
:maxlength="40" :disabled="creatingTag" @enter="handleAddNewTag" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tag-edit-footer">
|
||||||
|
<span class="tag-edit-selected-count">
|
||||||
|
{{ $t('knowledgeBase.tagSelectedCount', { count: selectedSet.size }) }}
|
||||||
|
</span>
|
||||||
<div class="tag-edit-footer-right">
|
<div class="tag-edit-footer-right">
|
||||||
<t-button variant="outline" size="small" @click="handleClose">
|
<t-button variant="outline" size="small" @click="handleClose">
|
||||||
{{ $t('common.cancel') }}
|
{{ $t('common.cancel') }}
|
||||||
@@ -152,11 +109,6 @@ const creatingTag = ref(false);
|
|||||||
const saving = ref(false);
|
const saving = ref(false);
|
||||||
const newTagName = ref('');
|
const newTagName = ref('');
|
||||||
|
|
||||||
const title = computed(() => {
|
|
||||||
return t('knowledgeBase.tagEditDialogTitle', { name: props.knowledgeName });
|
|
||||||
});
|
|
||||||
|
|
||||||
// 初始化已选标签
|
|
||||||
watch(
|
watch(
|
||||||
() => props.visible,
|
() => props.visible,
|
||||||
(val) => {
|
(val) => {
|
||||||
@@ -168,24 +120,21 @@ watch(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// 过滤标签列表,按照关键字匹配,已选的排前面
|
const tagMap = computed(() => new Map(props.tagList.map((tag) => [tag.id, tag])));
|
||||||
const filteredTags = computed(() => {
|
|
||||||
|
const selectedTagsList = computed(() => {
|
||||||
|
return Array.from(selectedSet.value)
|
||||||
|
.map((id) => tagMap.value.get(id))
|
||||||
|
.filter((tag): tag is Tag => Boolean(tag));
|
||||||
|
});
|
||||||
|
|
||||||
|
const availableTagsList = computed(() => {
|
||||||
const query = searchQuery.value.trim().toLowerCase();
|
const query = searchQuery.value.trim().toLowerCase();
|
||||||
let list = props.tagList;
|
return props.tagList.filter((tag) => {
|
||||||
if (query) {
|
if (selectedSet.value.has(tag.id)) return false;
|
||||||
list = list.filter((tag) => (tag.name || '').toLowerCase().includes(query));
|
if (query && !(tag.name || '').toLowerCase().includes(query)) return false;
|
||||||
}
|
return true;
|
||||||
// 已选的排前面
|
});
|
||||||
const selected: Tag[] = [];
|
|
||||||
const unselected: Tag[] = [];
|
|
||||||
for (const tag of list) {
|
|
||||||
if (selectedSet.value.has(tag.id)) {
|
|
||||||
selected.push(tag);
|
|
||||||
} else {
|
|
||||||
unselected.push(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [...selected, ...unselected];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function toggleTag(tagId: string) {
|
function toggleTag(tagId: string) {
|
||||||
@@ -225,10 +174,8 @@ async function handleCreateTag() {
|
|||||||
async function handleAddNewTag() {
|
async function handleAddNewTag() {
|
||||||
const name = newTagName.value.trim();
|
const name = newTagName.value.trim();
|
||||||
if (!name) return;
|
if (!name) return;
|
||||||
// 检查是否已存在同名标签
|
|
||||||
const exists = props.tagList.find((t) => t.name === name);
|
const exists = props.tagList.find((t) => t.name === name);
|
||||||
if (exists) {
|
if (exists) {
|
||||||
// 已存在则直接选中
|
|
||||||
const next = new Set(selectedSet.value);
|
const next = new Set(selectedSet.value);
|
||||||
next.add(exists.id);
|
next.add(exists.id);
|
||||||
selectedSet.value = next;
|
selectedSet.value = next;
|
||||||
@@ -267,84 +214,287 @@ function handleClose() {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style>
|
||||||
.tag-edit-search {
|
.tag-edit-dialog {
|
||||||
margin-bottom: 12px;
|
overflow: hidden;
|
||||||
|
padding: 0;
|
||||||
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-list {
|
.tag-edit-dialog .t-dialog__header {
|
||||||
max-height: 320px;
|
min-height: auto;
|
||||||
overflow-y: auto;
|
padding: 20px 20px 0;
|
||||||
border: 1px solid var(--td-component-stroke);
|
|
||||||
border-radius: 6px;
|
|
||||||
padding: 4px 0;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-item {
|
.tag-edit-dialog .t-dialog__body {
|
||||||
display: flex;
|
padding: 0 20px 20px;
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background 0.15s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-item:hover {
|
.tag-edit-dialog .t-dialog__close {
|
||||||
|
top: 16px;
|
||||||
|
right: 16px;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
transition: background 0.18s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-dialog .t-dialog__close:hover {
|
||||||
|
color: var(--td-text-color-primary);
|
||||||
background: var(--td-bg-color-container-hover);
|
background: var(--td-bg-color-container-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-item.is-selected {
|
@media (max-width: 480px) {
|
||||||
background: var(--td-brand-color-light);
|
.tag-edit-dialog {
|
||||||
|
width: calc(100vw - 24px) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.tag-edit-heading {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
min-width: 0;
|
||||||
|
padding-right: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-name {
|
.tag-edit-heading-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-heading-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-title {
|
||||||
|
color: var(--td-text-color-primary);
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 22px;
|
||||||
|
letter-spacing: 0.2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-document-name {
|
||||||
|
margin: 0;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
color: var(--td-text-color-placeholder);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 18px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-body {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-body .setting-drawer__section {
|
||||||
|
padding: 12px 0 16px;
|
||||||
|
border-bottom: 1px solid var(--td-component-stroke);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-body .setting-drawer__section:first-child {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-body .setting-drawer__section:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-body .setting-drawer__section-title {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--td-text-color-primary);
|
||||||
|
margin: 0 0 4px;
|
||||||
|
user-select: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-body .setting-drawer__section-title::before {
|
||||||
|
content: '';
|
||||||
|
width: 3px;
|
||||||
|
height: 14px;
|
||||||
|
background: var(--td-brand-color);
|
||||||
|
border-radius: 2px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-section-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-section-head .setting-drawer__section-title {
|
||||||
|
margin-bottom: 0;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
font-size: 14px;
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-section-head :deep(.t-button) {
|
||||||
|
height: auto;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--td-text-color-placeholder);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-search-bar {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-search-bar :deep(.t-input) {
|
||||||
|
font-size: 12px;
|
||||||
|
background-color: var(--td-bg-color-secondarycontainer);
|
||||||
|
border-color: transparent;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-search-bar :deep(.t-input:hover),
|
||||||
|
.tag-edit-search-bar :deep(.t-input.t-is-focused) {
|
||||||
|
border-color: var(--td-component-border);
|
||||||
|
background-color: var(--td-bg-color-container);
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-chips {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
max-height: min(120px, 24vh);
|
||||||
|
overflow-y: auto;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-chips::-webkit-scrollbar {
|
||||||
|
width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-chips::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 2px;
|
||||||
|
background: var(--td-scrollbar-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
max-width: 100%;
|
||||||
|
height: 22px;
|
||||||
|
padding: 0 8px;
|
||||||
|
border: 1px solid var(--td-component-stroke);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
font-family: var(--app-font-family);
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 22px;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-chip:hover {
|
||||||
|
border-color: var(--td-component-stroke);
|
||||||
|
background: var(--td-bg-color-secondarycontainer);
|
||||||
color: var(--td-text-color-primary);
|
color: var(--td-text-color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-count {
|
.tag-edit-chip:focus-visible {
|
||||||
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--td-component-stroke) 60%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-chip.is-selected {
|
||||||
|
border-color: transparent;
|
||||||
|
background: var(--td-bg-color-secondarycontainer);
|
||||||
|
color: var(--td-text-color-primary);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-chip.is-selected:hover {
|
||||||
|
background: color-mix(in srgb, var(--td-bg-color-secondarycontainer) 70%, var(--td-bg-color-container));
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-section-empty {
|
||||||
|
margin: 0;
|
||||||
|
min-height: 22px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
line-height: 22px;
|
||||||
color: var(--td-text-color-placeholder);
|
color: var(--td-text-color-placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-empty {
|
.tag-edit-section-empty--row {
|
||||||
padding: 24px 12px;
|
display: flex;
|
||||||
text-align: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-empty-text {
|
.tag-edit-create-row {
|
||||||
margin: 0 0 8px;
|
margin-top: 0;
|
||||||
font-size: 13px;
|
|
||||||
color: var(--td-text-color-placeholder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-new-bar {
|
.tag-edit-create-row :deep(.t-input) {
|
||||||
margin-bottom: 12px;
|
font-size: 12px;
|
||||||
|
background-color: transparent;
|
||||||
|
border-style: dashed;
|
||||||
|
border-color: var(--td-component-stroke);
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-edit-create-row :deep(.t-input:hover),
|
||||||
|
.tag-edit-create-row :deep(.t-input.t-is-focused) {
|
||||||
|
border-color: var(--td-component-border);
|
||||||
|
border-style: dashed;
|
||||||
|
background-color: var(--td-bg-color-secondarycontainer);
|
||||||
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-footer {
|
.tag-edit-footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
gap: 12px;
|
||||||
|
margin-top: 14px;
|
||||||
.tag-edit-footer-left {
|
padding-top: 14px;
|
||||||
display: flex;
|
border-top: 1px solid var(--td-component-stroke);
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-selected-count {
|
.tag-edit-selected-count {
|
||||||
font-size: 13px;
|
font-size: 12px;
|
||||||
color: var(--td-text-color-secondary);
|
color: var(--td-text-color-placeholder);
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-edit-footer-right {
|
.tag-edit-footer-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
margin-left: auto;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ CREATE INDEX IF NOT EXISTS idx_ktr_tag
|
|||||||
INSERT INTO knowledge_tag_relations (knowledge_id, tag_id, created_at)
|
INSERT INTO knowledge_tag_relations (knowledge_id, tag_id, created_at)
|
||||||
SELECT id, tag_id, updated_at
|
SELECT id, tag_id, updated_at
|
||||||
FROM knowledges
|
FROM knowledges
|
||||||
WHERE tag_id IS NOT NULL AND tag_id != '';
|
WHERE tag_id IS NOT NULL AND tag_id != ''
|
||||||
|
AND deleted_at IS NULL;
|
||||||
|
|
||||||
-- Drop the old index and column
|
-- Drop the old index and column
|
||||||
DROP INDEX IF EXISTS idx_knowledges_tag;
|
DROP INDEX IF EXISTS idx_knowledges_tag;
|
||||||
|
|||||||
Reference in New Issue
Block a user