Skip to content

Commit 0cd46ae

Browse files
author
Taois
committed
feat:换源loading
1 parent 6ab0bad commit 0cd46ae

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

dashboard/src/components/VideoGrid.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ onMounted(() => {
359359
// 监听筛选组件的高度变化
360360
const observeFilterChanges = () => {
361361
const categoryNav = document.querySelector('.category-nav-container');
362-
if (categoryNav) {
362+
if (categoryNav && containerRef.value) {
363363
const observer = new MutationObserver(() => {
364364
// 延迟执行以确保DOM更新完成
365365
setTimeout(() => {

dashboard/src/views/Video.vue

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717

1818
<!-- 内容区域 -->
1919
<div class="main-container">
20+
<!-- 全局loading指示器 -->
21+
<div v-if="globalLoading" class="global-loading-overlay">
22+
<div class="global-loading-content">
23+
<a-spin size="large" />
24+
<div class="loading-text">正在切换数据源...</div>
25+
</div>
26+
</div>
27+
2028
<a-layout-content class="content">
2129
<!-- 搜索结果展示 -->
2230
<SearchResults
@@ -160,6 +168,9 @@ const folderNavigationState = reactive({
160168
loading: false
161169
});
162170
171+
// 全局loading状态(用于换源等操作)
172+
const globalLoading = ref(false);
173+
163174
// 保存进入folder模式前的状态
164175
const previousState = reactive({
165176
activeKey: null,
@@ -277,6 +288,22 @@ const handleConfirmChange = (site) => {
277288
setCurrentSite(site);
278289
form.now_site_title = site.name;
279290
form.visible = false;
291+
292+
// 1. 如果当前在目录模式,自动退出目录模式
293+
if (folderNavigationState.isActive) {
294+
console.log('🔄 [换源] 检测到目录模式,自动退出目录模式');
295+
folderNavigationState.isActive = false;
296+
folderNavigationState.breadcrumbs = [];
297+
folderNavigationState.currentData = [];
298+
folderNavigationState.currentBreadcrumb = null;
299+
folderNavigationState.loading = false;
300+
301+
// 清空保存的状态
302+
previousState.activeKey = null;
303+
previousState.scrollPosition = 0;
304+
previousState.savedAt = null;
305+
}
306+
280307
getClassList(site); //获取分类列表
281308
};
282309
//获取分类列表
@@ -287,6 +314,9 @@ const getClassList = async (site) => {
287314
}
288315
289316
console.log(site, "确认换源");
317+
318+
// 2. 显示loading状态
319+
globalLoading.value = true;
290320
291321
// 先清除之前的数据,防止数据残留
292322
form.classList = {
@@ -320,6 +350,9 @@ const getClassList = async (site) => {
320350
filters: {}
321351
};
322352
form.recommendVideos = [];
353+
} finally {
354+
// 3. 隐藏loading状态
355+
globalLoading.value = false;
323356
}
324357
};
325358
const onSearch = async (value) => {
@@ -943,4 +976,38 @@ onBeforeUnmount(() => {
943976
.current-time span {
944977
font-weight: 500;
945978
}
979+
980+
/* 全局loading样式 */
981+
.global-loading-overlay {
982+
position: fixed;
983+
top: 0;
984+
left: 0;
985+
right: 0;
986+
bottom: 0;
987+
background: rgba(0, 0, 0, 0.5);
988+
display: flex;
989+
align-items: center;
990+
justify-content: center;
991+
z-index: 9999;
992+
backdrop-filter: blur(2px);
993+
}
994+
995+
.global-loading-content {
996+
display: flex;
997+
flex-direction: column;
998+
align-items: center;
999+
gap: 16px;
1000+
padding: 32px;
1001+
background: var(--color-bg-1);
1002+
border-radius: 12px;
1003+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
1004+
border: 1px solid var(--color-border-2);
1005+
}
1006+
1007+
.loading-text {
1008+
font-size: 16px;
1009+
color: var(--color-text-1);
1010+
font-weight: 500;
1011+
text-align: center;
1012+
}
9461013
</style>

0 commit comments

Comments
 (0)