调整路由拦截模式
This commit is contained in:
@@ -8,6 +8,11 @@
|
||||
import { RouterMount, createRouter } from 'uni-simple-router';
|
||||
import store from '../store/index'
|
||||
|
||||
// const ROUTESPATH = ROUTES.map(val => {
|
||||
// val.component: ()=> import('@/' + val.path + '.vue')
|
||||
// console.log(val)
|
||||
// })
|
||||
|
||||
const router = createRouter({
|
||||
platform: process.env.VUE_APP_PLATFORM,
|
||||
routes: [...ROUTES]
|
||||
@@ -17,7 +22,10 @@ const router = createRouter({
|
||||
router.beforeEach((to, from, next) => {
|
||||
const token = store.getters.getToken || uni.getStorageSync('token')
|
||||
// 检查是否需要登录
|
||||
if(to.meta.auth && token === ''){
|
||||
if(to.auth && token === ''){
|
||||
next({
|
||||
name: 'Login'
|
||||
})
|
||||
return
|
||||
}
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user