Merge pull request #315 from madrays/v2

This commit is contained in:
jxxghp
2025-03-30 00:55:25 +08:00
committed by GitHub
3 changed files with 932 additions and 215 deletions
+52 -15
View File
@@ -7,25 +7,62 @@ interface Props {
errorCode?: string errorCode?: string
errorTitle?: string errorTitle?: string
errorDescription?: string errorDescription?: string
size?: number
} }
</script> </script>
<template> <template>
<VEmptyState :image="image" size="250"> <div class="no-data-container">
<template #title> <VEmptyState :image="image" :size="props.size || 'auto'">
<div class="mt-8 text-2xl"> <template #title>
{{ props.errorTitle }} <div class="mt-8 text-2xl">
</div> {{ props.errorTitle }}
</template> </div>
</template>
<template #text> <template #text>
<div class="text-subtitle mt-3"> <div class="text-subtitle mt-3">
{{ props.errorDescription }} {{ props.errorDescription }}
</div> </div>
</template> </template>
<template #actions> <template #actions>
<slot name="button" /> <slot name="button" />
</template> </template>
</VEmptyState> </VEmptyState>
</div>
</template> </template>
<style scoped>
.no-data-container {
width: 100%;
}
.no-data-container :deep(.v-empty-state) {
width: 100%;
max-width: 100%;
}
.no-data-container :deep(.v-empty-state__media) {
width: 100%;
max-width: 100%;
}
.no-data-container :deep(.v-responsive) {
width: 100%;
max-width: 450px;
margin: 0 auto;
height: auto !important;
}
/* 移动响应式设计 */
@media (max-width: 768px) {
.no-data-container :deep(.v-responsive) {
max-width: 350px;
}
}
@media (max-width: 480px) {
.no-data-container :deep(.v-responsive) {
max-width: 250px;
}
}
</style>
+38 -8
View File
@@ -64,20 +64,49 @@ const errorDescription = ref('未搜索到任何资源')
// 使用SSE监听加载进度 // 使用SSE监听加载进度
function startLoadingProgress() { function startLoadingProgress() {
progressText.value = '正在搜索,请稍候...' progressText.value = '正在搜索,请稍候...'
progressValue.value = 10 // 初始进度设为10%,确保进度条显示
progressEventSource.value = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/progress/search`) progressEventSource.value = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/progress/search`)
progressEventSource.value.onmessage = event => { progressEventSource.value.onmessage = event => {
const progress = JSON.parse(event.data) const progress = JSON.parse(event.data)
if (progress) { if (progress) {
progressText.value = progress.text progressText.value = progress.text
progressValue.value = progress.value progressValue.value = progress.value
// 搜索完成条件调整:只有明确完成时才关闭
if (progress.text.includes('完成') && progress.value >= 99) {
setTimeout(() => {
stopLoadingProgress()
}, 1000) // 延迟1秒关闭,确保用户能看到100%
}
} }
} }
// 添加错误处理
progressEventSource.value.onerror = () => {
setTimeout(() => {
stopLoadingProgress()
}, 1000)
}
// 添加安全超时,确保不会永远卡住
setTimeout(() => {
if (progressEventSource.value && progressValue.value < 100) {
stopLoadingProgress()
}
}, 60000) // 60秒超时
} }
// 停止监听加载进度 // 停止监听加载进度
function stopLoadingProgress() { function stopLoadingProgress() {
if (progressEventSource.value) progressEventSource.value?.close() if (progressEventSource.value) {
progressValue.value = 0 progressEventSource.value.close()
progressEventSource.value = undefined
}
// 确保进度显示100%,然后再渐进清零
progressValue.value = 100
setTimeout(() => {
progressValue.value = 0
}, 1500) // 延长到1.5秒,让用户有足够时间看到完成状态
} }
// 设置视图类型 // 设置视图类型
@@ -125,7 +154,7 @@ async function fetchData() {
}) })
} }
if (result && result.success) { if (result && result.success) {
dataList.value = result.data dataList.value = result.data || []
} else if (result && result.message) { } else if (result && result.message) {
errorDescription.value = result.message errorDescription.value = result.message
} }
@@ -137,6 +166,8 @@ async function fetchData() {
isRefreshed.value = true isRefreshed.value = true
} catch (error) { } catch (error) {
console.error(error) console.error(error)
stopLoadingProgress()
isRefreshed.value = true
return Promise.reject(error) return Promise.reject(error)
} }
} }
@@ -156,7 +187,7 @@ onUnmounted(() => {
<div> <div>
<!-- 加载进度条 --> <!-- 加载进度条 -->
<VFadeTransition> <VFadeTransition>
<div v-if="progressValue > 0 && progressValue < 100" class="search-progress-container"> <div v-if="progressValue > 0" class="search-progress-container">
<div class="search-progress-card"> <div class="search-progress-card">
<div class="progress-header"> <div class="progress-header">
<VIcon icon="mdi-movie-search" color="primary" size="small" class="me-2" /> <VIcon icon="mdi-movie-search" color="primary" size="small" class="me-2" />
@@ -231,9 +262,8 @@ onUnmounted(() => {
<!-- 无数据显示 --> <!-- 无数据显示 -->
<div v-else-if="isRefreshed && !isViewChanging" class="d-flex flex-column align-center justify-center py-8"> <div v-else-if="isRefreshed && !isViewChanging" class="d-flex flex-column align-center justify-center py-8">
<NoDataFound <NoDataFound
:title="errorTitle" :errorTitle="errorTitle"
:description="errorDescription" :errorDescription="errorDescription"
:image="require('@images/illustrations/no-results.png')"
/> />
<VBtn class="mt-4" color="primary" prepend-icon="mdi-magnify" to="/"> 返回首页 </VBtn> <VBtn class="mt-4" color="primary" prepend-icon="mdi-magnify" to="/"> 返回首页 </VBtn>
</div> </div>
@@ -444,7 +474,7 @@ onUnmounted(() => {
letter-spacing: 1px; letter-spacing: 1px;
} }
/* 初始加载状态 */ /* 初始加载状态 */
.initial-loading-container { .initial-loading-container {
display: flex; display: flex;
justify-content: center; justify-content: center;
File diff suppressed because it is too large Load Diff