import localstorage from './localstorage.service.js'
export default{
	init: function (router) {
		router.beforeEach((to, form, next) => {
			let token = localstorage.get('token')
			if (to.meta && !to.meta.allowBack && window.history && window.history.pushState) { //登录页面不能后退
				history.pushState(null, null, document.URL)
			}
			if (to.name =='login' || to.name =='update' || to.name =='sweepCode'|| to.name== 'resumeDetail'|| to.name== 'pdfdetail'){
				next()
				return
			}
			if(!token){
				window.location.href = `${window.location.origin}/login`
				return
			}
			next()
		})
	}
}