import en from "../i18n/lang/en"
import Vue from "vue"
import Router from "vue-router"
import Login from "@/views/login/index"
import Layout from "@/views/layout/layout"
import HomeMain from "@/views/index/mainIndex"


// 不是必须加载的组件使用懒加载
const NotFound = () => import("@/views/page404")
const ExaminationPaper = () => import("@/views/examinationPaper/index")
const ExaminationPaperAdd = () => import("@/views/examinationPaper/add")
const ExaminationPaperEdit = () => import("@/views/examinationPaper/edit")
const ExaminationPaperRecycle = () => import("@/views/examinationPaper/recycle")
const ExaminationPaperArchiving = () => import("@/views/examinationPaper/archiving")
const Portrait = () => import("@/views/portrait/index")
const PortraitDetail = () => import("@/views/portrait/detail")
const CSExaminationPaper = () => import("@/views/examinationPaper/index")
// const CSExaminationPaperAdd = () => import("@/views/standard/examinationPaper/add")
// const CSExaminationPaperEdit = () => import("@/views/standard/examinationPaper/edit")
// const CSExaminationPaperRecycle = () => import("@/views/standard/examinationPaper/recycle")
const CSExaminationPaperAdd = () => import("@/views/examinationPaper/add")
const CSExaminationPaperEdit = () => import("@/views/examinationPaper/edit")
const CSExaminationPaperRecycle = () => import("@/views/examinationPaper/recycle")


const Ask = () => import("@/views/standard/ask/index")
const AskAnalysis = () => import("@/views/standard/ask/analysis")
const AskArchiving = () => import("@/views/standard/ask/archiving")
const Test = () => import("@/views/standard/test/index")
const TestAnalysis = () => import("@/views/standard/test/analysis")
const TestArchiving = () => import("@/views/standard/test/archiving")
const DataSync = () => import("@/views/standard/dataSync/index")
const Card = () => import("@/views/standard/card/index")
const Analysis = () => import("@/views/standard/analysis/index")
const Device = () => import("@/views/standard/device/index")
const DeviceLog = () => import("@/views/standard/device/log")
const Down = () => import("@/views/standard/down/index")
const DownClient = () => import("@/views/standard/down/client")
const SetUpAccount = () => import("@/views/standard/setUp/account")
const SetUpConglomerate = () => import("@/views/standard/setUp/conglomerate")
const SetUpSchool = () => import("@/views/standard/setUp/school")
const SetUpTeacher = () => import("@/views/standard/setUp/teacher")
const SetUpStudent = () => import("@/views/standard/setUp/student")
const ArchivedClazz = () => import("@/views/standard/setUp/archivedClazz")


const PersonalAsk = () => import("@/views/personal/ask/index")
const PersonalAskAnalysis = () => import("@/views/personal/ask/analysis")
const PersonalArchiving = () => import("@/views/personal/ask/archiving")
const PersonalTest = () => import("@/views/personal/test/index")
const PersonalTestAnalysis = () => import("@/views/personal/test/analysis")
const PersonalTestArchiving = () => import("@/views/personal/test/archiving")
const PersonalDataSync = () => import("@/views/personal/dataSync/index")
const PersonalSetUpStudent = () => import("@/views/personal/setUp/student")
const PersonalDown = () => import("@/views/personal/down/index")
const PersonalUserInfo = () => import("@/views/personal/userInfo/index")

const AdminDevice = () => import("@/views/admin/device/index")
const AdminDeviceLog = () => import("@/views/admin/device/log")
const AdminAccount = () => import("@/views/admin/account/index")
const AdminClientVersion = () => import("@/views/admin/clientVersion/index")

/**
 * v1.4 
 */
