| 123456789101112131415161718192021222324252627282930313233343536373839 | import { getToken } from '@/utils/auth'// 登录页面const loginPage:string = "/pages/login"  // 页面白名单const whiteList:string[] = [  '/pages/login', '/pages/register', '/pages/common/webview/index']// 检查地址白名单function checkWhite(url:any):boolean {  const path:string = url.split('?')[0]  return whiteList.indexOf(path) !== -1}// 页面跳转验证拦截器let list:string[] = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]list.forEach((item:string) => {  uni.addInterceptor(item, {    invoke(to) {      if (getToken()) {        if (to.url === loginPage) {          uni.reLaunch({ url: "/" })        }        return true      } else {        if (checkWhite(to.url)) {          return true        }        uni.reLaunch({ url: loginPage })        return false      }    },    fail(err:any) {      console.log(err)    }  })})
 |