You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import uniCrazyRouter from "uni-crazy-router" ;
export function setupRouter ( app ) {
// 接收vue3的实例, 并注册uni-crazy-router
app . use ( uniCrazyRouter )
}
const whiteList = [ 'pages/login/login' ] ;
// const whiteList = [];
uniCrazyRouter . beforeEach ( async ( to , from , next ) => {
console . log ( 'beforEach router' )
const path = to . url ;
const uInfo = uni . getStorageSync ( 'uInfo' ) || null ;
if ( whiteList . includes ( path ) ) {
next ( ) ;
return ;
}
if ( uInfo ) {
next ( ) ;
return ;
}
uniCrazyRouter . afterNotNext ( ( ) => {
uni . navigateTo ( { url : '/pages/login/login' } )
// if (uInfo) {
// uni.navigateTo({url: '/pages/index/index'})
// } else {
// uni.navigateTo({url: '/pages/login/login'})
// }
} )
} )
uniCrazyRouter . afterEach ( ( to , from ) => {
console . log ( 'afterEach router' )
// 逻辑代码
} )
uniCrazyRouter [ 'on' + 'Error' ] ( ( to , from ) => {
} )