const SetUpClazz = () => import("@/views/standard/setUp/clazz")
const Archived = () => import("@/views/standard/setUp/archived")
const DeviceError = () => import("@/views/standard/device/error")

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}
Vue.use(Router)
let routeName = en.routeName
let defaultRouter = [
  {
    path: "/",
    redirect: "/index",
    hidden: true,
    children: []
  },
  {
    path: "/login",
    component: Login,
    name: "登录",
    hidden: true,
    children: []
  },
  {
    path: "/index",
    iconCls: "fa fa-home", // 图标样式class
    name: "应用首页",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/index",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "主页",
        component: HomeMain,
        children: []
      }
    ]
  },
  {
    path: "/deviceError",
    iconCls: "fa fa-home", // 图标样式class
    name: "异常设备信息",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/deviceError",
        name: "异常设备信息",
        component: DeviceError,
        hidden: true
      }
    ]
  },
  {
    path: "/userInfo",
    iconCls: "fa fa-user", // 图标样式class
    name: "个人信息",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/userInfo",
        iconCls: "fa fa-user", // 图标样式class
        name: "个人信息",
        component: PersonalUserInfo,
        children: []
      }
    ]
  },
  {
    path: "/404",
    component: NotFound,
    name: "404",
    hidden: true,
    children: []
  }
]

