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) => {
	let isToken = store.getters.getToken === '' || uni.getStorageSync('token') === ''
	if(to.auth != undefined){
		if(to.auth && isToken){
			next({
				name: 'Auth',
				NAVTYPE: 'push'
			})
			return
		}
	}
    next();
});

// 全局路由后置守卫
router.afterEach((to, from) => {
	
})

export {
    router,
    RouterMount
}
