工作台
This commit is contained in:
35
router/index.js
Normal file
35
router/index.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
RouterMount,
|
||||
createRouter
|
||||
} from 'uni-simple-router';
|
||||
import store from '@/store/index'
|
||||
|
||||
const router = createRouter({
|
||||
platform: process.env.VUE_APP_PLATFORM,
|
||||
routes: [...ROUTES]
|
||||
});
|
||||
|
||||
//全局路由前置守卫
|
||||
router.beforeEach((to, from, next) => {
|
||||
let isToken = store.getters.getToken === '' || uni.getStorageSync('token') === ''
|
||||
if(to.auth != undefined){
|
||||
if(to.auth && isToken){
|
||||
next({
|
||||
name: 'Auth',
|
||||
NAVTYPE: 'push'
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// 全局路由后置守卫
|
||||
router.afterEach((to, from) => {
|
||||
|
||||
})
|
||||
|
||||
export {
|
||||
router,
|
||||
RouterMount
|
||||
}
|
||||
Reference in New Issue
Block a user