feat(knowledge-base): add document batch delete and list view

Add a list-view alongside the existing card grid (issue #957) and
multi-select batch delete (issue #1045) for documents inside a knowledge
base. The two views are toggled from the toolbar and the preference is
persisted in localStorage. Selection state is shared between views with
shift-range support and a sticky batch-action bar.

Backend
- POST /api/v1/knowledge/batch-delete: validates KB scope and editor
  permission, then delegates to the existing DeleteKnowledgeList service
  which already cascades vector/file/graph cleanup. Caps batch size at
  200 and uses a single GetKnowledgeBatch call for membership validation.

Frontend
- DocumentListView: table layout with sticky header, checkbox column
  (with indeterminate select-all), file-type icons, status badges,
  per-row action menu.
- DocumentBatchBar: floating pill bar with selected count and delete
  action; appears when items are selected.
- KnowledgeBase.vue: view-mode toggle, selection state, batch-delete
  confirmation dialog, hover/active checkbox overlay on existing cards.
- Extracted formatFileSize and getFileIcon to utils/files.ts to share
  with the new list view and avoid further drift from the existing
  inline copies.
- i18n keys added for zh-CN, en-US, ko-KR, ru-RU.

Closes #1045
Closes #957
This commit is contained in:
nullkey
2026-04-29 03:24:35 +08:00
committed by lyingbug
parent abd188d344
commit be8e53bf08
11 changed files with 1074 additions and 12 deletions
+282 -12
View File
@@ -28,13 +28,17 @@ import {
createKnowledgeFromURL,
listKnowledgeBases,
reparseKnowledge,
batchDeleteKnowledge,
} from "@/api/knowledge-base/index";
import FAQEntryManager from './components/FAQEntryManager.vue';
import DocumentListView from './components/DocumentListView.vue';
import DocumentBatchBar from './components/DocumentBatchBar.vue';
import WikiBrowser from './wiki/WikiBrowser.vue';
import { getWikiStats } from '@/api/wiki';
import { listMoveTargets, moveKnowledge, getKnowledgeMoveProgress } from '@/api/knowledge-base';
import { useI18n } from 'vue-i18n';
import { formatStringDate, kbFileTypeVerification } from '@/utils';
import { formatFileSize } from '@/utils/files';
import { getParserEngines, type ParserEngineInfo } from '@/api/system';
const route = useRoute();
const { t } = useI18n();
@@ -269,6 +273,26 @@ const moveMode = ref<'reuse_vectors' | 'reparse'>('reuse_vectors');
const moveSubmitting = ref(false);
let movePollTimer: ReturnType<typeof setInterval> | null = null;
// View mode (grid / list) — persisted per browser
type DocViewMode = 'grid' | 'list';
const VIEW_MODE_KEY = 'weknora.kb.docs.viewMode';
const initViewMode = (): DocViewMode => {
try {
return localStorage.getItem(VIEW_MODE_KEY) === 'list' ? 'list' : 'grid';
} catch { return 'grid'; }
};
const viewMode = ref<DocViewMode>(initViewMode());
watch(viewMode, (v) => {
try { localStorage.setItem(VIEW_MODE_KEY, v); } catch { /* ignore */ }
});
// Multi-select state — shared between grid and list views.
// Vue 3.5 tracks Set#add/delete natively, so direct mutation is reactive.
const selectedIds = ref<Set<string>>(new Set());
let lastSelectedIndex = -1;
const batchDeleteDialog = ref(false);
const batchDeleting = ref(false);
const selectedTagId = ref<string>('');
const tagList = ref<any[]>([]);
const tagLoading = ref(false);
@@ -358,16 +382,6 @@ const formatDocTime = (time?: string) => {
return formatted.slice(2, 16) // "YY-MM-DD HH:mm"
}
// 格式化文件大小,用于气泡等展示
const formatFileSize = (bytes?: number | string) => {
if (bytes == null || bytes === '') return ''
const n = typeof bytes === 'string' ? parseInt(bytes, 10) : bytes
if (Number.isNaN(n) || n <= 0) return ''
if (n < 1024) return `${n} B`
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`
return `${(n / (1024 * 1024)).toFixed(1)} MB`
}
const channelLabelMap: Record<string, string> = {
web: 'knowledgeBase.channelWeb',
api: 'knowledgeBase.channelApi',
@@ -1600,6 +1614,91 @@ const delCardConfirm = () => {
});
};
const toggleSelectRow = (id: string, checked: boolean, shiftKey?: boolean) => {
const items = cardList.value || [];
const idx = items.findIndex((i: KnowledgeCard) => i.id === id);
if (shiftKey && lastSelectedIndex >= 0 && idx >= 0) {
const [s, e] = idx < lastSelectedIndex
? [idx, lastSelectedIndex]
: [lastSelectedIndex, idx];
for (let i = s; i <= e; i++) {
if (checked) selectedIds.value.add(items[i].id);
else selectedIds.value.delete(items[i].id);
}
} else {
if (checked) selectedIds.value.add(id);
else selectedIds.value.delete(id);
}
lastSelectedIndex = idx;
};
const toggleSelectAll = (checked: boolean) => {
if (checked) {
for (const item of cardList.value || []) selectedIds.value.add(item.id);
} else {
for (const item of cardList.value || []) selectedIds.value.delete(item.id);
}
};
const clearSelection = () => {
selectedIds.value.clear();
lastSelectedIndex = -1;
};
const openBatchDeleteDialog = () => {
if (selectedIds.value.size === 0) return;
batchDeleteDialog.value = true;
};
const confirmBatchDelete = async () => {
if (batchDeleting.value || selectedIds.value.size === 0) return;
const ids = Array.from(selectedIds.value);
batchDeleting.value = true;
try {
const res: any = await batchDeleteKnowledge(kbId.value, ids);
if (res?.success) {
MessagePlugin.success(t('knowledgeBase.batchDeleteSuccess', { count: ids.length }));
clearSelection();
batchDeleteDialog.value = false;
page = 1;
loadKnowledgeFiles(kbId.value);
loadTags(kbId.value);
} else {
MessagePlugin.error(res?.message || t('knowledgeBase.batchDeleteFailed'));
}
} catch (e: any) {
MessagePlugin.error(e?.message || t('knowledgeBase.batchDeleteFailed'));
} finally {
batchDeleting.value = false;
}
};
// Bridge list-view actions back to existing per-card handlers.
const handleListAction = (
action: 'edit' | 'reparse' | 'move' | 'delete',
item: KnowledgeCard,
) => {
const idx = (cardList.value || []).findIndex((i: KnowledgeCard) => i.id === item.id);
if (action === 'edit') return handleManualEdit(idx, item);
if (action === 'reparse') return handleKnowledgeReparse(idx, item);
if (action === 'move') return handleMoveKnowledge(item);
if (action === 'delete') return delCard(idx, item);
};
// Clear selection on filter/tag/kb change to avoid acting on hidden items.
watch([selectedTagId, docSearchKeyword, selectedFileType, kbId], () => {
clearSelection();
});
// After cardList reloads, drop ids that are no longer present.
watch(cardList, () => {
if (selectedIds.value.size === 0) return;
const visible = new Set((cardList.value || []).map((i: KnowledgeCard) => i.id));
for (const id of selectedIds.value) {
if (!visible.has(id)) selectedIds.value.delete(id);
}
}, { deep: false });
// 处理知识库编辑成功后的回调
const handleKBEditorSuccess = (kbIdValue: string) => {
if (kbIdValue === kbId.value) {
@@ -1979,6 +2078,30 @@ async function createNewSession(value: string): Promise<void> {
class="doc-type-select"
clearable
/>
<div class="doc-view-toggle" role="group" :aria-label="$t('knowledgeBase.viewModeToggle')">
<t-tooltip :content="$t('knowledgeBase.viewModeGrid')" placement="top">
<button
type="button"
class="doc-view-toggle-btn"
:class="{ active: viewMode === 'grid' }"
@click="viewMode = 'grid'"
:aria-pressed="viewMode === 'grid'"
>
<t-icon name="view-module" size="16px" />
</button>
</t-tooltip>
<t-tooltip :content="$t('knowledgeBase.viewModeList')" placement="top">
<button
type="button"
class="doc-view-toggle-btn"
:class="{ active: viewMode === 'list' }"
@click="viewMode = 'list'"
:aria-pressed="viewMode === 'list'"
>
<t-icon name="view-list" size="16px" />
</button>
</t-tooltip>
</div>
<div v-if="canEdit" class="doc-filter-actions">
<t-tooltip :content="$t('knowledgeBase.addDocument')" placement="top">
<t-dropdown
@@ -2014,11 +2137,12 @@ async function createNewSession(value: string): Promise<void> {
</div>
</div>
</div>
<template v-else-if="cardList.length">
<template v-else-if="cardList.length && viewMode === 'grid'">
<div class="doc-card-list doc-card-list-animated">
<!-- 现有文档卡片 -->
<div
class="knowledge-card"
:class="{ 'is-selected': selectedIds.has(item.id), 'has-selection': selectedIds.size > 0 }"
v-for="(item, index) in cardList"
:key="index"
@click="openCardDetails(item)"
@@ -2026,6 +2150,19 @@ async function createNewSession(value: string): Promise<void> {
@mousemove="onCardMouseMove($event)"
@mouseleave="onCardMouseLeave"
>
<label
v-if="canEdit"
class="card-select-overlay"
:class="{ active: selectedIds.has(item.id) }"
@click.stop
>
<input
type="checkbox"
:checked="selectedIds.has(item.id)"
@click.stop="(e: MouseEvent) => toggleSelectRow(item.id, !selectedIds.has(item.id), e.shiftKey)"
:aria-label="item.file_name"
/>
</label>
<div class="card-content">
<div class="card-content-nav">
<span class="card-content-title" :title="item.file_name">{{ item.file_name }}</span>
@@ -2234,11 +2371,29 @@ async function createNewSession(value: string): Promise<void> {
</div>
</Teleport>
</template>
<template v-else-if="cardList.length && viewMode === 'list'">
<DocumentListView
:items="cardList"
:selected-ids="selectedIds"
:tag-list="tagList"
:can-edit="canEdit"
@open="(item: any) => openCardDetails(item)"
@toggle-row="toggleSelectRow"
@toggle-all="toggleSelectAll"
@action="(action: any, item: any) => handleListAction(action, item)"
/>
</template>
<template v-else-if="!docListLoading">
<div class="doc-empty-state">
<EmptyKnowledge />
</div>
</template>
<DocumentBatchBar
:count="selectedIds.size"
:loading="batchDeleting"
@clear="clearSelection"
@delete="openBatchDeleteDialog"
/>
</div>
</div>
<t-dialog
@@ -2265,6 +2420,41 @@ async function createNewSession(value: string): Promise<void> {
</div>
</t-dialog>
<!-- 批量删除确认弹窗 -->
<t-dialog
v-model:visible="batchDeleteDialog"
dialogClassName="del-knowledge"
:closeBtn="false"
:cancelBtn="null"
:confirmBtn="null"
>
<div class="circle-wrap">
<div class="header">
<img class="circle-img" src="@/assets/img/circle.png" alt="" />
<span class="circle-title">{{ t('knowledgeBase.batchDeleteConfirmation') }}</span>
</div>
<span class="del-circle-txt">
{{ t('knowledgeBase.confirmBatchDeleteDocument', { count: selectedIds.size }) }}
</span>
<div class="circle-btn">
<span
class="circle-btn-txt"
:class="{ disabled: batchDeleting }"
@click="batchDeleting ? null : (batchDeleteDialog = false)"
>
{{ t('common.cancel') }}
</span>
<span
class="circle-btn-txt confirm"
:class="{ disabled: batchDeleting }"
@click="confirmBatchDelete"
>
{{ batchDeleting ? '...' : t('knowledgeBase.confirmDelete') }}
</span>
</div>
</div>
</t-dialog>
<!-- 重建知识确认弹窗 -->
<t-dialog
v-model:visible="rebuildDialog"
@@ -2828,6 +3018,38 @@ async function createNewSession(value: string): Promise<void> {
flex-shrink: 0;
}
.doc-view-toggle {
flex-shrink: 0;
display: inline-flex;
align-items: center;
padding: 2px;
background: var(--td-bg-color-secondarycontainer);
border-radius: 6px;
gap: 0;
.doc-view-toggle-btn {
width: 28px;
height: 24px;
display: inline-flex;
align-items: center;
justify-content: center;
border: 0;
background: transparent;
border-radius: 4px;
color: var(--td-text-color-secondary, #888);
cursor: pointer;
transition: background-color 0.12s ease, color 0.12s ease;
&:hover { color: var(--td-text-color-primary, #232323); }
&.active {
background: var(--td-bg-color-container, #fff);
color: var(--td-brand-color, #0052d9);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
}
}
.doc-filter-actions {
flex-shrink: 0;
:deep(.content-bar-icon-btn) {
@@ -3326,6 +3548,11 @@ async function createNewSession(value: string): Promise<void> {
font-weight: 400;
line-height: 22px;
cursor: pointer;
&.disabled {
opacity: 0.5;
cursor: not-allowed;
}
}
.confirm {
@@ -3538,7 +3765,50 @@ async function createNewSession(value: string): Promise<void> {
background: var(--td-bg-color-container);
position: relative;
cursor: pointer;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
&.is-selected {
border-color: var(--td-brand-color, #0052d9);
box-shadow: 0 0 0 1px var(--td-brand-color, #0052d9), 0 4px 12px rgba(0, 82, 217, 0.08);
background: var(--td-brand-color-1, #f0f6ff);
}
.card-select-overlay {
position: absolute;
top: 8px;
left: 8px;
width: 22px;
height: 22px;
display: inline-flex;
align-items: center;
justify-content: center;
background: var(--td-bg-color-container, #fff);
border: 1px solid var(--td-component-border, #e0e0e0);
border-radius: 6px;
cursor: pointer;
opacity: 0;
transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
z-index: 1;
input[type='checkbox'] {
width: 14px;
height: 14px;
margin: 0;
cursor: pointer;
accent-color: var(--td-brand-color, #0052d9);
}
&.active,
&:focus-within {
opacity: 1;
border-color: var(--td-brand-color, #0052d9);
}
}
&:hover .card-select-overlay,
&.has-selection .card-select-overlay {
opacity: 1;
}
.card-content {
padding: 15px 17px 13px;
@@ -0,0 +1,103 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
defineProps<{
count: number;
loading?: boolean;
}>();
const emit = defineEmits<{
(e: 'clear'): void;
(e: 'delete'): void;
}>();
const { t } = useI18n();
</script>
<template>
<transition name="batch-bar-fade">
<div v-if="count > 0" class="doc-batch-bar" role="region" :aria-label="t('knowledgeBase.selectedCount', { count })">
<div class="batch-bar-info">
<span class="batch-bar-count">{{ t('knowledgeBase.selectedCount', { count }) }}</span>
<button class="batch-bar-link" type="button" @click="emit('clear')">
{{ t('knowledgeBase.clearSelection') }}
</button>
</div>
<div class="batch-bar-actions">
<t-button
theme="danger"
variant="base"
size="small"
:loading="loading"
@click="emit('delete')"
>
<template #icon><t-icon name="delete" size="14px" /></template>
{{ t('knowledgeBase.batchDelete') }}
</t-button>
</div>
</div>
</transition>
</template>
<style scoped lang="less">
.doc-batch-bar {
position: sticky;
bottom: 12px;
align-self: center;
display: flex;
align-items: center;
gap: 24px;
padding: 8px 12px 8px 16px;
margin: 12px auto 4px;
min-width: 320px;
max-width: 720px;
background: var(--td-bg-color-container, #fff);
border: 1px solid var(--td-component-border, #e7e7e7);
border-radius: 999px;
box-shadow:
0 6px 20px rgba(0, 0, 0, 0.08),
0 2px 6px rgba(0, 0, 0, 0.06);
z-index: 5;
}
.batch-bar-info {
display: flex;
align-items: center;
gap: 12px;
}
.batch-bar-count {
font-size: 13px;
font-weight: 500;
color: var(--td-text-color-primary, #232323);
}
.batch-bar-link {
background: transparent;
border: 0;
padding: 2px 4px;
font-size: 12px;
color: var(--td-brand-color, #0052d9);
cursor: pointer;
border-radius: 4px;
&:hover { background: var(--td-brand-color-1, #f0f6ff); }
}
.batch-bar-actions {
display: flex;
align-items: center;
gap: 8px;
margin-left: auto;
}
.batch-bar-fade-enter-active,
.batch-bar-fade-leave-active {
transition: transform 0.18s ease, opacity 0.18s ease;
}
.batch-bar-fade-enter-from,
.batch-bar-fade-leave-to {
opacity: 0;
transform: translateY(8px);
}
</style>
@@ -0,0 +1,453 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { formatFileSize, getFileIcon } from '@/utils/files';
interface Tag {
id: string;
name: string;
color?: string;
}
interface KnowledgeItem {
id: string;
file_name: string;
file_type?: string;
file_size?: number | string;
type?: string;
tag_id?: string | number;
parse_status?: string;
summary_status?: string;
updated_at?: string;
source?: string;
isMore?: boolean;
}
const props = defineProps<{
items: KnowledgeItem[];
selectedIds: Set<string>;
canEdit: boolean;
tagList: Tag[];
loading?: boolean;
}>();
const emit = defineEmits<{
(e: 'open', item: KnowledgeItem): void;
(e: 'toggle-row', id: string, checked: boolean, shiftKey: boolean): void;
(e: 'toggle-all', checked: boolean): void;
(e: 'action', action: 'edit' | 'reparse' | 'move' | 'delete', item: KnowledgeItem): void;
}>();
const { t } = useI18n();
const tagMap = computed(() => {
const map: Record<string, Tag> = {};
for (const tag of props.tagList) map[String(tag.id)] = tag;
return map;
});
const getTagName = (tagId?: string | number) => {
if (!tagId && tagId !== 0) return '';
return tagMap.value[String(tagId)]?.name || '';
};
const formatTime = (time?: string) => {
if (!time) return '--';
const d = new Date(time);
if (Number.isNaN(d.getTime())) return '--';
const yy = String(d.getFullYear()).slice(2);
const MM = String(d.getMonth() + 1).padStart(2, '0');
const dd = String(d.getDate()).padStart(2, '0');
const hh = String(d.getHours()).padStart(2, '0');
const mm = String(d.getMinutes()).padStart(2, '0');
return `${yy}-${MM}-${dd} ${hh}:${mm}`;
};
const getTypeLabel = (item: KnowledgeItem) => {
if (item.type === 'url') return 'URL';
if (item.type === 'manual') return t('knowledgeBase.typeManual');
if (item.file_type) return item.file_type.toUpperCase();
return '--';
};
interface StatusInfo {
label: string;
theme: 'success' | 'warning' | 'danger' | 'primary' | 'default';
icon?: string;
spin?: boolean;
}
const computeStatus = (item: KnowledgeItem): StatusInfo => {
if (item.parse_status === 'pending' || item.parse_status === 'processing') {
return { label: t('knowledgeBase.statusProcessing'), theme: 'primary', icon: 'loading', spin: true };
}
if (item.parse_status === 'failed') {
return { label: t('knowledgeBase.statusFailed'), theme: 'danger', icon: 'close-circle' };
}
if (item.parse_status === 'draft') {
return { label: t('knowledgeBase.statusDraft'), theme: 'warning' };
}
if (
item.parse_status === 'completed' &&
(item.summary_status === 'pending' || item.summary_status === 'processing')
) {
return { label: t('knowledgeBase.generatingSummary'), theme: 'primary', icon: 'loading', spin: true };
}
if (item.parse_status === 'completed') {
return { label: t('knowledgeBase.statusCompleted'), theme: 'success' };
}
return { label: '--', theme: 'default' };
};
const statusByRow = computed(() => {
const map = new Map<string, StatusInfo>();
for (const item of props.items) map.set(item.id, computeStatus(item));
return map;
});
const allSelected = computed(() => {
return props.items.length > 0 && props.items.every(i => props.selectedIds.has(i.id));
});
const someSelected = computed(() => {
return props.items.some(i => props.selectedIds.has(i.id)) && !allSelected.value;
});
const onHeaderToggle = (e: Event) => {
const checked = (e.target as HTMLInputElement).checked;
emit('toggle-all', checked);
};
const onRowToggle = (item: KnowledgeItem, e: MouseEvent) => {
const checked = !props.selectedIds.has(item.id);
emit('toggle-row', item.id, checked, e.shiftKey);
};
const moreOpen = ref<string | null>(null);
const onMoreVisible = (id: string, visible: boolean) => {
moreOpen.value = visible ? id : null;
};
const handleAction = (action: 'edit' | 'reparse' | 'move' | 'delete', item: KnowledgeItem) => {
moreOpen.value = null;
item.isMore = false;
emit('action', action, item);
};
</script>
<template>
<div class="doc-list-view" :class="{ 'is-loading': loading }">
<div class="doc-list-header" role="row">
<div class="cell cell-check" role="columnheader">
<label class="checkbox-wrap" @click.stop>
<input
type="checkbox"
:checked="allSelected"
:indeterminate.prop="someSelected"
:disabled="!items.length"
@change="onHeaderToggle"
:aria-label="t('knowledgeBase.selectAll')"
/>
</label>
</div>
<div class="cell cell-name" role="columnheader">{{ t('knowledgeBase.columnName') }}</div>
<div class="cell cell-tag" role="columnheader">{{ t('knowledgeBase.columnTag') }}</div>
<div class="cell cell-size" role="columnheader">{{ t('knowledgeBase.columnSize') }}</div>
<div class="cell cell-type" role="columnheader">{{ t('knowledgeBase.columnType') }}</div>
<div class="cell cell-status" role="columnheader">{{ t('knowledgeBase.columnStatus') }}</div>
<div class="cell cell-time" role="columnheader">{{ t('knowledgeBase.columnUpdatedAt') }}</div>
<div class="cell cell-actions" role="columnheader" v-if="canEdit"></div>
</div>
<div class="doc-list-body">
<div
v-for="item in items"
:key="item.id"
class="doc-list-row"
:class="{ selected: selectedIds.has(item.id), 'menu-open': moreOpen === item.id }"
role="row"
@click="emit('open', item)"
>
<div class="cell cell-check" @click.stop>
<label class="checkbox-wrap">
<input
type="checkbox"
:checked="selectedIds.has(item.id)"
@click="onRowToggle(item, $event as unknown as MouseEvent)"
:aria-label="item.file_name"
/>
</label>
</div>
<div class="cell cell-name">
<t-icon :name="getFileIcon(item)" class="row-file-icon" />
<span class="row-file-name" :title="item.file_name">{{ item.file_name }}</span>
</div>
<div class="cell cell-tag">
<t-tag v-if="getTagName(item.tag_id)" size="small" variant="light-outline" class="row-tag">
{{ getTagName(item.tag_id) }}
</t-tag>
<span v-else class="row-muted">--</span>
</div>
<div class="cell cell-size">
<span class="row-mono">{{ formatFileSize(item.file_size) || '--' }}</span>
</div>
<div class="cell cell-type">
<span class="row-mono">{{ getTypeLabel(item) }}</span>
</div>
<div class="cell cell-status">
<template v-if="statusByRow.get(item.id) as StatusInfo | undefined">
<t-tag
v-if="statusByRow.get(item.id)!.label !== '--'"
size="small"
:theme="statusByRow.get(item.id)!.theme"
variant="light"
class="row-status-tag"
>
<template v-if="statusByRow.get(item.id)!.icon" #icon>
<t-icon
:name="statusByRow.get(item.id)!.icon!"
:class="{ 'icon-spin': statusByRow.get(item.id)!.spin }"
/>
</template>
{{ statusByRow.get(item.id)!.label }}
</t-tag>
<span v-else class="row-muted">--</span>
</template>
</div>
<div class="cell cell-time">
<span class="row-mono">{{ formatTime(item.updated_at) }}</span>
</div>
<div class="cell cell-actions" v-if="canEdit" @click.stop>
<t-popup
placement="bottom-right"
trigger="click"
destroy-on-close
:on-visible-change="(v: boolean) => onMoreVisible(item.id, v)"
>
<button class="row-more-btn" :class="{ active: moreOpen === item.id }" type="button" :aria-label="t('knowledgeBase.columnActions')">
<t-icon name="more" size="16px" />
</button>
<template #content>
<div class="row-menu">
<div
v-if="item.type === 'manual'"
class="row-menu-item"
@click.stop="handleAction('edit', item)"
>
<t-icon name="edit" /> <span>{{ t('knowledgeBase.editDocument') }}</span>
</div>
<div class="row-menu-item" @click.stop="handleAction('reparse', item)">
<t-icon name="refresh" /> <span>{{ t('knowledgeBase.rebuildDocument') }}</span>
</div>
<div class="row-menu-item" @click.stop="handleAction('move', item)">
<t-icon name="swap" /> <span>{{ t('knowledgeBase.moveDocument') }}</span>
</div>
<div class="row-menu-item danger" @click.stop="handleAction('delete', item)">
<t-icon name="delete" /> <span>{{ t('knowledgeBase.deleteDocument') }}</span>
</div>
</div>
</template>
</t-popup>
</div>
</div>
</div>
</div>
</template>
<style scoped lang="less">
.doc-list-view {
display: flex;
flex-direction: column;
width: 100%;
background: var(--td-bg-color-container, #fff);
border: 1px solid var(--td-component-border, #e7e7e7);
border-radius: 10px;
overflow: hidden;
}
.doc-list-header,
.doc-list-row {
display: grid;
grid-template-columns:
44px // checkbox
minmax(220px, 2.4fr) // name
minmax(100px, 0.9fr) // tag
96px // size
72px // type
minmax(96px, 0.7fr) // status
140px // updated_at
48px; // actions
align-items: center;
column-gap: 0;
padding: 0 12px;
}
.doc-list-header {
position: sticky;
top: 0;
z-index: 2;
height: 40px;
font-size: 12px;
font-weight: 500;
color: var(--td-text-color-secondary, #888);
background: var(--td-bg-color-secondarycontainer, #fafafa);
border-bottom: 1px solid var(--td-component-border, #e7e7e7);
}
.doc-list-body {
display: flex;
flex-direction: column;
}
.doc-list-row {
height: 48px;
font-size: 13px;
color: var(--td-text-color-primary, #232323);
border-bottom: 1px solid var(--td-component-stroke, #f0f0f0);
cursor: pointer;
transition: background-color 0.12s ease;
&:last-child { border-bottom: 0; }
&:hover,
&.menu-open {
background: var(--td-bg-color-container-hover, #f6f8fa);
.row-more-btn { opacity: 1; }
}
&.selected {
background: var(--td-brand-color-1, #f0f6ff);
&:hover { background: var(--td-brand-color-2, #e6f0ff); }
}
}
.cell {
display: flex;
align-items: center;
min-width: 0;
padding: 0 8px;
&:first-child { padding-left: 0; }
&:last-child { padding-right: 0; }
}
.cell-check {
justify-content: center;
padding: 0;
}
.cell-name {
gap: 8px;
font-weight: 500;
}
.cell-size,
.cell-time {
justify-content: flex-end;
}
.cell-actions {
justify-content: flex-end;
}
.checkbox-wrap {
display: inline-flex;
align-items: center;
cursor: pointer;
input[type='checkbox'] {
width: 14px;
height: 14px;
accent-color: var(--td-brand-color, #0052d9);
cursor: pointer;
margin: 0;
}
}
.row-file-icon {
flex-shrink: 0;
font-size: 16px;
color: var(--td-text-color-secondary, #888);
}
.row-file-name {
flex: 1;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.row-tag {
max-width: 100%;
:deep(.t-tag__text) {
overflow: hidden;
text-overflow: ellipsis;
max-width: 120px;
display: inline-block;
}
}
.row-muted {
color: var(--td-text-color-disabled, #bbb);
}
.row-mono {
font-variant-numeric: tabular-nums;
font-size: 12px;
color: var(--td-text-color-secondary, #666);
}
.row-status-tag :deep(.t-icon) {
margin-right: 2px;
}
.icon-spin {
animation: doc-list-spin 0.9s linear infinite;
}
@keyframes doc-list-spin {
to { transform: rotate(360deg); }
}
.row-more-btn {
width: 28px;
height: 28px;
display: inline-flex;
align-items: center;
justify-content: center;
border: 0;
background: transparent;
border-radius: 6px;
color: var(--td-text-color-secondary, #666);
cursor: pointer;
opacity: 0;
transition: opacity 0.12s ease, background-color 0.12s ease;
&:hover { background: var(--td-bg-color-component-hover, #ececec); }
&.active { opacity: 1; background: var(--td-bg-color-component-active, #e0e0e0); }
}
.row-menu {
min-width: 160px;
padding: 4px 0;
}
.row-menu-item {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
font-size: 13px;
color: var(--td-text-color-primary, #232323);
cursor: pointer;
transition: background-color 0.12s ease;
&:hover { background: var(--td-bg-color-component-hover, #f5f5f5); }
&.danger { color: var(--td-error-color, #d54941); }
&.danger:hover { background: var(--td-error-color-1, #fff1f0); }
.t-icon { font-size: 14px; }
}
</style>