// router.js import { RouterMount, createRouter } from 'uni-simple-router'; import tools from '@/common/js/tools' import store from '@/store/index' import { getPlatform } from '@/common/js/utils' import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb"; const router = createRouter({ platform: process.env.VUE_APP_PLATFORM, routes: [...ROUTES] }); //全局路由前置守卫 const whiteList = ['/','/pages/index/error','/pages/login/register','/pages/login/index','/pages/index/index'] router.beforeEach((to, from, next) => { if(to.path!=='/pages/index/error'){ let token = to.query.token; let inviteCode = to.query.inviteCode; if (token) { uni.setStorageSync('token',token); } if (inviteCode) { uni.setStorageSync('inviteCode',inviteCode); } const userToken = uni.getStorageSync('token') if(!userToken ){ if(whiteList.indexOf(to.path)<0){ next('/pages/login/index'); } } next(); }else { next(); } }); // 全局路由后置守卫 router.afterEach((to, from) => { console.log('后置守卫to------', to) if(to.path!=='/pages/index/error'){ } }) export { router, RouterMount }