feat: enhance document summary functionality with expandable/collapsible feature and overflow detection, improving user interaction

This commit is contained in:
wizardchen
2026-04-11 14:05:56 +08:00
committed by lyingbug
parent 98ff0761ed
commit 1a4b7b390d
9 changed files with 83 additions and 11 deletions
+62 -8
View File
@@ -690,6 +690,24 @@ const getParentContent = (item: any) => {
return parentContextCache.value.get(item.parent_chunk_id) || '';
};
const summaryExpanded = ref(false);
const summaryRef = ref<HTMLElement>();
const summaryOverflow = ref(false);
const checkSummaryOverflow = () => {
nextTick(() => {
const el = summaryRef.value;
if (!el) { summaryOverflow.value = false; return; }
summaryOverflow.value = el.scrollHeight > el.clientHeight + 1;
});
};
watch(() => props.details?.description, () => {
summaryExpanded.value = false;
checkSummaryOverflow();
});
watch(summaryRef, () => checkSummaryOverflow());
const downloadFile = () => {
downKnowledgeDetails(props.details.id)
.then((result) => {
@@ -734,7 +752,7 @@ const handleDetailsScroll = () => {
</script>
<template>
<div class="doc_content" ref="mdContentWrap">
<t-drawer :visible="visible" :zIndex="2000" :closeBtn="true" @close="handleClose">
<t-drawer :visible="visible" :zIndex="2000" :closeBtn="true" :footer="false" @close="handleClose">
<template #header>
<div class="drawer-header">
<span class="header-title">{{ getDisplayTitle() }}</span>
@@ -784,7 +802,12 @@ const handleDetailsScroll = () => {
<!-- 文档摘要 -->
<div v-if="details.description" class="summary_box">
<span class="label">{{ $t('knowledgeBase.documentSummary') }}</span>
<div class="summary_content">{{ details.description }}</div>
<div class="summary_wrapper" :class="{ 'summary_clickable': summaryOverflow || summaryExpanded }" @click="(summaryOverflow || summaryExpanded) && (summaryExpanded = !summaryExpanded)">
<div ref="summaryRef" :class="['summary_content', { 'summary_collapsed': !summaryExpanded }]">{{ details.description }}</div>
<div v-if="(summaryOverflow && !summaryExpanded) || summaryExpanded" class="summary_fade" :class="{ 'summary_fade_expanded': summaryExpanded }">
<t-icon :name="summaryExpanded ? 'chevron-up' : 'chevron-down'" size="14px" class="summary_fade_icon" />
</div>
</div>
</div>
<div v-else-if="details.summary_status === 'pending' || details.summary_status === 'processing'" class="summary_box">
<span class="label">{{ $t('knowledgeBase.documentSummary') }}</span>
@@ -948,10 +971,6 @@ const handleDetailsScroll = () => {
/>
</div>
<template #footer>
<t-button @click="handleClose">{{ $t('common.confirm') }}</t-button>
<t-button theme="default" @click="handleClose">{{ $t('common.cancel') }}</t-button>
</template>
</t-drawer>
</div>
</template>
@@ -1056,15 +1075,50 @@ const handleDetailsScroll = () => {
font-size: 14px;
}
.summary_content {
padding: 12px;
.summary_wrapper {
position: relative;
background: var(--td-bg-color-container-hover);
border-radius: 4px;
&.summary_clickable {
cursor: pointer;
}
}
.summary_content {
padding: 12px;
color: var(--td-text-color-primary);
font-size: 13px;
line-height: 1.5;
word-break: break-word;
white-space: pre-wrap;
&.summary_collapsed {
max-height: 4.5em;
overflow: hidden;
}
}
.summary_fade {
display: flex;
justify-content: center;
padding-bottom: 4px;
pointer-events: none;
&:not(.summary_fade_expanded) {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 28px;
background: linear-gradient(transparent, var(--td-bg-color-container-hover) 80%);
border-radius: 0 0 4px 4px;
align-items: flex-end;
}
}
.summary_fade_icon {
color: var(--td-text-color-placeholder);
}
.summary_loading {
+2
View File
@@ -1177,6 +1177,8 @@ export default {
defaultUser: 'User',
copyFailed: 'Copy failed',
retry: 'Retry',
expand: 'Expand',
collapse: 'Collapse',
},
mentionDetail: {
readOnlyFromAgent: 'Read-only in this conversation; not shown in Knowledge Base list',
+2
View File
@@ -1020,6 +1020,8 @@ export default {
defaultUser: "사용자",
copyFailed: "복사 실패",
retry: "재시도",
expand: "펼치기",
collapse: "접기",
},
mentionDetail: {
faqCount: "Q&A {count}개",
+2
View File
@@ -1139,6 +1139,8 @@ export default {
defaultUser: 'Пользователь',
copyFailed: 'Ошибка копирования',
retry: 'Повторить',
expand: 'Развернуть',
collapse: 'Свернуть',
me: 'Я',
copy: 'Копировать',
copied: 'Скопировано'
+2
View File
@@ -1024,6 +1024,8 @@ export default {
defaultUser: "用户",
copyFailed: "复制失败",
retry: "重试",
expand: "展开",
collapse: "收起",
},
mentionDetail: {
faqCount: "共 {count} 条问答",
@@ -1218,6 +1218,7 @@ import { listSkills, type SkillInfo } from '@/api/skill';
import { listWebSearchProviders, type WebSearchProviderEntity } from '@/api/web-search-provider';
import { getAgentConfig, getConversationConfig, getStorageEngineStatus, type StorageEngineStatusItem, type PromptTemplate } from '@/api/system';
import { useUIStore } from '@/stores/ui';
import { useAuthStore } from '@/stores/auth';
import { useOrganizationStore } from '@/stores/organization';
import AgentAvatar from '@/components/AgentAvatar.vue';
import PromptTemplateSelector from '@/components/PromptTemplateSelector.vue';
@@ -1226,6 +1227,7 @@ import AgentShareSettings from '@/components/AgentShareSettings.vue';
import IMChannelPanel from '@/components/IMChannelPanel.vue';
const uiStore = useUIStore();
const authStore = useAuthStore();
const orgStore = useOrganizationStore();
const { t } = useI18n();
@@ -1453,8 +1455,8 @@ const navItems = computed(() => {
if (!isAgentMode.value) {
items.push({ key: 'conversation', icon: 'chat', label: t('agent.editor.conversationSettings') });
}
// 共享管理(仅编辑模式且非内置智能体)
if (props.mode === 'edit' && props.agent?.id && !props.agent?.is_builtin) {
// 共享管理(仅编辑模式且非内置智能体,Lite 模式下隐藏)
if (props.mode === 'edit' && props.agent?.id && !props.agent?.is_builtin && !authStore.isLiteMode) {
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') });
}
// IM集成(仅编辑模式,创建时Agent还没有ID)
+3
View File
@@ -1,6 +1,7 @@
<template>
<div class="agent-list-container">
<ListSpaceSidebar
v-if="!authStore.isLiteMode"
v-model="spaceSelection"
:count-all="allAgentsCount"
:count-mine="agents.length"
@@ -545,10 +546,12 @@ import type { SharedAgentInfo, OrganizationSharedAgentItem } from '@/api/organiz
import AgentEditorModal from './AgentEditorModal.vue'
import AgentAvatar from '@/components/AgentAvatar.vue'
import ListSpaceSidebar from '@/components/ListSpaceSidebar.vue'
import { useAuthStore } from '@/stores/auth'
const { t } = useI18n()
const route = useRoute()
const router = useRouter()
const authStore = useAuthStore()
const orgStore = useOrganizationStore()
interface AgentWithUI extends CustomAgent {
@@ -292,6 +292,7 @@ import { createKnowledgeBase, getKnowledgeBaseById, listKnowledgeFiles, updateKn
import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
import { listModels } from '@/api/model'
import { useUIStore } from '@/stores/ui'
import { useAuthStore } from '@/stores/auth'
import KBModelConfig from './settings/KBModelConfig.vue'
import KBParserSettings from './settings/KBParserSettings.vue'
import KBStorageSettings from './settings/KBStorageSettings.vue'
@@ -304,6 +305,7 @@ import DataSourceSettings from './settings/DataSourceSettings.vue'
import { useI18n } from 'vue-i18n'
const uiStore = useUIStore()
const authStore = useAuthStore()
const { t } = useI18n()
// Props
@@ -349,7 +351,7 @@ const navItems = computed(() => {
items.push({ key: 'datasource', icon: 'cloud-download', label: t('knowledgeEditor.sidebar.datasource'), badge: dsCount.value || undefined })
}
}
if (props.mode === 'edit' && props.kbId) {
if (props.mode === 'edit' && props.kbId && !authStore.isLiteMode) {
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') })
}
return items
@@ -1,6 +1,7 @@
<template>
<div class="kb-list-container">
<ListSpaceSidebar
v-if="!authStore.isLiteMode"
v-model="spaceSelection"
:count-all="allKnowledgeBases"
:count-mine="kbs.length"
@@ -606,6 +607,7 @@ import { MessagePlugin, Icon as TIcon } from 'tdesign-vue-next'
import { listKnowledgeBases, deleteKnowledgeBase, togglePinKnowledgeBase } from '@/api/knowledge-base'
import { formatStringDate } from '@/utils/index'
import { useUIStore } from '@/stores/ui'
import { useAuthStore } from '@/stores/auth'
import { useOrganizationStore } from '@/stores/organization'
import { listOrganizationSharedKnowledgeBases, type SharedKnowledgeBase, type OrganizationSharedKnowledgeBaseItem, type SourceFromAgentInfo } from '@/api/organization'
import KnowledgeBaseEditorModal from './KnowledgeBaseEditorModal.vue'
@@ -616,6 +618,7 @@ import { useI18n } from 'vue-i18n'
const router = useRouter()
const route = useRoute()
const uiStore = useUIStore()
const authStore = useAuthStore()
const orgStore = useOrganizationStore()
const { t } = useI18n()