forked from vincentzyc/form-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.js
More file actions
46 lines (41 loc) · 847 Bytes
/
router.js
File metadata and controls
46 lines (41 loc) · 847 Bytes
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
import Vue from 'vue'
import Router from 'vue-router'
const vue = new Vue();
Vue.use(Router)
const checkLogin = () => localStorage.getItem("loanuser") ? "/home" : "/login"
const router = new Router({
// mode: 'history',
routes: [{
path: "/",
redirect: checkLogin()
},
{
path: "/login",
name: 'login',
component: () => import("@/views/login.vue")
},
{
path: "/home",
name: 'home',
component: () => import('@/views/home.vue')
},
{
path: '*',
name: '404',
component: () => import("@/views/404.vue")
}
]
})
router.beforeEach((to, from, next) => {
if (to.name === "login") {
next();
return;
}
localStorage.getItem("loanuser") ? next() : next('/login');
})
router.afterEach(() => {
if (window.dom_container) {
vue.$util.easeout(window.dom_container, 0, 5);
}
})
export default router