Skip to content

Commit 1d885a2

Browse files
committed
feat: enhance NotFound component with improved layout and navigation
1 parent 2ce09e5 commit 1d885a2

File tree

2 files changed

+72
-6
lines changed

2 files changed

+72
-6
lines changed
Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,73 @@
1+
<script setup>
2+
import { useRouter } from 'vitepress'
3+
4+
const router = useRouter()
5+
6+
const goHome = () => {
7+
router.go('/')
8+
}
9+
</script>
10+
111
<template>
2-
<div
3-
style="padding: 2rem; text-align: center; display: flex; flex-direction: column; align-items: center; height: 100%">
4-
<img src="/404-seio.png" alt="404 Not Found" style="max-width: 400px; margin-bottom: 1rem;" />
5-
<h1>😢 你来到了未知的领域,页面不存在!请点击左上角 Logo 返回首页。</h1>
12+
<div class="NotFound">
13+
<img src="/404-seio.png" alt="404 Not Found" class="not-found-image" />
14+
<h1 class="not-found-title">😢 你来到了未知的领域,页面不存在!</h1>
15+
<p class="not-found-desc">请点击左上角 Logo 返回首页,或点击下方按钮。</p>
16+
<button @click="goHome" class="not-found-button">返回首页</button>
617
</div>
7-
</template>
18+
</template>
19+
20+
<style scoped>
21+
.NotFound {
22+
padding: 4rem 2rem;
23+
text-align: center;
24+
display: flex;
25+
flex-direction: column;
26+
align-items: center;
27+
justify-content: center;
28+
min-height: 60vh;
29+
}
30+
31+
.not-found-image {
32+
max-width: 400px;
33+
width: 100%;
34+
margin-bottom: 2rem;
35+
}
36+
37+
.not-found-title {
38+
font-size: 1.5rem;
39+
margin-bottom: 1rem;
40+
color: var(--vp-c-text-1);
41+
}
42+
43+
.not-found-desc {
44+
font-size: 1rem;
45+
margin-bottom: 2rem;
46+
color: var(--vp-c-text-2);
47+
}
48+
49+
.not-found-button {
50+
padding: 0.75rem 1.5rem;
51+
font-size: 1rem;
52+
color: #fff;
53+
background-color: var(--vp-c-brand-1);
54+
border: none;
55+
border-radius: 8px;
56+
cursor: pointer;
57+
transition: background-color 0.2s;
58+
}
59+
60+
.not-found-button:hover {
61+
background-color: var(--vp-c-brand-2);
62+
}
63+
64+
@media (max-width: 768px) {
65+
.not-found-image {
66+
max-width: 300px;
67+
}
68+
69+
.not-found-title {
70+
font-size: 1.25rem;
71+
}
72+
}
73+
</style>

.vitepress/theme/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import NotFound from './components/NotFound.vue'
1111
/** @type {import('vitepress').Theme} */
1212
export default {
1313
extends: DefaultTheme,
14-
Layout: () => {
14+
Layout() {
1515
return h(DefaultTheme.Layout, null, {
1616
// https://vitepress.dev/guide/extending-default-theme#layout-slots
1717
"aside-outline-after": () => h(ArticleShare),

0 commit comments

Comments
 (0)