feat(kb-list): group pinned knowledge bases into a labeled section

On the KB list page, pinned items already sort to the top but look
identical to the rest, so at a glance you can't tell where the pinned
group ends. Add lightweight section headers ("置顶" / "其他") that
span the grid when the list transitions from pinned to unpinned, in
both the "全部" and "我的" tabs. Shared KBs never enter the pinned
group (backend doesn't pin them).

No divider line, no backend change — purely a visual grouping on the
existing sort order.
This commit is contained in:
wizardchen
2026-05-06 12:09:10 +08:00
committed by lyingbug
parent c3e53a3fc4
commit 0be4572bd5
5 changed files with 70 additions and 3 deletions
+4
View File
@@ -1548,6 +1548,10 @@ export default {
unpinSuccess: 'Unpinned',
failed: 'Operation failed',
},
sections: {
pinned: 'Pinned',
others: 'Others',
},
messages: {
deleted: 'Knowledge base deleted',
deleteFailed: 'Failed to delete knowledge base',
+4
View File
@@ -2146,6 +2146,10 @@ export default {
unpinSuccess: "고정 해제됨",
failed: "작업 실패",
},
sections: {
pinned: "고정됨",
others: "기타",
},
detail: {
title: "공유 지식베이스",
overview: "개요",
+4
View File
@@ -1753,6 +1753,10 @@ export default {
unpinSuccess: 'Откреплено',
failed: 'Операция не удалась'
},
sections: {
pinned: 'Закреплённые',
others: 'Другие'
},
messages: {
deleted: 'База знаний удалена',
deleteFailed: 'Не удалось удалить базу знаний',
+4
View File
@@ -2119,6 +2119,10 @@ export default {
unpinSuccess: "已取消置顶",
failed: "操作失败",
},
sections: {
pinned: "置顶",
others: "其他",
},
detail: {
title: "共享知识库",
overview: "概览",
@@ -95,8 +95,26 @@
<!-- 卡片网格:全部 -->
<div v-if="spaceSelection === 'all' && filteredKnowledgeBases.length > 0" class="kb-card-wrap">
<!-- 置顶分组标题 -->
<div
v-if="filteredKnowledgeBases[0] && filteredKnowledgeBases[0].isMine && filteredKnowledgeBases[0].is_pinned"
class="kb-section-header kb-section-header-pinned"
>
<t-icon name="pin-filled" size="14px" />
<span>{{ $t('knowledgeList.sections.pinned') }}</span>
</div>
<!-- 全部:我的知识库 + 共享给我的知识库 -->
<template v-for="kb in filteredKnowledgeBases" :key="kb.id">
<template v-for="(kb, index) in filteredKnowledgeBases" :key="kb.id">
<!-- 「其他」分组标题:从置顶过渡到非置顶时插入 -->
<div
v-if="index > 0
&& filteredKnowledgeBases[index - 1].isMine
&& filteredKnowledgeBases[index - 1].is_pinned
&& !(kb.isMine && kb.is_pinned)"
class="kb-section-header"
>
<span>{{ $t('knowledgeList.sections.others') }}</span>
</div>
<!-- 我的知识库卡片 -->
<div
v-if="kb.isMine"
@@ -262,10 +280,21 @@
</div>
<div v-if="spaceSelection === 'mine' && kbs.length > 0" class="kb-card-wrap">
<!-- 置顶分组标题 -->
<div v-if="kbs[0] && kbs[0].is_pinned" class="kb-section-header kb-section-header-pinned">
<t-icon name="pin-filled" size="14px" />
<span>{{ $t('knowledgeList.sections.pinned') }}</span>
</div>
<!-- 我的知识库 -->
<template v-for="(kb, index) in kbs" :key="kb.id">
<!-- 「其他」分组标题:从置顶过渡到非置顶时插入 -->
<div
v-if="index > 0 && kbs[index - 1].is_pinned && !kb.is_pinned"
class="kb-section-header"
>
<span>{{ $t('knowledgeList.sections.others') }}</span>
</div>
<div
v-for="(kb, index) in kbs"
:key="kb.id"
class="kb-card"
:class="{
'uninitialized': !isInitialized(kb),
@@ -367,6 +396,7 @@
</div>
</div>
</div>
</template>
</div>
<!-- 卡片网格:共享给我 -->
@@ -1615,6 +1645,27 @@ const handleUploadFinishedEvent = (event: Event) => {
animation: contentFadeIn 0.32s ease-out;
}
.kb-section-header {
grid-column: 1 / -1;
display: flex;
align-items: center;
gap: 6px;
padding: 4px 0 4px;
color: var(--td-text-color-secondary);
font-family: var(--app-font-family);
font-size: 13px;
font-weight: 600;
line-height: 20px;
.t-icon {
color: var(--td-brand-color);
}
&.kb-section-header-pinned {
color: var(--td-brand-color);
}
}
.kb-card {
border: .5px solid var(--td-component-stroke);
border-radius: 12px;