import Vue from 'vue';
import Router from 'vue-router';
import routes from './router';
import Utils from '@/extend/Utils';
import HttpRequest from '@/extend/HttpRequest';

Vue.use(Router);

const router = new Router({
    routes,
    mode: 'history'
});

// 验证路由内 name
const verify_router_list: string[] = ['index', 'other', 'login'];

// 跳转之前
router.beforeEach((to, from, next) => {
    //  next();
    // let token = HttpRequest.getInstance().getToken('refresh_token');
    // if (Utils.getInstance().inArray(to.name, verify_router_list) === false && !token) {
    //     // 跳转路径在验证路由内且未登录,跳转至登录
    //     Utils.getInstance().setCookie('org_url',from.name);
    //     next({name: 'login'});
    // } else if (token && to.name === 'login') {
    //     // 已登录且要跳转的页面是登录页
    //     next({name: 'index', replace: true});
    // } else {
    //     next();
    // }

    next();

});


// 跳转之后
router.afterEach(to => {
    //
});

export default router;
