import Vue from 'vue'
import Router from 'vue-router'

import routerBefore from '@/config/routerBefore.js'

// 主要
import main from '@/components/main.vue'
// 系统配置管理
import processDdesign from '../components/processDdesign.vue'
import processDdesign2 from '../components/processDdesign2.vue'
import processManagement from '../components/processManagement.vue'
import workFlow2 from '../components/workFlow2.vue'
import processDialog from '../components/processDialog.vue'
import processDdesign3 from '../components/processDdesign3.vue'
import coverTask from '../components/coverTask.vue'
import approvelDetails from '../components/approvelDetails.vue'
import initiateTransactions from '../components/initiateTransactions.vue'
import userApplyStart from '../components/userApplyStart.vue'
import processActiveAndHang from '../components/processActiveAndHang.vue'
import finishedTask from '../components/finishedTask.vue'
import personalInitiatedTask from '../components/personalInitiatedTask.vue'
import countTaskApply from '../components/countTaskApply.vue'
import drawerAssembly from '../components/drawerAssembly.vue'

Vue.use(Router)

const constantRouterMap = [
  {
    path: '/',
    name: 'main',
    meta: {title: '流程引擎', code: 'xtpzgl'},
    component: main,
    redirect: {name: 'processManagement'},
    children: [
      {path: 'processDdesign', name: 'processDdesign', component: processDdesign},
      {path: 'processDdesign2', name: 'processDdesign2', component: processDdesign2},
      {path: 'processManagement', name: 'processManagement', component: processManagement, meta: {keepAlive: true}},
      {path: 'workFlow2', name: 'workFlow2', component: workFlow2},
      {path: 'processDialog', name: 'processDialog', component: processDialog},
      {path: 'processDdesign3', name: 'processDdesign3', component: processDdesign3},
      {path: 'coverTask', name: 'coverTask', component: coverTask, meta: {keepAlive: true}},
      {path: 'approvelDetails', name: 'approvelDetails', component: approvelDetails},
      {path: 'initiateTransactions', name: 'initiateTransactions', component: initiateTransactions, meta: {keepAlive: true}},
      {path: 'userApplyStart', name: 'userApplyStart', component: userApplyStart},
      {path: 'processActiveAndHang', name: 'processActiveAndHang', component: processActiveAndHang},
      {path: 'finishedTask', name: 'finishedTask', component: finishedTask,  meta: {keepAlive: true}},
      {path: 'personalInitiatedTask', name: 'personalInitiatedTask', component: personalInitiatedTask, meta: {keepAlive: true}},
      {path: 'countTaskApply', name: 'countTaskApply', component: countTaskApply},
      {path: 'drawerAssembly', name: 'drawerAssembly', component: drawerAssembly}
    ]
  }
];

const router = new Router({
  // 滚动条
  // mode: 'history', // 需要框架支持history模式
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  },
  routes: constantRouterMap
})
//  before
routerBefore(router, constantRouterMap);

export default router;
//  constantRouterMap
export const routes = constantRouterMap;
