重构优化框架
这是一个大版本的更新 现在,框架更加稳定
This commit is contained in:
18
Yi.Vue2.x/src/permission.js
Normal file
18
Yi.Vue2.x/src/permission.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import router from './router/index'
|
||||
import store from './store/index'
|
||||
// import accountApi from '@/api/accountApi'
|
||||
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const user = store.state.user.user; //获取是有user
|
||||
if (!user) { //如果没有登入
|
||||
if (to.path == '/login/' || to.path == '/register/' || to.path == '/reset_password/' || to.path == '/qq/') {
|
||||
next();
|
||||
} else {
|
||||
next({ path: '/login/' });
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user