import { RouterMount, createRouter, runtimeQuit } from 'uni-simple-router'; //配置白名单 let WHiTE_LIST=['login'] let first = null; const router = createRouter({ platform: process.env.VUE_APP_PLATFORM, APP:{ animation:{ animationType:'slide-in-top', animationDuration:300 } }, routerBeforeEach:(to, from, next) => { if (WHiTE_LIST.includes(to.name)) { next(); }else{ //拦截未登录页面并跳转到登录页面 let phone =uni.getStorageSync("phone") console.log(phone); if (phone) { next(); }else{ next({ name: 'login', params: { fullPath: to.fullPath }, NAVTYPE: 'replaceAll' }); } } }, routerAfterEach:(to, from) => { console.log('--------routerAfterEach----') }, routerErrorEach:({type,msg})=>{ console.log({type,msg}) // #ifdef APP-PLUS if(type===3){ router.$lockStatus=false; runtimeQuit(); } // #endif }, routes: [ ...ROUTES, { path: '*', redirect:(to)=>{ return {name:'404'} } }, ] }); let count=0; router.beforeEach((to, from, next) => { // if(count==0){ // next({ // path:'/pages/login/login', // NAVTYPE:'replaceAll' // }) // }else{ // next(); // } next(); count++; }); router.afterEach((to, from, next) => { console.log('afterEach---跳转结束') }); export { router, RouterMount }