feat: implement theme synchronization and loading skeletons across various components, enhancing user experience during content loading
This commit is contained in:
@@ -42,6 +42,7 @@ const uploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
const folderUploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
const uploading = ref(false);
|
||||
const kbLoading = ref(false);
|
||||
const docListLoading = ref(true);
|
||||
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
|
||||
const missingStorageEngine = computed(() => {
|
||||
if (!kbInfo.value || isFAQ.value) return false
|
||||
@@ -566,6 +567,7 @@ const loadKnowledgeBaseInfo = async (targetKbId: string) => {
|
||||
// 重置store中的标签选择状态,避免上传文档时自动带上之前选择的标签
|
||||
uiStore.setSelectedTagId('');
|
||||
if (!isFAQ.value) {
|
||||
docListLoading.value = true;
|
||||
loadKnowledgeFiles(targetKbId);
|
||||
} else {
|
||||
cardList.value = [];
|
||||
@@ -723,6 +725,7 @@ onUnmounted(() => {
|
||||
});
|
||||
watch(() => cardList.value, (newValue) => {
|
||||
if (isFAQ.value) return;
|
||||
docListLoading.value = false;
|
||||
|
||||
// Auto-open document if navigated with ?knowledge_id=xxx
|
||||
if (pendingKnowledgeId.value && newValue?.length) {
|
||||
@@ -1758,8 +1761,22 @@ async function createNewSession(value: string): Promise<void> {
|
||||
ref="knowledgeScroll"
|
||||
@scroll="handleScroll"
|
||||
>
|
||||
<template v-if="cardList.length">
|
||||
<div class="doc-card-list">
|
||||
<!-- 文档骨架屏 -->
|
||||
<div v-if="docListLoading && cardList.length === 0" class="doc-card-list doc-card-list-animated">
|
||||
<div v-for="n in 8" :key="'doc-skel-'+n" class="knowledge-card knowledge-card-skeleton">
|
||||
<div class="card-content">
|
||||
<div class="card-content-nav">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '70%', height: '18px' }]" />
|
||||
</div>
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '60%', height: '14px' }]" />
|
||||
</div>
|
||||
<div class="card-bottom">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '80px', height: '14px' }, { width: '40px', height: '18px', type: 'rect' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template v-else-if="cardList.length">
|
||||
<div class="doc-card-list doc-card-list-animated">
|
||||
<!-- 现有文档卡片 -->
|
||||
<div
|
||||
class="knowledge-card"
|
||||
@@ -1978,7 +1995,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-else-if="!docListLoading">
|
||||
<div class="doc-empty-state">
|
||||
<EmptyKnowledge />
|
||||
</div>
|
||||
@@ -2898,6 +2915,11 @@ async function createNewSession(value: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.doc-card-list {
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
@@ -2905,6 +2927,29 @@ async function createNewSession(value: string): Promise<void> {
|
||||
gap: 14px;
|
||||
align-content: flex-start;
|
||||
width: 100%;
|
||||
|
||||
&.doc-card-list-animated {
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
.knowledge-card-skeleton {
|
||||
cursor: default;
|
||||
.card-content { padding: 15px 17px 13px; }
|
||||
.card-content-nav { margin-bottom: 14px; }
|
||||
.card-bottom {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding: 0 17px;
|
||||
box-sizing: border-box;
|
||||
height: 34px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
|
||||
.doc-empty-state {
|
||||
|
||||
@@ -78,6 +78,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 骨架屏占位 -->
|
||||
<div v-if="loading && kbs.length === 0" class="kb-card-wrap">
|
||||
<div v-for="n in 6" :key="'skel-'+n" class="kb-card kb-card-skeleton">
|
||||
<div class="card-header">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '60%', height: '20px' }]" />
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '80%', height: '14px' }]" />
|
||||
</div>
|
||||
<div class="card-bottom">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '28px', height: '28px', type: 'rect' }, { width: '28px', height: '28px', type: 'rect' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 卡片网格:全部 -->
|
||||
<div v-if="spaceSelection === 'all' && filteredKnowledgeBases.length > 0" class="kb-card-wrap">
|
||||
<!-- 全部:我的知识库 + 共享给我的知识库 -->
|
||||
@@ -1583,10 +1598,16 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
transition: width 0.2s ease;
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.kb-card-wrap {
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
grid-template-columns: 1fr;
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
}
|
||||
|
||||
.kb-card {
|
||||
@@ -1605,6 +1626,13 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
height: 160px;
|
||||
min-height: 160px;
|
||||
|
||||
&.kb-card-skeleton {
|
||||
cursor: default;
|
||||
.card-header { margin-bottom: 16px; }
|
||||
.card-content { flex: 1; }
|
||||
.card-bottom { margin-top: auto; }
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-brand-color);
|
||||
box-shadow: 0 4px 12px rgba(7, 192, 95, 0.12);
|
||||
|
||||
@@ -394,9 +394,22 @@
|
||||
</div>
|
||||
<!-- Card List Container with Scroll -->
|
||||
<div ref="scrollContainer" class="faq-scroll-container" @scroll="handleScroll">
|
||||
<t-loading :loading="loading && entries.length === 0" size="medium">
|
||||
<!-- FAQ 骨架屏 -->
|
||||
<div v-if="loading && entries.length === 0" class="faq-skeleton-grid">
|
||||
<div v-for="n in 6" :key="'faq-skel-'+n" class="faq-card faq-card-skeleton">
|
||||
<div class="faq-card-header">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '16px' }]" />
|
||||
</div>
|
||||
<div class="faq-card-body">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '13px' }, { width: '90%', height: '13px' }, { width: '60%', height: '13px' }]" />
|
||||
</div>
|
||||
<div class="faq-skel-footer">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '50px', height: '18px', type: 'rect' }, { width: '60px', height: '18px', type: 'rect' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Card List -->
|
||||
<template v-if="entries.length > 0">
|
||||
<template v-else-if="entries.length > 0">
|
||||
<div ref="cardListRef" class="faq-card-list">
|
||||
<div
|
||||
v-for="entry in entries"
|
||||
@@ -614,8 +627,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-if="!loading" class="faq-empty-state">
|
||||
<template v-else-if="!loading">
|
||||
<div class="faq-empty-state">
|
||||
<div class="empty-content">
|
||||
<t-icon name="file-add" size="48px" class="empty-icon" />
|
||||
<div class="empty-text">{{ $t('knowledgeEditor.faq.emptyTitle') }}</div>
|
||||
@@ -623,7 +636,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</t-loading>
|
||||
<div v-if="loadingMore" class="faq-load-more">
|
||||
<t-loading size="small" :text="$t('common.loading')" />
|
||||
</div>
|
||||
@@ -1363,7 +1375,7 @@ const handleFaqAction = (data: { value: string }) => {
|
||||
}
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const loading = ref(true)
|
||||
const loadingMore = ref(false)
|
||||
const entries = ref<FAQEntry[]>([])
|
||||
const entryStatusLoading = reactive<Record<number, boolean>>({})
|
||||
@@ -4171,10 +4183,40 @@ watch(() => entries.value.map(e => ({
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.faq-skeleton-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
}
|
||||
|
||||
.faq-card-skeleton {
|
||||
cursor: default;
|
||||
height: auto;
|
||||
.faq-card-header {
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
.faq-card-body {
|
||||
padding: 8px 0;
|
||||
}
|
||||
.faq-skel-footer {
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
|
||||
// 卡片列表样式 - 使用绝对定位实现瀑布流,下一行补齐上一行空缺
|
||||
.faq-card-list {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user