You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
837 B
48 lines
837 B
import Vue from 'vue'
|
|
import store from '../store/index.js'
|
|
import pages from '../pages.js'
|
|
// router.js
|
|
import {
|
|
RouterMount,
|
|
createRouter
|
|
} from 'uni-simple-router';
|
|
|
|
const router = createRouter({
|
|
platform: process.env.VUE_APP_PLATFORM,
|
|
routes: [...ROUTES]
|
|
});
|
|
|
|
Vue.use(Router)
|
|
|
|
// const ROUTES =
|
|
// pages().pages.map(item => ({
|
|
// path: `/${item.path}`,
|
|
// meta: item.meta || {}
|
|
// }))
|
|
//初始化
|
|
// const myrouter = new Router({
|
|
// routes: myRouter
|
|
// });
|
|
|
|
//全局路由前置守卫
|
|
router.beforeEach((to, from, next) => {
|
|
const isLogin = sessionStorage.getItem("isLogin");
|
|
if (!isLogin && to.meta.needLogin) {
|
|
next({
|
|
path: '/pages/login/index',
|
|
query: {
|
|
redirect: to.path
|
|
}
|
|
})
|
|
} else {
|
|
next()
|
|
}
|
|
|
|
})
|
|
// 全局路由后置守卫
|
|
router.afterEach((to, from) => {
|
|
})
|
|
export {
|
|
router,
|
|
RouterMount
|
|
}
|
|
|