import modules from './modules' import Vue from 'vue' import Router from '@/plugin/uni-simple-router/index.js' import { ACCESS_TOKEN, USER_INFO } from '@/common/util/constants.js' Vue.use(Router) //初始化 const router = new Router({ encodeURI: false, routes: [...modules] //路由表 }); const whiteList = ['/pages/login/login', '/pages/fileView/fileView'] //全局路由前置守卫 router.beforeEach((to, from, next) => { let token = uni.getStorageSync(ACCESS_TOKEN); if (token) { next() } else { if (whiteList.indexOf(to.path) !== -1) { next() } else if (to.name == 'login') { next() } else if (to.name == 'zhuce') { next() } else { next({ name: "login" }) } if (whiteList.indexOf(to.path) !== -1) { } else { } } }) // 全局路由后置守卫 router.afterEach((to, from) => {}) export default router;