优化loading加载

This commit is contained in:
我若为王 2024-12-13 14:43:48 +08:00
parent 7abd79dde8
commit 8dc4b8a6f1
2 changed files with 50 additions and 16 deletions

View File

@ -39,14 +39,29 @@
<script setup> <script setup>
import { GithubOutlined } from '@ant-design/icons-vue' import { GithubOutlined } from '@ant-design/icons-vue'
import { ref, onMounted } from 'vue' import { ref, onMounted, onBeforeUnmount } from 'vue'
const loading = ref(true) const loading = ref(true)
onMounted(() => { const checkPageLoaded = () => {
setTimeout(() => { if (document.readyState === 'complete') {
loading.value = false loading.value = false
}, 300) }
}
onMounted(() => {
//
if (document.readyState === 'complete') {
loading.value = false
} else {
//
window.addEventListener('load', checkPageLoaded)
}
})
onBeforeUnmount(() => {
//
window.removeEventListener('load', checkPageLoaded)
}) })
</script> </script>

View File

@ -5,27 +5,46 @@
<main class="max-h-screen bg-gray-100 p-4"> <main class="max-h-screen bg-gray-100 p-4">
<div class="mx-auto w-full max-w-3xl mb-8"> <div class="mx-auto w-full max-w-3xl mb-8">
<div class="space-y-4"> <div class="space-y-4">
<NuxtLink to="/alipan-tv-token" class="block"> <template v-for="tool in tools" :key="tool.id">
<NuxtLink v-if="tool.available" :to="tool.path" class="block">
<a-card hoverable> <a-card hoverable>
<template #title> <template #title>
<h2 class="text-xl font-medium text-gray-800">阿里云盘TV授权</h2> <h2 class="text-xl font-medium" :class="tool.available ? 'text-gray-800' : 'text-gray-400'">
{{ tool.title }}
</h2>
</template> </template>
<p class="text-gray-600">获取阿里云盘TV端的授权令牌</p> <p :class="tool.available ? 'text-gray-600' : 'text-gray-400'">{{ tool.description }}</p>
</a-card> </a-card>
</NuxtLink> </NuxtLink>
<a-card v-else hoverable>
<a-card hoverable>
<template #title> <template #title>
<h2 class="text-xl font-medium text-gray-400">敬请期待</h2> <h2 class="text-xl font-medium text-gray-400">{{ tool.title }}</h2>
</template> </template>
<p class="text-gray-400">更多工具正在开发中...</p> <p class="text-gray-400">{{ tool.description }}</p>
</a-card> </a-card>
</template>
</div> </div>
</div> </div>
</main> </main>
</template> </template>
<script setup> <script setup>
const tools = [
{
id: 1,
title: '阿里云盘TV授权',
description: '获取阿里云盘TV端的授权令牌',
path: '/alipan-tv-token',
available: true
},
{
id: 2,
title: '敬请期待',
description: '更多工具正在开发中...',
path: '',
available: false
}
];
</script> </script>
<style scoped> <style scoped>