Skip to content

Commit f6958b0

Browse files
committed
fix(kb): improve knowledge base responsive layout
1 parent a9bb8a6 commit f6958b0

4 files changed

Lines changed: 114 additions & 11 deletions

File tree

dashboard/src/views/knowledge-base/KBDetail.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<!-- 主内容 -->
1717
<div v-else class="kb-content">
1818
<!-- 标签页 -->
19-
<v-tabs v-model="activeTab" class="mb-6" color="primary">
19+
<v-tabs v-model="activeTab" class="kb-tabs mb-6" color="primary" show-arrows>
2020
<v-tab value="overview">
2121
<v-icon start>mdi-information-outline</v-icon>
2222
{{ t('tabs.overview') }}
@@ -247,9 +247,14 @@ watch(
247247

248248
<style scoped>
249249
.kb-detail-page {
250+
min-width: 0;
250251
width: 100%;
251252
}
252253
254+
.kb-tabs {
255+
max-width: 100%;
256+
}
257+
253258
.kb-detail-page :deep(.v-card--variant-outlined) {
254259
background: rgb(var(--v-theme-surface));
255260
}
@@ -290,6 +295,11 @@ watch(
290295
291296
/* 响应式设计 */
292297
@media (max-width: 768px) {
298+
.kb-tabs :deep(.v-tab) {
299+
min-width: max-content;
300+
padding-inline: 12px;
301+
}
302+
293303
.kb-title {
294304
font-size: 1.25rem;
295305
}

dashboard/src/views/knowledge-base/KBList.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
v-if="total > pageSize"
9494
v-model="page"
9595
:length="Math.ceil(total / pageSize)"
96-
:total-visible="7"
96+
:total-visible="xs ? 3 : 7"
9797
class="mt-4"
9898
@update:model-value="loadKnowledgeBases()"
9999
/>
@@ -277,12 +277,14 @@
277277
<script setup lang="ts">
278278
import { ref, onMounted } from 'vue'
279279
import { useRouter } from 'vue-router'
280+
import { useDisplay } from 'vuetify'
280281
import { knowledgeApi, providerApi } from '@/api/v1'
281282
import { useModuleI18n } from '@/i18n/composables'
282283
import OutlinedActionListItem from '@/components/shared/OutlinedActionListItem.vue'
283284
284285
const { tm: t } = useModuleI18n('features/knowledge-base/index')
285286
const router = useRouter()
287+
const { xs } = useDisplay()
286288
287289
// 状态
288290
const loading = ref(false)
@@ -530,6 +532,7 @@ onMounted(() => {
530532

531533
<style scoped>
532534
.kb-list-page {
535+
padding-bottom: 144px;
533536
width: 100%;
534537
}
535538
@@ -685,6 +688,16 @@ onMounted(() => {
685688
686689
/* 响应式设计 */
687690
@media (max-width: 768px) {
691+
.kb-list-page {
692+
padding-bottom: 132px;
693+
}
694+
695+
.kb-fab-stack {
696+
bottom: calc(20px + env(safe-area-inset-bottom));
697+
gap: 12px;
698+
right: 20px;
699+
}
700+
688701
.emoji-grid {
689702
grid-template-columns: repeat(6, 1fr);
690703
}

dashboard/src/views/knowledge-base/components/DocumentsTab.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<!-- 文档列表 -->
1313
<v-card variant="outlined">
14-
<v-data-table-server :headers="headers" :items="documents" :loading="loading"
14+
<v-data-table-server class="documents-table" :headers="headers" :items="documents" :loading="loading"
1515
:items-per-page="pageSize" :page="page" :items-length="total"
1616
@update:page="onPageChange" @update:items-per-page="onItemsPerPageChange">
1717
<template #item.doc_name="{ item }">
@@ -897,5 +897,25 @@ onUnmounted(() => {
897897
.action-bar>* {
898898
width: 100%;
899899
}
900+
901+
.documents-table :deep(.v-data-table-footer) {
902+
justify-content: center;
903+
padding: 12px 8px;
904+
row-gap: 8px;
905+
}
906+
907+
.documents-table :deep(.v-data-table-footer__items-per-page) {
908+
flex: 1 1 100%;
909+
justify-content: space-between;
910+
}
911+
912+
.documents-table :deep(.v-data-table-footer__info) {
913+
min-width: 0;
914+
padding: 0 8px;
915+
}
916+
917+
.documents-table :deep(.v-data-table-footer__pagination) {
918+
margin-inline-start: 0;
919+
}
900920
}
901921
</style>

dashboard/src/views/knowledge-base/components/RetrievalTab.vue

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,25 @@
5757

5858
<!-- 检索结果 -->
5959
<div v-if="hasSearched" class="results-section">
60-
<div class="d-flex align-center mb-4">
60+
<div class="results-heading d-flex align-center mb-4">
6161
<h3 class="text-h6">{{ t('retrieval.results') }}</h3>
62-
<v-chip class="ml-3" color="primary" variant="tonal" size="small">
62+
<v-chip color="primary" variant="tonal" size="small">
6363
{{ results.length }} {{ t('retrieval.results') }}
6464
</v-chip>
6565
</div>
6666

6767
<!-- 结果列表 -->
6868
<div v-if="results.length > 0" class="results-list">
6969
<v-card v-for="(result, index) in results" :key="result.chunk_id" variant="outlined" class="mb-4">
70-
<v-card-title class="d-flex align-center pa-2">
71-
<v-chip size="x-small" color="primary" class="mr-2">
70+
<v-card-title class="result-card-header d-flex align-center pa-2">
71+
<v-chip size="x-small" color="primary">
7272
#{{ index + 1 }}
7373
</v-chip>
74-
<span class="text-subtitle-1">
74+
<span class="result-title text-subtitle-1">
7575
{{ t('retrieval.chunk', { index: result.chunk_index }) }}
7676
</span>
77-
<div class="ml-4">
78-
<v-chip size="x-small" variant="tonal" class="mr-2">
77+
<div class="result-meta ml-2">
78+
<v-chip size="x-small" variant="tonal" class="result-document-chip">
7979
<v-icon start size="small">mdi-file-document</v-icon>
8080
{{ result.doc_name }}
8181
</v-chip>
@@ -85,7 +85,7 @@
8585
</v-chip>
8686
</div>
8787
<v-spacer />
88-
<v-chip size="x-small" :color="getScoreColor(result.score)">
88+
<v-chip class="result-score" size="x-small" :color="getScoreColor(result.score)">
8989
{{ t('retrieval.score') }}: {{ result.score.toFixed(4) }}
9090
</v-chip>
9191
</v-card-title>
@@ -240,4 +240,64 @@ const getScoreColor = (score: number) => {
240240
overflow-y: auto;
241241
font-size: 13px;
242242
}
243+
244+
.result-card-header,
245+
.result-meta {
246+
gap: 8px;
247+
}
248+
249+
.results-heading {
250+
gap: 12px;
251+
}
252+
253+
.result-meta {
254+
align-items: center;
255+
display: flex;
256+
min-width: 0;
257+
}
258+
259+
.result-document-chip {
260+
max-width: min(280px, 40vw);
261+
}
262+
263+
.result-document-chip :deep(.v-chip__content) {
264+
overflow: hidden;
265+
text-overflow: ellipsis;
266+
white-space: nowrap;
267+
}
268+
269+
@media (max-width: 768px) {
270+
.result-card-header {
271+
align-items: flex-start !important;
272+
flex-wrap: wrap;
273+
}
274+
275+
.result-title {
276+
flex: 1 1 auto;
277+
min-width: 0;
278+
}
279+
280+
.result-meta {
281+
flex: 1 1 100%;
282+
flex-wrap: wrap;
283+
margin-left: 0 !important;
284+
order: 2;
285+
}
286+
287+
.result-document-chip {
288+
max-width: 100%;
289+
}
290+
291+
.result-score {
292+
margin-left: auto;
293+
}
294+
295+
.results-heading {
296+
flex-wrap: wrap;
297+
}
298+
299+
.results-heading .v-chip {
300+
margin-left: 0 !important;
301+
}
302+
}
243303
</style>

0 commit comments

Comments
 (0)