Skip to content

Commit 7880389

Browse files
committed
'新增403页面'
1 parent 6e54b70 commit 7880389

File tree

6 files changed

+72
-3
lines changed

6 files changed

+72
-3
lines changed

src/components/common/Sidebar.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
icon: 'el-icon-warning',
7878
index: 'permission',
7979
title: '权限测试'
80+
},
81+
{
82+
icon: 'el-icon-error',
83+
index: '404',
84+
title: '404页面'
8085
}
8186
]
8287
}

src/components/page/403.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div class="error-page">
3+
<div class="error-code">4<span>0</span>3</div>
4+
<div class="error-desc">啊哦~ 你没有权限访问该页面哦</div>
5+
<div class="error-handle">
6+
<router-link to="/readme">
7+
<el-button type="primary" size="large">返回首页</el-button>
8+
</router-link>
9+
<el-button class="error-btn" type="primary" size="large" @click="goBack">返回上一页</el-button>
10+
</div>
11+
</div>
12+
</template>
13+
14+
<script>
15+
export default {
16+
methods: {
17+
goBack(){
18+
this.$router.go(-1);
19+
}
20+
}
21+
}
22+
</script>
23+
24+
25+
<style scoped>
26+
.error-page{
27+
display: flex;
28+
justify-content: center;
29+
align-items: center;
30+
flex-direction: column;
31+
width: 100%;
32+
height: 100%;
33+
background: #f3f3f3;
34+
box-sizing: border-box;
35+
}
36+
.error-code{
37+
line-height: 1;
38+
font-size: 250px;
39+
font-weight: bolder;
40+
color: #f02d2d;
41+
}
42+
.error-code span{
43+
color: #00a854;
44+
}
45+
.error-desc{
46+
font-size: 30px;
47+
color: #777;
48+
}
49+
.error-handle{
50+
margin-top: 30px;
51+
padding-bottom: 200px;
52+
}
53+
.error-btn{
54+
margin-left: 100px;
55+
}
56+
</style>

src/components/page/404.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="error-code">4<span>0</span>4</div>
44
<div class="error-desc">啊哦~ 你所访问的页面不存在</div>
55
<div class="error-handle">
6-
<router-link to="/">
6+
<router-link to="/readme">
77
<el-button type="primary" size="large">返回首页</el-button>
88
</router-link>
99
<el-button class="error-btn" type="primary" size="large" @click="goBack">返回上一页</el-button>

src/components/page/Permission.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</div>
88
<div class="container">
99
<h1>管理员权限页面</h1>
10-
<p>只有用 admin 账号登录的才拥有管理员权限,才能进到这个页面,其他账号想进来都会跳到登录页面,重新用管理员账号登录才有权限。</p>
10+
<p>只有用 admin 账号登录的才拥有管理员权限,才能进到这个页面,其他账号想进来都会跳到403页面,重新用管理员账号登录才有权限。</p>
1111
<p>想尝试一下,请<router-link to="/login" class="logout">退出登录</router-link>,随便输入个账号名,再进来试试看。</p>
1212
</div>
1313

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ router.beforeEach((to, from, next) => {
1515
if(to.meta.permission){
1616
const role = localStorage.getItem('ms_username');
1717
// 如果是管理员权限则可进入,这里只是简单的模拟管理员权限而已
18-
role === 'admin' ? next() : next('/login');
18+
role === 'admin' ? next() : next('/403');
1919
}else{
2020
// 简单的判断IE10及以下不进入富文本编辑器,该组件不兼容
2121
if(navigator.userAgent.indexOf('MSIE') > -1 && to.path === '/editor'){

src/router/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,13 @@ export default new Router({
7575
path: '/404',
7676
component: resolve => require(['../components/page/404.vue'], resolve)
7777
},
78+
{
79+
path: '/403',
80+
component: resolve => require(['../components/page/403.vue'], resolve)
81+
},
82+
{
83+
path: '*',
84+
redirect: '/404'
85+
}
7886
]
7987
})

0 commit comments

Comments
 (0)