let addrouters = [
  {
    path: "/examinationPaper",
    iconCls: "fa fa-file-text", // 图标样式class
    name: "备题组卷",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/examinationPaper",
        iconCls: "fa fa-file-text", // 图标样式class
        name: "examinationPaper",
        component: ExaminationPaper,
        children: []
      },
      {
        path: "/examinationPaperAdd",
        iconCls: "", // 图标样式class
        name: "examinationPaperAdd",
        component: ExaminationPaperAdd,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperEdit",
        iconCls: "", // 图标样式class
        name: "修改答题卡",
        component: ExaminationPaperEdit,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperRecycle",
        iconCls: "", // 图标样式class
        name: "回收站答题卡",
        component: ExaminationPaperRecycle,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperArchiving",
        iconCls: "", // 图标样式class
        name: "已归档答题卡",
        component: ExaminationPaperArchiving,
        parent: "examinationPaper",
        hidden: true,
        children: []
      },
    ]
  },
  {
    path: "/ask",
    iconCls: "fa fa-bar-chart", // 图标样式class
    name: "随堂问报表",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/ask",
        iconCls: "fa fa-bar-chart", // 图标样式class
        name: "ask",
        name: "随堂问报表",
        component: Ask,
        meta: {
          keepAlive: true,
        },
        children: []

      },
      {
        path: "/askAnalysis",
        iconCls: "", // 图标样式class
        name: "随堂问报表分析",
        component: AskAnalysis,
        parent: "ask",
        children: []
      },
      {
        path: "/askArchiving",
        iconCls: "", // 图标样式class
        name: "随堂问已归档报表分析",
        component: AskArchiving,
        parent: "ask",
        hidden: true,
        children: []
      }
    ]
  },
  {
    path: "/test",
    iconCls: "fa fa-pie-chart", // 图标样式class
    name: "即时测报表",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/test",
        iconCls: "fa fa-pie-chart", // 图标样式class
        name: "",
        component: Test,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/testAnalysis",
        iconCls: "", // 图标样式class
        name: "即时测报表分析",
        component: TestAnalysis,
        parent: "test",
        children: []
      },
      {
        path: "/testArchiving",
        iconCls: "", // 图标样式class
        name: "即时测已归档报表分析",
        component: TestArchiving,
        parent: "test",
        hidden: true,
        children: []
      }

    ]
  },
  {
    path: "/setUpConglomerate",
    iconCls: "fa fa-building", // 图标样式class
    name: "学校管理",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/setUpConglomerate",
        iconCls: "fa fa-building",
        name: '集团管理',
        component: SetUpConglomerate,
        children: []
      },
    ]
  },
  {
    path: "/setUpAccount",
    iconCls: "fa fa-id-card-o", // 图标样式class
    name: "账号管理",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/setUpAccount",
        iconCls: "fa fa-id-card-o",
        name: '',
        component: SetUpAccount,
        children: []
      },
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-cog",
    name: '学校管理',
    component: Layout,
    children: [
      {
        path: "/setUpSchool",
        iconCls: "fa fa-calculator",
        name: '学校设置',
        component: SetUpSchool,
        children: []
      },
      {
        path: "/setUpClazz",
        iconCls: "fa fa-sitemap",
        name: '班级管理',
        component: SetUpClazz,
        children: []
      },
      {
        path: "/setUpTeacher",
        iconCls: "fa fa-male",
        name: '教师管理',
        component: SetUpTeacher,
        children: []
      },
      {
        path: "/setUpStudent",
        iconCls: "fa fa-mortar-board",
        name: '学生管理',
        component: SetUpStudent,
        children: []
      },
      {
        path: "/archivedClazz",
        iconCls: "fa fa-list-ul",
        name: '已归档班级',
        component: ArchivedClazz,
        hidden: true,
        children: []
      },
      {
        path: "/archived",
        iconCls: "fa fa-list-ul",
        name: '分班',
        component: Archived,
        hidden: true,
        children: []
      },
    ]
  },
  {
    path: "/card",
    iconCls: "fa fa-id-card", // 图标样式class
    name: "发卡记录",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/card",
        iconCls: "fa fa-id-card", // 图标样式class
        name: "",
        component: Card,
        children: []
      }
    ]
  },
  {
    path: "/device",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: "设备状态",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/device",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "",
        component: Device,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/deviceLog",
        iconCls: "fa fa-list-alt", // 图标样式class
        name: "",
        component: DeviceLog,
        parent: "device",
        children: []
      }
    ]
  },
  {
    path: "/analysis",
    iconCls: "fa fa-area-chart", // 图标样式class
    name: "使用分析",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/analysis",
        iconCls: "fa fa-area-chart", // 图标样式class
        name: "",
        component: Analysis,
        children: []
      }
    ]
  },
  {
    path: "/down",
    iconCls: "fa fa-download", // 图标样式class
    name: "软件下载",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/down",
        iconCls: "fa fa-download", // 图标样式class
        name: "发卡软件",
        component: Down,
        children: []
      },
      {
        path: "/downClient",
        iconCls: "", // 图标样式class
        name: "授课端软件",
        component: DownClient,
        parent: "down",
        children: []
      }
    ]
  },
  {
    path: "/dataSync",
    iconCls: "fa fa-random", // 图标样式class
    name: "数据同步",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/dataSync",
        iconCls: "fa fa-random", // 图标样式class
        name: "",
        component: DataSync,
        children: []
      }
    ]
  },
  // {
  //   path: "/portrait",
  //   iconCls: "fa fa-users", // 图标样式class
  //   name: "学生画像",
  //   component: Layout,
  //   alone: true,
  //   children: [
  //     {
  //       path: "/portrait",
  //       iconCls: "fa fa-users", // 图标样式class
  //       name: "",
  //       component: Portrait,
  //       meta: {
  //         keepAlive: true,
  //       },
  //       children: []
  //     },
  //     {
  //       path: "/portraitDetail",
  //       iconCls: "", // 图标样式class
  //       name: "授课端软件",
  //       component: PortraitDetail,
  //       parent: "down",
  //       children: []
  //     }
  //   ]
  // },
]
let csAddrouters = [
  {
    path: "/examinationPaper",
    iconCls: "fa fa-file-text", // 图标样式class
    name: "备题组卷",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/examinationPaper",
        iconCls: "fa fa-file-text", // 图标样式class
        name: "examinationPaper",
        component: CSExaminationPaper,
        children: []
      },
      {
        path: "/examinationPaperAdd",
        iconCls: "", // 图标样式class
        name: "examinationPaperAdd",
        component: CSExaminationPaperAdd,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperEdit",
        iconCls: "", // 图标样式class
        name: "修改答题卡",
        component: CSExaminationPaperEdit,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperRecycle",
        iconCls: "", // 图标样式class
        name: "回收站答题卡",
        component: CSExaminationPaperRecycle,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperArchiving",
        iconCls: "", // 图标样式class
        name: "已归档答题卡",
        component: ExaminationPaperArchiving,
        parent: "examinationPaper",
        hidden: true,
        children: []
      },
    ]
  },
  {
    path: "/ask",
    iconCls: "fa fa-bar-chart", // 图标样式class
    name: "随堂问报表",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/ask",
        iconCls: "fa fa-bar-chart", // 图标样式class
        name: "ask",
        name: "随堂问报表",
        component: Ask,
        meta: {
          keepAlive: true,
        },
        children: []

      },
      {
        path: "/askAnalysis",
        iconCls: "", // 图标样式class
        name: "随堂问报表分析",
        component: AskAnalysis,
        parent: "ask",
        children: []
      }
    ]
  },
  {
    path: "/test",
    iconCls: "fa fa-pie-chart", // 图标样式class
    name: "即时测报表",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/test",
        iconCls: "fa fa-pie-chart", // 图标样式class
        name: "",
        component: Test,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/testAnalysis",
        iconCls: "", // 图标样式class
        name: "即时测报表分析",
        component: TestAnalysis,
        parent: "test",
        children: []
      }

    ]
  },
  {
    path: "/setUpConglomerate",
    iconCls: "fa fa-building", // 图标样式class
    name: "学校管理",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/setUpConglomerate",
        iconCls: "fa fa-building",
        name: '集团管理',
        component: SetUpConglomerate,
        children: []
      },
    ]
  },
  {
    path: "/setUpAccount",
    iconCls: "fa fa-id-card-o", // 图标样式class
    name: "账号管理",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/setUpAccount",
        iconCls: "fa fa-id-card-o",
        name: '',
        component: SetUpAccount,
        children: []
      },
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-cog",
    name: '学校管理',
    component: Layout,
    children: [
      {
        path: "/setUpSchool",
        iconCls: "fa fa-calculator",
        name: '学校设置',
        component: SetUpSchool,
        children: []
      },
      {
        path: "/setUpTeacher",
        iconCls: "fa fa-male",
        name: '教师管理',
        component: SetUpTeacher,
        children: []
      },
      {
        path: "/setUpStudent",
        iconCls: "fa fa-mortar-board",
        name: '学生管理',
        component: SetUpStudent,
        children: []
      },
    ]
  },
  {
    path: "/card",
    iconCls: "fa fa-id-card", // 图标样式class
    name: "发卡记录",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/card",
        iconCls: "fa fa-id-card", // 图标样式class
        name: "",
        component: Card,
        children: []
      }
    ]
  },
  {
    path: "/device",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: "设备状态",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/device",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "",
        component: Device,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/deviceLog",
        iconCls: "fa fa-list-alt", // 图标样式class
        name: "",
        component: DeviceLog,
        parent: "device",
        children: []
      }
    ]
  },
  {
    path: "/analysis",
    iconCls: "fa fa-area-chart", // 图标样式class
    name: "使用分析",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/analysis",
        iconCls: "fa fa-area-chart", // 图标样式class
        name: "",
        component: Analysis,
        children: []
      }
    ]
  },
  {
    path: "/down",
    iconCls: "fa fa-download", // 图标样式class
    name: "软件下载",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/down",
        iconCls: "fa fa-download", // 图标样式class
        name: "发卡软件",
        component: Down,
        children: []
      },
      {
        path: "/downClient",
        iconCls: "", // 图标样式class
        name: "授课端软件",
        component: DownClient,
        parent: "down",
        children: []
      }
    ]
  },
  {
    path: "/dataSync",
    iconCls: "fa fa-random", // 图标样式class
    name: "数据同步",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/dataSync",
        iconCls: "fa fa-random", // 图标样式class
        name: "",
        component: DataSync,
        children: []
      }
    ]
  },
]

