根据当前环境设置路由跳转方式

This commit is contained in:
wangxiaowei 2024-09-02 18:05:04 +08:00
parent 378ae54916
commit f6c2d8fb6e

@ -74,13 +74,23 @@ router.beforeEach((to, from, next) => {
// #endif // #endif
console.log(to,from, 'beforeEach---开始跳转')
let index = whiteList.findIndex((item) => from.path.includes(item)) let index = whiteList.findIndex((item) => from.path.includes(item))
if (index == -1 && !store.getters.token) { if (index == -1 && !store.getters.token) {
Cache.set(BACK_URL, from.fullPath) Cache.set(BACK_URL, from.fullPath)
} }
if (to.meta.auth && !store.getters.token) { if (to.meta.auth && !store.getters.token) {
// #ifdef APP-PLUS
next(false)
uni.navigateTo({
url: '/pages/login/login'
})
// #endif
// #ifdef H5
next('/pages/login/login'); next('/pages/login/login');
// #endif
// #ifdef MP
next('/pages/login/login');
// #endif
return return
} else { } else {
next() next()