{"size": 1075, "ext": "js", "max_stars_repo_path": "src/main.js", "max_stars_repo_name": "Garens/vue-pro", "max_stars_repo_stars_event_min_datetime": "2017-05-15T04:02:44.000Z", "max_stars_repo_stars_event_max_datetime": "2017-10-02T16:48:47.000Z", "max_issues_repo_path": "src/main.js", "max_issues_repo_name": "Garens/vue-pro", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/main.js", "max_forks_repo_name": "Garens/vue-pro", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.3695652174, "max_line_length": 80, "alphanum_fraction": 0.6641860465}
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import VueRouter from 'vue-router'
import Routers from './router/index'
import iView from 'iview'
import 'iview/dist/styles/iview.css'
import store from './store/index'
import Util from './libs/util'

Vue.use(VueRouter)
Vue.use(iView)
Vue.config.productionTip = false

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

router.beforeEach((to, from, next) => {
    iView.LoadingBar.start();
    Util.title(to.meta.title);
    var isLogin = Boolean(store.state.user.name) //true用户已登录， false用户未登录
    if (!isLogin && to.path !== '/admin/login') {
        return next({ path: '/admin/login' })
    }

    next();
});

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

/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  router: router,
  render: h => h(App)
})
