/**
 * Created by zhengguorong on 16/11/3.
 */
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const router = new Router({
  routes: [{
    path: '/',
    name: 'myHistoryTest',
    component: require('./views/myHistoryTest/myHistoryTest.vue')
  }, {
    path: '/myHistoryTest',
    name: 'myHistoryTest',
    component: require('./views/myHistoryTest/myHistoryTest.vue')
  }, {
    path: '/login',
    name: 'login',
    component: require('./views/user/login')
  }, {
    path: '/register',
    name: 'register',
    component: require('./views/user/register')
  }, {
    path: '/h5editor',
    name: 'h5editor',
    component: require('./views/h5editor/index.vue')
  }, {
    path: '/spaeditor',
    name: 'spaeditor',
    component: require('./views/spaeditor/index.vue')
  }, {
    path: '/themeList',
    name: 'themeList',
    component: require('./views/h5editor/themeList.vue')
  }, {
    path: '/spaList',
    name: 'spaList',
    component: require('./views/spaeditor/themeList.vue')
  }, {
    path: '/about',
    name: 'about',
    component: require('./views/user/about.vue')
  }, {
    path: '/cncTestLists',
    name: "cncTestLists",
    component: require('./views/cnctestlists/cncTestLists.vue')
  }]
})
router.beforeEach((to, from, next) => {
  if ((from.name == 'spaeditor' || from.name == 'h5editor') && !window.hasSaveFlag) {
    if (window.confirm('请确保已经将修改的内容保存，否则页面将丢失。是否确认退出编辑？')) {
      next()
    }
  } else {
    next()
  }
})
export default router;
