text: import Vue from 'vue';
  import VueRouter from 'vue-router';
  
  Vue.use(VueRouter);
  
  const initRouter = () => {
    const routerParam = {
      mode: 'history',
      routes: [{
        path: '/a',
        name: 'Index',
        component: (resolve) => require(['components/startpage'], resolve)
      },
      {
        path: '/login',
        name: 'Login',
        component: (resolve) => require(['components/login/index'], resolve)
      },
      {
        path: '/register',
        name: 'Register',
        component: (resolve) => require(['components/register/index'], resolve)
      }]
    };
  
    let router = new VueRouter(routerParam);
    let isFirstRouter = true;
  
    router.beforeEach((to, from, next) => {
      if (!isFirstRouter && !isAuthPage(to.name)) {
        next({ name: 'PermissionError' });
        return;
      }
      HeyUI.$LoadingBar.start();
      if (to.meta && to.meta.title) {
        document.title = to.meta.title + ' - 管理应用';
      } else {
        document.title = '管理系统';
      }
      isFirstRouter = false;
      next();
    });
    router.afterEach(() => {
      HeyUI.$LoadingBar.success();
      document.documentElement.scrollTop = 0;
      document.body.scrollTop = 0;
      let layoutContent = document.querySelector('.h-layout-content');
      if (layoutContent) {
        layoutContent.scrollTop = 0;
      }
      // baidu 统计，如果有自己的统计，请至index.html修改至自己的埋点
      if (window._hmt) {
        window._hmt.push(['_trackPageview', window.location.pathname]);
      }
    });
    return router;
  };
  
  export default initRouter;
  