From 10c1041b06239cdeddb35ac979e63a2ed648597c Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 10 Apr 2026 16:07:17 +0800 Subject: [PATCH] Improve resource search loading UI --- src/pages/resource.vue | 195 +++++++++++++++++++++++++++++++++++------ 1 file changed, 169 insertions(+), 26 deletions(-) diff --git a/src/pages/resource.vue b/src/pages/resource.vue index 0f519e9a..22175b02 100644 --- a/src/pages/resource.vue +++ b/src/pages/resource.vue @@ -109,6 +109,24 @@ const progressEnabled = ref(false) // 进度是否激活 const progressActive = ref(false) +// 是否显示搜索中的页面态 +const isSearchLoading = computed( + () => !isRefreshed.value && (progressActive.value || progressEnabled.value || progressValue.value > 0), +) + +// 归一化搜索进度,避免 SSE 异常值影响显示 +const searchProgressPercent = computed(() => + Math.min(100, Math.max(0, Math.ceil(Number(progressValue.value) || 0))), +) + +// 搜索进度文案 +const searchProgressLabel = computed(() => + progressEnabled.value || progressValue.value > 0 ? `${searchProgressPercent.value}%` : '...', +) + +// 进度未返回前使用不确定态 +const searchProgressIndeterminate = computed(() => !progressEnabled.value && searchProgressPercent.value <= 0) + // 错误标题 const errorTitle = ref(t('resource.noData')) @@ -561,17 +579,60 @@ onUnmounted(() => {