2024-11-17 11:45:08 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
defineProps<{
|
|
|
|
loading: boolean
|
|
|
|
error: boolean
|
|
|
|
empty: boolean
|
2025-01-13 01:03:16 +08:00
|
|
|
errMsg?: object
|
2024-11-17 11:45:08 +08:00
|
|
|
}>()
|
|
|
|
|
2025-01-13 21:51:37 +08:00
|
|
|
const emit = defineEmits(['reload']),
|
2024-11-17 11:45:08 +08:00
|
|
|
|
2025-01-13 21:51:37 +08:00
|
|
|
handleReload = () => {
|
|
|
|
emit('reload')
|
|
|
|
}
|
2024-11-17 11:45:08 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2025-01-13 21:51:37 +08:00
|
|
|
<div
|
|
|
|
:class="{ 'justify-center': (empty || error) }"
|
|
|
|
class="container flex"
|
|
|
|
>
|
2024-11-17 11:45:08 +08:00
|
|
|
<!-- 加载骨架 -->
|
2025-01-13 21:51:37 +08:00
|
|
|
<div
|
|
|
|
v-if="loading"
|
|
|
|
class="h-56 w-full text-2xl font-bold"
|
|
|
|
>
|
2024-11-17 11:45:08 +08:00
|
|
|
<slot name="skeleton">
|
|
|
|
<div class="grid w-full grid-cols-1 gap-4 overflow-hidden sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
2025-01-13 21:51:37 +08:00
|
|
|
<div
|
|
|
|
v-for="index of 3"
|
|
|
|
:key="index"
|
|
|
|
class="h-56 animate-pulse rounded-2xl bg-gray-200"
|
|
|
|
/>
|
2024-11-17 11:45:08 +08:00
|
|
|
</div>
|
|
|
|
</slot>
|
|
|
|
</div>
|
2025-01-13 21:51:37 +08:00
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
class="w-full"
|
|
|
|
>
|
2024-11-17 11:45:08 +08:00
|
|
|
<!-- 错误处理 -->
|
2025-01-13 21:51:37 +08:00
|
|
|
<div
|
|
|
|
v-if="error"
|
|
|
|
@click="handleReload"
|
|
|
|
>
|
2025-01-13 01:03:16 +08:00
|
|
|
<div class="flex items-center justify-center gap-8">
|
2025-01-13 21:51:37 +08:00
|
|
|
<p class="text-2xl text-gray-700 border-2 border-black py-2 px-8 rounded-full rounded-br-lg">
|
|
|
|
载入错误
|
|
|
|
</p>
|
|
|
|
<img
|
|
|
|
class="h-32 w-auto relative"
|
|
|
|
src="~/assets/images/common/plana_e.png"
|
|
|
|
alt=""
|
|
|
|
>
|
2025-01-13 01:03:16 +08:00
|
|
|
</div>
|
2025-01-13 21:51:37 +08:00
|
|
|
<div
|
|
|
|
v-if="errMsg"
|
|
|
|
class="bg-white mt-4 p-4 border border-dashed rounded-md"
|
|
|
|
style="font-family: 'LXGW WenKai Mono', monospace"
|
|
|
|
>
|
2025-01-13 01:03:16 +08:00
|
|
|
{{ errMsg }}
|
|
|
|
</div>
|
2025-01-13 21:51:37 +08:00
|
|
|
<p class="text-right text-xs">
|
|
|
|
(点击重试)
|
|
|
|
</p>
|
2024-11-17 11:45:08 +08:00
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<!-- 正式内容 -->
|
2025-01-13 01:03:16 +08:00
|
|
|
<div v-if="empty">
|
2025-01-13 21:51:37 +08:00
|
|
|
<div
|
|
|
|
v-if="empty"
|
|
|
|
class="flex items-center justify-center gap-8"
|
|
|
|
@click="handleReload"
|
|
|
|
>
|
|
|
|
<p class="text-2xl text-gray-700 border-2 border-black py-2 px-8 rounded-full rounded-br-lg">
|
|
|
|
最近没有动态~
|
|
|
|
</p>
|
|
|
|
<img
|
|
|
|
class="h-32 w-auto relative"
|
|
|
|
src="~/assets/images/common/plana_e.png"
|
|
|
|
alt=""
|
|
|
|
>
|
2025-01-13 01:03:16 +08:00
|
|
|
</div>
|
2025-01-13 21:51:37 +08:00
|
|
|
<p class="text-right text-xs">
|
|
|
|
(点击重试)
|
|
|
|
</p>
|
2025-01-13 01:03:16 +08:00
|
|
|
</div>
|
|
|
|
|
2025-01-13 21:51:37 +08:00
|
|
|
<slot
|
|
|
|
v-else
|
|
|
|
name="default"
|
|
|
|
/>
|
2024-11-17 11:45:08 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
2025-01-13 21:51:37 +08:00
|
|
|
</style>
|