/*
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-09-29 16:08:12
 * @LastEditTime: 2019-09-29 18:00:17
 * @LastEditors: Please set LastEditors
 */
import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)
const route = new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: resolve => require(['@/pages/home/main'], resolve)
    },
    {
      path:'/PersonalCenter',
      name:'PersonalCenter',
      component:resolve=>require(['@/pages/PersonalCenter/index'],resolve)
    },
    //赛果
    {
      path:'/ResultMatch',
      name:'ResultMatch',
      component:resolve=>require(['@/pages/ResultMatch/index'],resolve)
    },
    //赛事规则
    {
      path:'/RuleMatch',
      name:'RuleMatch',
      component:resolve=>require(['@/pages/RuleMatch/index'],resolve)
    }
  ],
  scrollBehavior(to,from,savedPosition){
    if(savedPosition){
      return savedPosition;
    }else{
      return {x:0,y:0}
    }
  },
})

/**
 * 前置守卫
 */
route.beforeEach((to, from, next) => {
  //to.query.isTrue =true;
  //console.log(from);
  /**
   * 拦截头部导航页面跳转
   */
  if (to.path == '/StRollBallpage') {
    to.query.isTrue = true;
    //console.log(to);
  }
  next();

})

export default route
