Skip to content

Commit 796029d

Browse files
committed
feat: add custom 404 error page
1 parent 259bc60 commit 796029d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

app/error.vue

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<script setup>
2+
const router = useRouter()
3+
const { currentRoute } = router
4+
const currentPath = currentRoute.value.fullPath
5+
const targetUrl = `https://to.ntut.club${currentPath}`
6+
// async function checkUrl() {
7+
// const response = await fetch(targetUrl, { method: 'GET' });
8+
// if(response.ok){
9+
// console.log(targetUrl);
10+
// window.location.href = targetUrl;
11+
// }
12+
// }
13+
14+
// onMounted(() => {
15+
// checkUrl();
16+
// })
17+
</script>
18+
19+
<template>
20+
<div class="error-page">
21+
<h1>404 - 找不到頁面</h1>
22+
<p>抱歉,<strong>小N</strong>找不到您所請求的頁面:<br><a href="#">https://ntut.club{{ currentPath }}</a></p>
23+
<NuxtLink to="/">
24+
返回首頁
25+
</NuxtLink>
26+
<br>
27+
<br>
28+
<NuxtLink :to="targetUrl">
29+
<button>
30+
嘗試在 <strong>Shorts 短網址</strong>尋找此路徑
31+
</button>
32+
</NuxtLink>
33+
</div>
34+
</template>
35+
36+
<style scoped>
37+
.error-page {
38+
text-align: center;
39+
padding: 4rem;
40+
}
41+
</style>

0 commit comments

Comments
 (0)