225 lines
5.4 KiB
Vue
225 lines
5.4 KiB
Vue
<template>
|
||
<div class="not-found-container">
|
||
<header class="not-found-topbar">
|
||
<button class="not-found-back" type="button" aria-label="返回" @click="handleBackClick">
|
||
<LeftOutlined />
|
||
</button>
|
||
<strong>{{ BRAND_CONFIG.appName }}</strong>
|
||
<span class="not-found-topbar-spacer" aria-hidden="true"></span>
|
||
</header>
|
||
|
||
<div class="not-found-content">
|
||
<span class="not-found-kicker">{{ BRAND_CONFIG.appName }}</span>
|
||
<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'
|
||
import { LeftOutlined } from '@ant-design/icons-vue'
|
||
import { BRAND_CONFIG } from '@/config/brand'
|
||
|
||
/**
|
||
* 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
|
||
|
||
const clearRedirectTimer = () => {
|
||
if (timer) {
|
||
clearInterval(timer)
|
||
timer = null
|
||
}
|
||
}
|
||
|
||
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(() => {
|
||
clearRedirectTimer()
|
||
})
|
||
</script>
|
||
|
||
<style scoped>
|
||
.not-found-container {
|
||
position: relative;
|
||
min-height: 100vh;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
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;
|
||
}
|
||
|
||
.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 {
|
||
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;
|
||
box-shadow: 0 24px 54px color-mix(in srgb, var(--theme-neutral) 12%, transparent);
|
||
max-width: 500px;
|
||
width: 100%;
|
||
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 {
|
||
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;
|
||
color: var(--text-primary);
|
||
margin: 0 0 16px 0;
|
||
}
|
||
|
||
.not-found-content p {
|
||
font-size: 16px;
|
||
color: var(--text-secondary);
|
||
margin: 0 0 24px 0;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.redirect-message {
|
||
margin: 20px 0 30px 0;
|
||
color: var(--text-secondary);
|
||
font-size: 14px;
|
||
}
|
||
|
||
.countdown {
|
||
color: var(--theme-primary-action);
|
||
font-weight: bold;
|
||
font-size: 18px;
|
||
margin: 0 4px;
|
||
}
|
||
|
||
:deep(.ant-btn-primary) {
|
||
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;
|
||
box-shadow: var(--theme-button-shadow);
|
||
transition: all 0.3s ease;
|
||
}
|
||
|
||
:deep(.ant-btn-primary:hover) {
|
||
transform: translateY(-2px);
|
||
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;
|
||
}
|
||
}
|
||
</style>
|