feat: implement theme synchronization and loading skeletons across various components, enhancing user experience during content loading

This commit is contained in:
wizardchen
2026-04-11 15:03:20 +08:00
committed by lyingbug
parent 1a4b7b390d
commit 6d8b47e57c
15 changed files with 441 additions and 19 deletions
+28 -2
View File
@@ -6,7 +6,16 @@
</div>
<!-- 推荐问题 -->
<div ref="sqContainerRef" class="suggested-questions-container">
<transition name="sq-slide-fade" mode="out-in"
<!-- 骨架屏占位 -->
<div v-if="sqLoading && suggestedQuestions.length === 0" class="suggested-questions-inner">
<div class="suggested-questions-title"><t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '18px' }]" /></div>
<div class="suggested-questions-grid">
<div v-for="n in 6" :key="'sq-skel-'+n" class="suggested-question-card sq-card-skeleton">
<t-skeleton animation="gradient" :row-col="[{ width: '90%', height: '14px' }, { width: '60%', height: '14px' }]" />
</div>
</div>
</div>
<transition v-else appear name="sq-slide-fade" mode="out-in"
@before-leave="onBeforeLeave"
@after-leave="onAfterLeave"
@enter="onEnter"
@@ -69,6 +78,7 @@ const { navigateToKnowledgeBaseList } = useKnowledgeBaseCreationNavigation();
// ===== 推荐问题 =====
const suggestedQuestions = ref<SuggestedQuestion[]>([]);
const sqLoading = ref(true);
const sqCardsRevealed = ref(false);
const sqRenderKey = ref(0);
const sqContainerRef = ref<HTMLElement | null>(null);
@@ -119,7 +129,7 @@ const onQuestionsEntered = () => {
const fetchSuggestedQuestions = async () => {
const fetchId = ++suggestedQuestionsFetchId;
// 加载期间保留旧数据,不清空,避免布局抖动
if (suggestedQuestions.value.length === 0) sqLoading.value = true;
try {
const agentId = settingsStore.selectedAgentId;
if (!agentId) return;
@@ -140,6 +150,10 @@ const fetchSuggestedQuestions = async () => {
if (fetchId === suggestedQuestionsFetchId) {
suggestedQuestions.value = [];
}
} finally {
if (fetchId === suggestedQuestionsFetchId) {
sqLoading.value = false;
}
}
};
@@ -277,11 +291,17 @@ const handleKBEditorSuccess = (kbId: string) => {
transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes skeletonFadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.suggested-questions-inner {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
animation: skeletonFadeIn 0.3s ease-out;
}
// 容器整体过渡:淡入 + 轻微上滑
@@ -335,6 +355,12 @@ const handleKBEditorSuccess = (kbId: string) => {
background 0.2s ease,
box-shadow 0.2s ease;
&.sq-card-skeleton {
opacity: 1;
transform: none;
cursor: default;
}
&.sq-card-visible {
opacity: 1;
transform: translateY(0) scale(1);