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

225 lines
5.4 KiB
Vue
Raw Normal View History

<template>
<div class="not-found-container">
2026-05-31 18:36:52 +08:00
<header class="not-found-topbar">
<button class="not-found-back" type="button" aria-label="返回" @click="handleBackClick">
<LeftOutlined />
</button>
2026-06-24 22:13:00 +08:00
<strong>{{ BRAND_CONFIG.appName }}</strong>
2026-05-31 18:36:52 +08:00
<span class="not-found-topbar-spacer" aria-hidden="true"></span>
</header>
<div class="not-found-content">
2026-06-24 22:13:00 +08:00
<span class="not-found-kicker">{{ BRAND_CONFIG.appName }}</span>
<div class="error-code">404</div>
2026-05-29 13:30:56 +08:00
<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-31 18:36:52 +08:00
import { LeftOutlined } from '@ant-design/icons-vue'
2026-06-24 22:13:00 +08:00
import { BRAND_CONFIG } from '@/config/brand'
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
2026-05-31 18:36:52 +08:00
const clearRedirectTimer = () => {
if (timer) {
clearInterval(timer)
2026-05-31 18:36:52 +08:00
timer = null
}
2026-05-31 18:36:52 +08:00
}
const handleBackClick = () => {
clearRedirectTimer()
if (window.history.length > 1) {
router.back()
return
}
router.push('/home')
}
/** redirectToHome is a local helper used by this page script. */
const redirectToHome = () => {
clearRedirectTimer()
router.push('/home')
}
onMounted(() => {
timer = window.setInterval(() => {
if (countdown.value > 0) {
countdown.value--
} else {
if (timer) {
clearInterval(timer)
}
redirectToHome()
}
}, 1000)
})
onUnmounted(() => {
2026-05-31 18:36:52 +08:00
clearRedirectTimer()
})
</script>
<style scoped>
.not-found-container {
2026-05-31 18:36:52 +08:00
position: relative;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
2026-05-29 13:30:56 +08:00
background:
radial-gradient(circle at 82% 12%, color-mix(in srgb, var(--theme-primary) 30%, transparent), transparent 34%),
linear-gradient(180deg, var(--theme-tertiary), color-mix(in srgb, var(--theme-secondary) 14%, var(--theme-tertiary)));
padding: 20px;
}
2026-05-31 18:36:52 +08:00
.not-found-topbar {
position: fixed;
top: 12px;
left: 50%;
z-index: 20;
display: grid;
grid-template-columns: 40px minmax(0, 1fr) 40px;
align-items: center;
width: min(calc(100% - 32px), var(--app-mobile-max-width, 480px));
height: 44px;
transform: translateX(-50%);
}
.not-found-back {
display: inline-grid;
width: 36px;
height: 36px;
place-items: center;
border: 1px solid color-mix(in srgb, var(--theme-border) 78%, transparent);
border-radius: 999px;
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent);
box-shadow: 0 10px 24px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
cursor: pointer;
}
.not-found-topbar strong {
overflow: hidden;
color: var(--text-primary);
font-size: 16px;
font-weight: 800;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
}
.not-found-topbar-spacer {
width: 36px;
height: 36px;
}
.not-found-content {
2026-05-29 13:30:56 +08:00
background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent);
border: 1px solid var(--theme-border);
border-radius: 28px;
padding: 48px 28px;
text-align: center;
2026-05-29 13:30:56 +08:00
box-shadow: 0 24px 54px color-mix(in srgb, var(--theme-neutral) 12%, transparent);
max-width: 500px;
width: 100%;
2026-05-29 13:30:56 +08:00
backdrop-filter: blur(16px);
}
.not-found-kicker {
color: var(--theme-secondary);
font-family: Georgia, 'Times New Roman', serif;
font-size: 13px;
font-weight: 800;
}
.error-code {
2026-05-29 13:30:56 +08:00
font-size: 104px;
font-weight: 900;
color: var(--theme-primary-action);
margin: 10px 0 14px;
line-height: 1;
}
.not-found-content h1 {
font-size: 28px;
font-weight: 700;
2026-05-29 13:30:56 +08:00
color: var(--text-primary);
margin: 0 0 16px 0;
}
.not-found-content p {
font-size: 16px;
2026-05-29 13:30:56 +08:00
color: var(--text-secondary);
margin: 0 0 24px 0;
line-height: 1.6;
}
.redirect-message {
margin: 20px 0 30px 0;
2026-05-29 13:30:56 +08:00
color: var(--text-secondary);
font-size: 14px;
}
.countdown {
2026-05-29 13:30:56 +08:00
color: var(--theme-primary-action);
font-weight: bold;
font-size: 18px;
margin: 0 4px;
}
:deep(.ant-btn-primary) {
2026-05-29 13:30:56 +08:00
background: linear-gradient(135deg, var(--theme-primary-action), var(--theme-secondary));
border: none;
padding: 12px 32px;
font-size: 16px;
font-weight: 600;
border-radius: 25px;
2026-05-29 13:30:56 +08:00
box-shadow: var(--theme-button-shadow);
transition: all 0.3s ease;
}
:deep(.ant-btn-primary:hover) {
transform: translateY(-2px);
2026-05-29 13:30:56 +08:00
box-shadow: var(--theme-button-shadow);
}
@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;
}
}
2026-05-29 13:30:56 +08:00
</style>