import Vue from 'vue';
import iView from 'iview';
import VueRouter from 'vue-router';
import Routers from './router';
import {title} from './libs/cookieUtil';
import App from './app.vue';
import 'iview/dist/styles/iview.css';
import store from './store'
import config from './config'

Vue.use(VueRouter);
Vue.use(iView);

require('./mock')

/**
 * @description 全局注册应用配置
 */
Vue.prototype.$config = config

// 路由配置
const RouterConfig = {
    mode: 'history',
    routes: Routers
};
const router = new VueRouter(RouterConfig);

router.beforeEach((to, from, next) => {
    iView.LoadingBar.start();
    title(to.meta.title);
    next();
});

router.afterEach((to, from, next) => {
    iView.LoadingBar.finish();
    window.scrollTo(0, 0);
});

new Vue({
    el: '#app',
    router: router,
    store,
    render: h => h(App)
});