const addroutersPersonal = [
  {
    path: "/setUpStudent",
    iconCls: "fa fa-mortar-board",
    name: '班级名单',
    component: Layout,
    alone: true,
    children: [
      {
        path: "/setUpStudent",
        iconCls: "a fa-mortar-board",
        name: '',
        component: PersonalSetUpStudent,
        children: []
      },
    ]
  },
  {
    path: "/examinationPaper",
    iconCls: "fa fa-file-text", // 图标样式class
    name: "备题组卷",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/examinationPaper",
        iconCls: "fa fa-file-text", // 图标样式class
        name: "examinationPaper",
        component: ExaminationPaper,
        children: []
      },
      {
        path: "/examinationPaperAdd",
        iconCls: "", // 图标样式class
        name: "examinationPaperAdd",
        component: ExaminationPaperAdd,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperEdit",
        iconCls: "", // 图标样式class
        name: "修改答题卡",
        component: ExaminationPaperEdit,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperRecycle",
        iconCls: "", // 图标样式class
        name: "回收站答题卡",
        component: ExaminationPaperRecycle,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperArchiving",
        iconCls: "", // 图标样式class
        name: "已归档答题卡",
        component: ExaminationPaperArchiving,
        parent: "examinationPaper",
        hidden: true,
        children: []
      },
    ]
  },
  {
    path: "/ask",
    iconCls: "fa fa-bar-chart", // 图标样式class
    name: "随堂问报表",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/ask",
        iconCls: "fa fa-bar-chart", // 图标样式class
        name: "ask",
        name: "随堂问报表",
        component: PersonalAsk,
        meta: {
          keepAlive: true,
        },
        children: []

      },
      {
        path: "/askAnalysis",
        iconCls: "", // 图标样式class
        name: "随堂问报表分析",
        component: PersonalAskAnalysis,
        parent: "ask",
        children: []
      },
      {
        path: "/askArchiving",
        iconCls: "", // 图标样式class
        name: "随堂已归档问报表分析",
        component: PersonalArchiving,
        parent: "ask",
        hidden: true,
        children: []
      }
    ]
  },
  {
    path: "/test",
    iconCls: "fa fa-pie-chart", // 图标样式class
    name: "即时测报表",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/test",
        iconCls: "fa fa-pie-chart", // 图标样式class
        name: "",
        component: PersonalTest,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/testAnalysis",
        iconCls: "", // 图标样式class
        name: "即时测报表分析",
        component: PersonalTestAnalysis,
        parent: "test",
        children: []
      },
      {
        path: "/testArchiving",
        iconCls: "", // 图标样式class
        name: "即时已归档测报表分析",
        component: PersonalTestArchiving,
        parent: "test",
        hidden: true,
        children: []
      }

    ]
  },
  {
    path: "/portrait",
    iconCls: "fa fa-users", // 图标样式class
    name: "学生画像",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/portrait",
        iconCls: "fa fa-users", // 图标样式class
        name: "",
        component: Portrait,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/portraitDetail",
        iconCls: "", // 图标样式class
        name: "授课端软件",
        component: PortraitDetail,
        parent: "down",
        children: []
      }
    ]
  },
  {
    path: "/dataSync",
    iconCls: "fa fa-random", // 图标样式class
    name: "数据同步",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/dataSync",
        iconCls: "fa fa-random", // 图标样式class
        name: "",
        component: PersonalDataSync,
        children: []
      }
    ]
  },
  {
    path: "/down",
    iconCls: "fa fa-download", // 图标样式class
    name: "软件下载",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/down",
        iconCls: "fa fa-download", // 图标样式class
        name: "发卡软件",
        component: PersonalDown,
        children: []
      }
    ]
  },
]

const addRoutersAdmin = [
  {
    path: "/account",
    iconCls: "fa fa-id-card-o", // 图标样式class
    name: "账号管理",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/account",
        iconCls: "fa fa-id-card-o",
        name: '',
        component: AdminAccount,
        children: []
      },
    ]
  },
  {
    path: "/device",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: "设备状态",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/device",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "",
        component: AdminDevice,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/deviceLog",
        iconCls: "fa fa-list-alt", // 图标样式class
        name: "",
        component: AdminDeviceLog,
        parent: "device",
        children: []
      }
    ]
  },
  {
    path: "/clientVersion",
    iconCls: "fa fa-cogs", // 图标样式class
    name: "版本管理",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/clientVersion",
        iconCls: "fa fa-id-card-o",
        name: '',
        component: AdminClientVersion,
        children: []
      },
    ]
  },
]

export default new Router({
  routes: defaultRouter
})
export { defaultRouter, addrouters, addroutersPersonal, addRoutersAdmin, csAddrouters }
