Files
JayuCloud/YumiNail-Frontend/src/views/NotFoundView.vue
T

148 lines
3.1 KiB
Vue
Raw Normal View History

<template>
<div class="not-found-container">
<div class="not-found-content">
<div class="error-code">404</div>
<h1>页面不存在</h1>
<p>您访问的页面不存在或已被删除</p>
<p class="redirect-message">
将在 <span class="countdown">{{ countdown }}</span> 秒后自动跳转到首页...
</p>
<a-button type="primary" @click="redirectToHome">立即前往首页</a-button>
</div>
</div>
</template>
<script setup lang="ts">
/**
* NotFoundView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { ref, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
2026-05-23 18:44:57 +08:00
/**
* Purpose: router supports NotFoundView.vue by holding or executing the router page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const router = useRouter()
/** countdown is a reactive state variable used by the template and event handlers. */
const countdown = ref(5)
let timer: number | null = null
/** redirectToHome is a local helper used by this page script. */
const redirectToHome = () => {
if (timer) {
clearInterval(timer)
}
router.push('/home')
}
onMounted(() => {
timer = window.setInterval(() => {
if (countdown.value > 0) {
countdown.value--
} else {
if (timer) {
clearInterval(timer)
}
redirectToHome()
}
}, 1000)
})
onUnmounted(() => {
if (timer) {
clearInterval(timer)
}
})
</script>
<style scoped>
.not-found-container {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
}
.not-found-content {
background: white;
border-radius: 20px;
padding: 60px 40px;
text-align: center;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
max-width: 500px;
width: 100%;
}
.error-code {
font-size: 120px;
font-weight: bold;
color: #667eea;
margin: 0 0 20px 0;
line-height: 1;
}
.not-found-content h1 {
font-size: 28px;
font-weight: 700;
color: #333;
margin: 0 0 16px 0;
}
.not-found-content p {
font-size: 16px;
color: #666;
margin: 0 0 24px 0;
line-height: 1.6;
}
.redirect-message {
margin: 20px 0 30px 0;
color: #999;
font-size: 14px;
}
.countdown {
color: #667eea;
font-weight: bold;
font-size: 18px;
margin: 0 4px;
}
:deep(.ant-btn-primary) {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
padding: 12px 32px;
font-size: 16px;
font-weight: 600;
border-radius: 25px;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
transition: all 0.3s ease;
}
:deep(.ant-btn-primary:hover) {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}
@media (max-width: 768px) {
.not-found-content {
padding: 40px 20px;
}
.error-code {
font-size: 80px;
}
.not-found-content h1 {
font-size: 24px;
}
.not-found-content p {
font-size: 14px;
}
}
</style>