Skip to content

Commit e361dc6

Browse files
author
12345678
committed
问题修改
1 parent 190a74c commit e361dc6

File tree

13 files changed

+451
-75
lines changed

13 files changed

+451
-75
lines changed

.DS_Store

0 Bytes
Binary file not shown.

src/.DS_Store

10 KB
Binary file not shown.

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export default {
1818
-moz-osx-font-smoothing: grayscale;
1919
text-align: center;
2020
color: #2c3e50;
21-
margin-top: 60px;
21+
margin-top: 150px;
2222
}
2323
</style>

src/assets/.DS_Store

6 KB
Binary file not shown.

src/assets/logo.png

66.1 KB
Loading

src/assets/user.png

82.6 KB
Loading

src/router/index.js

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,62 @@
11
import Vue from 'vue'
22
import Router from 'vue-router'
3-
// import HelloWorld from '@/components/HelloWorld'
43
import Login from '@/views/Login'
5-
import Home from '@/views/Home'
64
import NotFound from '@/views/404'
5+
import Home from '@/views/Home'
6+
import Main from '@/views/Main'
7+
import User from '@/views/User'
8+
import Menu from '@/views/Menu'
9+
10+
11+
712

813
Vue.use(Router)
914

10-
export default new Router({
15+
const router = new Router({
1116
routes: [
12-
// {
13-
// path: '/',
14-
// name: 'HelloWorld',
15-
// component: HelloWorld
16-
// },
1717
{
1818
path: '/',
19-
name: 'Home',
20-
component: Home
19+
name: '首页',
20+
component: Home,
21+
children: [
22+
{ path: '/main', component: Main, name: '系统介绍' },
23+
{ path: '/user', component: User, name: '用户管理' },
24+
{ path: '/menu', component: Menu, name: '菜单管理' }
25+
]
2126
},
27+
2228
{
2329
path: '/login',
24-
name: 'Login',
30+
name: '登录',
2531
component: Login
26-
},
27-
{
32+
}
33+
,{
2834
path: '/404',
2935
name: 'notFound',
3036
component: NotFound
3137
}
3238
]
33-
})
39+
})
40+
41+
router.beforeEach((to, from, next) => {
42+
// 登录界面登录成功之后,会把用户信息保存在会话
43+
// 存在时间为会话生命周期,页面关闭即失效。
44+
let user = sessionStorage.getItem('user');
45+
if (to.path == '/login') {
46+
// 如果是访问登录界面,如果用户会话信息存在,代表已登录过,跳转到主页
47+
if(user) {
48+
next({ path: '/' })
49+
} else {
50+
next()
51+
}
52+
} else {
53+
// 如果访问非登录界面,且户会话信息不存在,代表未登录,则跳转到登录界面
54+
if (!user) {
55+
next({ path: '/login' })
56+
} else {
57+
next()
58+
}
59+
}
60+
})
61+
62+
export default router

src/views/404.vue

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,61 @@
11
<template>
2-
<div>
3-
<h4>404 Page</h4>
2+
<div class="site-wrapper site-page--not-found">
3+
<div class="site-content__wrapper">
4+
<div class="site-content">
5+
<h2 class="not-found-title">404</h2>
6+
<p class="not-found-desc">抱歉!您访问的页面<em>失联</em>啦 ...</p>
7+
<el-button @click="$router.go(-1)">返回上一页</el-button>
8+
<el-button type="primary" class="not-found-btn-gohome" @click="$router.push({ name: 'home' })">进入首页</el-button>
9+
</div>
410
</div>
11+
</div>
512
</template>
13+
614
<script>
7-
export default {
8-
name:'notFound'
9-
}
15+
export default {
16+
}
1017
</script>
11-
<style scoped lang='scss'>
1218

19+
<style lang="scss">
20+
.site-wrapper.site-page--not-found {
21+
position: absolute;
22+
top: 0;
23+
right: 0;
24+
bottom: 0;
25+
left: 0;
26+
overflow: hidden;
27+
.site-content__wrapper {
28+
padding: 0;
29+
margin: 0;
30+
background-color: #fff;
31+
}
32+
.site-content {
33+
position: fixed;
34+
top: 15%;
35+
left: 50%;
36+
z-index: 2;
37+
padding: 30px;
38+
text-align: center;
39+
transform: translate(-50%, 0);
40+
}
41+
.not-found-title {
42+
margin: 20px 0 15px;
43+
font-size: 8em;
44+
font-weight: 500;
45+
color: rgb(55, 71, 79);
46+
}
47+
.not-found-desc {
48+
margin: 0 0 30px;
49+
font-size: 26px;
50+
text-transform: uppercase;
51+
color: rgb(118, 131, 143);
52+
> em {
53+
font-style: normal;
54+
color: #ee8145;
55+
}
56+
}
57+
.not-found-btn-gohome {
58+
margin-left: 30px;
59+
}
60+
}
1361
</style>

0 commit comments

Comments
 (0)