易货app
This commit is contained in:
44
router/index.js
Normal file
44
router/index.js
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Web唐明明
|
||||
* 匆匆数载恍如梦,岁月迢迢华发增。
|
||||
* 碌碌无为枉半生,一朝惊醒万事空。
|
||||
* moduleName: router
|
||||
*/
|
||||
|
||||
import { RouterMount, createRouter } from 'uni-simple-router';
|
||||
import store from '../store/index'
|
||||
|
||||
const router = createRouter({
|
||||
platform: process.env.VUE_APP_PLATFORM,
|
||||
routes: [...ROUTES]
|
||||
})
|
||||
|
||||
// 全局路由前置守卫
|
||||
router.beforeEach((to, from, next) => {
|
||||
const token = store.getters.getToken || uni.getStorageSync('token')
|
||||
if(to.meta.auth && token === ''){
|
||||
next({
|
||||
name: 'Login',
|
||||
NAVTYPE: 'replaceAll'
|
||||
})
|
||||
return
|
||||
}
|
||||
if(to.name === 'Welcome'){
|
||||
next({
|
||||
name: 'ChainIndex',
|
||||
NAVTYPE: 'replaceAll'
|
||||
})
|
||||
return
|
||||
}
|
||||
next();
|
||||
})
|
||||
|
||||
// 全局路由后置守卫
|
||||
router.afterEach((to, from) => {
|
||||
// console.log('跳转结束--暂无应用场景')
|
||||
})
|
||||
|
||||
export {
|
||||
router,
|
||||
RouterMount
|
||||
}
|
||||
Reference in New Issue
Block a user