Skip to content

Commit

Permalink
去掉登录权限逻辑 , 纯前端暂时
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Sep 13, 2018
1 parent e2352f7 commit 4edf431
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 39 deletions.
59 changes: 30 additions & 29 deletions src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,37 @@ import {
const whiteList = ['/login']
router.beforeEach((to, from, next) => {
NProgress.start()
if (getToken()) {
if (to.path === '/login') {
next({
path: '/'
})
} else {
if (store.getters.roles.length === 0) {
store.dispatch('GetInfo').then(res => {
const roles = res.data.Roles
store.dispatch('GenerateRoutes', {
roles
}).then(() => {
router.addRoutes(store.getters.addRouters)
next({ ...to
})
})
})
} else {
next()
}
}
next()
// if (getToken()) {
// if (to.path === '/login') {
// next({
// path: '/'
// })
// } else {
// if (store.getters.roles.length === 0) {
// store.dispatch('GetInfo').then(res => {
// const roles = res.data.Roles
// store.dispatch('GenerateRoutes', {
// roles
// }).then(() => {
// router.addRoutes(store.getters.addRouters)
// next({ ...to
// })
// })
// })
// } else {
// next()
// }
// }

} else {
if (whiteList.indexOf(to.path) !== -1) {
next()
} else {
next('/login')
NProgress.done()
}
}
// } else {
// if (whiteList.indexOf(to.path) !== -1) {
// next()
// } else {
// next('/login')
// NProgress.done()
// }
// }
})

router.afterEach(() => {
Expand Down
12 changes: 12 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ export const constantRouterMap = [
meta: { title: '首页', icon: 'dashboard', noCache: true }
}]
},

{
path: '/DouBan',
component: Layout,
redirect: '/DouBan/movie',
name:"DouBan",
title:"豆瓣查询" ,
icon:'tubiao',
children: [{ path: 'movie', name: 'movie', component: _import('DouBan/movie'),meta:{title:"热映电影"}},
{ path: 'music', name: 'music', component: _import('DouBan/music'),meta:{title:"热门音乐"}},
{ path: 'book', name: 'book', component: _import('DouBan/book'),meta:{title:"热门书籍"}}]
}
]

export default new Router({
Expand Down
25 changes: 15 additions & 10 deletions src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,26 @@ export default {
methods: {
handleLogin() {
this.loading = true;
this.$store
.dispatch("Login", this.loginForm)
.then(response => {
this.loading = false;
// this.$store
// .dispatch("Login", this.loginForm)
// .then(response => {
// this.loading = false;
setTimeout(() => {
// setTimeout(() => {
// this.$router.push({
// path: "/"
// });
// }, 2000);
// })
// .catch(error => {
// this.$message.error(error);
// this.loading = false;
// });
setTimeout(() => {
this.$router.push({
path: "/"
});
}, 2000);
})
.catch(error => {
this.$message.error(error);
this.loading = false;
});
}
}
};
Expand Down

0 comments on commit 4edf431

Please sign in to comment.