NotFound.vue
1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<script setup lang="ts">
import { useRouter } from "vue-router";
const router = useRouter();
const goHome = () => {
// router.push("/home");
console.log("goHome");
// 检查 localStorage 中是否存在 token
const TOKEN_KEY = "scrm_access_token";
const token = localStorage.getItem(TOKEN_KEY);
if (!token) {
// 如果没有 token,跳转到登录页面
// 登录页是基座应用的页面,直接使用绝对路径
window.location.href = "/login";
} else {
// 有 token,跳转到首页
router.push("/");
}
};
</script>
<template>
<div class="not-found-page">
<div class="not-found-content">
<div class="error-code">
404
</div>
<h2 class="error-title">
页面未找到
</h2>
<p class="error-desc">
抱歉,您访问的页面不存在
</p>
<button class="back-button" @click="goHome">
返回首页
</button>
</div>
</div>
</template>
<style scoped>
.not-found-page {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
padding: 60px 20px;
background: #fff;
}
.not-found-content {
color: #383838;
text-align: center;
}
.error-code {
margin-bottom: 24px;
font-size: 120px;
font-weight: 700;
line-height: 1;
text-shadow: 0 4px 8px rgb(0 0 0 / 20%);
}
.error-title {
margin-bottom: 16px;
font-size: 32px;
font-weight: 600;
}
.error-desc {
margin-bottom: 32px;
font-size: 16px;
opacity: 0.9;
}
.back-button {
padding: 12px 32px;
font-size: 16px;
font-weight: 500;
color: #fff;
cursor: pointer;
background: #1956fe;
border: none;
border-radius: 24px;
box-shadow: 0 4px 12px rgb(31 86 254 / 25%);
transition: all 0.3s;
}
.back-button:hover {
background: #1443d8;
box-shadow: 0 6px 16px rgb(31 86 254 / 35%);
transform: translateY(-2px);
}
</style>