import?Vue?from?'vue';
import?Router?from?'vue-router';
import?home?from?'_/index/home';
import?index?from?'_/index/index';
Vue.use(Router)
const?Route?=?[
??{
????path:?'/',?//?首頁頁面
????name:?'home',
????component:?home,
????redirect:?'/home/index',
????children:?[
??????{
????????path:?'/home/index',?//?企u首頁頁面
????????name:?'index',
????????component:?index
??????},
??????{
????????path:?'/home/companyProfile',?//?企業(yè)詳情
????????name:?'companyProfile',
????????//?eslint-disable-next-line?no-undef
????????component:?resolve?=>?require(['~/home/companyProfile'],?resolve)
??????},
????]
??},
//?配置路由
const?router?=?new?Router({
??mode:?'hash',
??history:?false,
??routes:?Route,
??scrollBehavior(to,?from,?savedPosition)?{//頁面滾動的位置
????return?{?x:?0,?y:?0?}
??}
});
//?全局守衛(wèi)?控制用戶未登錄狀況下的加載
//?router.beforeEach((to,?from,?next)?=>?{
//???if?(to.matched.some(res?=>?res.meta.requireLogin))?{?//?判斷是否需要登錄
//?????//?判斷是否有登錄憑證叠骑,如果有,正常跳轉(zhuǎn),沒有返回登錄頁面或主頁焊虏,并提示
//?????if?(window.sessionStorage.getItem('token'))?{
//???????//?根據(jù)登錄時間設置過期時間?8小時
//???????let?loginTime?=?parseInt(window.sessionStorage.getItem('tokenTime'))?+?1000?*?60?*?8;
//???????let?nowTime?=?(new?Date()).getTime();?//?獲取當前時間
//???????if?(nowTime?<?loginTime)?{
//?????????next()
//???????}?else?{
//?????????//?Token?超時
//?????????Message({
//???????????showClose:?true,
//???????????message:?'登錄狀態(tài)信息過期,請重新登陸囤踩!',
//???????????type:?'error'
//?????????});
//?????????window.sessionStorage.clear();
//?????????next({
//???????????path:?'/home/index'
//?????????})
//???????}
//?????}?else?{
//???????//?沒有登錄則跳轉(zhuǎn)到登錄頁
//???????next({
//?????????path:?'/home/login'
//???????})
//?????}
//???}?else?{
//?????next()
//???}
//?});
export?default?router