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

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '仪表盘', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/profile/index'),
        name: 'Profile',
        meta: { title: 'profile', icon: 'user', noCache: true }
      }
    ]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: '/chart',
    component: Layout,
    redirect: '/chart/index',
    alwaysShow: true,
    name: 'Info',
    meta: { title: '数据分析', icon: 'el-icon-pie-chart' },
    children: [{
      path: 'index',
      component: () => import('@/views/chart/index'),
      name: 'Dashboard2',
      meta: { title: '数据大盘', affix: true }
    }]
  }, {
    path: '/info',
    component: Layout,
    redirect: '/info/news',
    alwaysShow: true,
    name: 'Info',
    meta: { title: '消息中心', icon: 'el-icon-chat-dot-square' },
    children: [{
      path: 'news',
      component: () => import('@/views/info/news/index'),
      name: 'News',
      meta: { title: '新闻资讯' }
    }]
  }, {
    path: '/basics',
    component: Layout,
    redirect: 'noRedirect',
    name: 'Basics',
    meta: { title: '基础数据', icon: 'component' },
    children: [{
      path: 'school-year-semester',
      name: 'BasicsSchoolYearSemester',
      component: () => import('@/views/basics/year-semester/index'),
      meta: { title: '学年学期' }
    }, {
      path: 'school',
      name: 'BasicsSchool',
      component: () => import('@/views/basics/school/index'),
      meta: { title: '学校' }
    }, {
      path: 'teacher',
      name: 'TeacherIndex',
      component: () => import('@/views/basics/teacher/index'),
      meta: { title: '教师列表' }
    }, {
      path: 'course',
      name: 'BasicsCourse',
      component: () => import('@/views/basics/course/index'),
      meta: { title: '课程' }
    }]
  }, {
    path: '/in-school',
    component: Layout,
    redirect: 'noRedirect',
    name: 'InSchool',
    meta: { title: '校内', icon: 'el-icon-school' },
    children: [{
      path: '430-open-course',
      name: 'InSchool430OpenCourse',
      component: () => import('@/views/InSchool/430-open-course/index'),
      meta: { title: '430课程' }
    }, {
      path: 'order',
      name: 'InSchoolOrderIndex',
      component: () => import('@/views/InSchool/order/index'),
      meta: { title: '订单列表' }
    }/* , {
      path: 'refund',
      name: 'InSchoolRefundIndex',
      component: () => import('@/views/InSchool/order/refund'),
      meta: { title: '审核退课' }
    } */]
  },/*  {
    path: '/out-school',
    component: Layout,
    redirect: 'noRedirect',
    name: 'OutSchool',
    meta: { title: '校外', icon: 'el-icon-office-building' }
  }, */ {
    path: '/guardian',
    component: Layout,
    redirect: '/guardian/index',
    alwaysShow: true,
    name: 'Guardian',
    meta: { title: '家长管理', icon: 'el-icon-user' },
    children: [{
      path: 'index',
      name: 'GuardianIndex',
      component: () => import('@/views/guardian/index'),
      meta: { title: '家长列表' }
    }]
  },/*  {
    path: '/organ',
    component: Layout,
    redirect: '/organ/index',
    alwaysShow: true,
    name: 'Organ',
    meta: { title: '机构管理', icon: 'el-icon-s-shop' },
    children: [{
      path: 'index',
      name: 'OrganIndex',
      component: () => import('@/views/organ/index'),
      meta: { title: '机构列表' }
    }]
  }, */ {
    path: '/platform/system',
    component: Layout,
    redirect: '/platform/system/account',
    alwaysShow: true,
    name: 'System',
    meta: { title: '平台管理', icon: 'el-icon-setting' },
    children: [/*{ 
      path: 'tenant',
      name: 'TenantIndex',
      component: () => import('@/views/platform/system/tenant/index'),
      meta: { title: '租户管理' }
    },  */{
      path: 'account',
      name: 'AccountIndex',
      component: () => import('@/views/platform/system/account/index'),
      meta: { title: '账号管理' }
    }, {
      path: 'role',
      name: 'RoleIndex',
      component: () => import('@/views/platform/system/role/index'),
      meta: { title: '角色管理' }
    }, {
      path: 'resource',
      name: 'ResourceIndex',
      component: () => import('@/views/platform/system/resource/index'),
      meta: { title: '菜单管理' }
    }, {
      path: 'dept',
      name: 'DeptIndex',
      component: () => import('@/views/platform/system/dept/index'),
      meta: { title: '部门管理' }
    }, {
      path: 'job',
      name: 'JobIndex',
      component: () => import('@/views/platform/system/job/index'),
      meta: { title: '岗位管理' }
    }, {
      path: 'dict',
      name: 'DictIndex',
      component: () => import('@/views/platform/system/dict/index'),
      meta: { title: '字典管理' }
    }]
  }, {
    path: '/platform/monitor',
    component: Layout,
    redirect: '/platform/monitor/online',
    alwaysShow: true,
    name: 'Monitor',
    meta: { title: '平台监控', icon: 'el-icon-s-platform' },
    children: [{
      path: 'online',
      name: 'MonitorOnlineIndex',
      component: () => import('@/views/platform/monitor/online/index'),
      meta: { title: '在线用户' }
    }, {
      path: 'log',
      name: 'MonitorLogIndex',
      component: () => import('@/views/platform/monitor/log/index'), // todo log文件夹区分（操作日志、异常日志、登录日志等等）
      meta: { title: '日志监控' }
    }, {
      path: 'druid',
      name: 'MonitorDruidIndex',
      component: () => import('@/views/platform/monitor/druid/index'),
      meta: { title: 'SQL监控' }
    }, {
      path: 'server',
      name: 'MonitorServerIndex',
      // component: () => import('@/views/platform/monitor/dict/index'), // todo
      meta: { title: '服务监控' }
    }]
  }, {
    path: 'weixin-tools',
    component: Layout,
    meta: { title: '微信工具', icon: 'link' },
    // iconBase64: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAANEAYAAADwKzJnAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAAASAAAAEgARslrPgAAA4NJREFUOMulU19M22UUPfdXcOkUhVlkQTHWQWSxIyHInyCbGuJWVheWwZwLEjGDUcRWKovRVJNqprNLGbQdpQW6vlTXjGWh0w1K4wZWsnQQXRlDMgNEcUYwLBhi3aT8rk/0gUqAeJ6+5J57z8k99yOsQNNOW5ItKS1Nckx8VfKbRoPPWYMplQpv40/aIZfDhGa2MdMUFMDEBI7gV3RevMi7lvYJTqu1obShtCZrZgbrBC0/WsKnH2zPKytDGAmscLngZj3yExLWOwhS7IRlfp52CMe55/Dhdwrrz6uf7O1dq02wKC3KDk1BASb4Rwx5PFHhKn6B+o1GfIXj1HL5ckznCbTC6/FgAFm832bD3whAm5jIU6JOkF+4YG40N7a9rFCsaUCso2zRaTDgG3jZHhe3XOB6wcMvnjtHKdBiamBgZSOf5qdo1O9HFX2J57q7o4U/8D3bpFJ2C5eEeL1+TQN4nlx4rbAwJpvvuAv24WHOw8NsNhpj6ndIxXqnE1q+QjKfj9qQj/cDAcrDP1xiNsPLfZi+eXP5pla9gRa1tduROTuLTExDl5y87swjKMG1mRnoUCPWGY04QCNCaUUFXmIDPs7JieE/ChcQDLIJZWJxY6MupNHXpQ8OChSgdg719a1buBs+DC0t0eMApZpM+BofCBKTCTquoM0LC3QS0wjcvh3lH8IVfHvrFg6hmj6NRMiNSklGf79FaVE67Lt3S/bcf0W3N/XGDdJyrXC9shKzGMYTUumqBkqwGSa/n7QYRmpxMZ7FIuJlMixQHMW53fwF19MPgkBBGkNeZiY24XVorl6Fjd7CY2NjmIMM+4qK2E/HyKBQRL+hRWlRtn2SnS1eovuSk14vrDjATf+R3SN4g7ijAwbksKO6GjpooSbCRmGAHdfv3Yte/VzPXM/vH4VCSRmy9tSfIhGM0LvkPHsWck5jGRHdxRE0p6dzOyAmA3BBpM/GxzECANu3b1Sf/kIV3hsdjTo/VXCqoFO3ZYtA8Z3syM1tuKZR1IR9vtUGNFdYBh0OlYru0AkMeb3Yjz3IlUjWVA7hZ2BxkZ/GvNCkVG58dStgTmwtd9iLitgqToJMJszhTSA/P4ZYjFJSRyI8zkeRVlurO6jtPfrLmTP/28BKtJa3lreWb90q+kW/JCslJRwMB+M3TU4+8MxDHy7Jt22jFnEX383IaNBptLXqrq5/AQ7AZONTWPqgAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE5LTA3LTIwVDExOjUyOjM1KzA4OjAwZihCpAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOS0wNy0yMFQxMTo1MjozNSswODowMBd1+hgAAABIdEVYdHN2ZzpiYXNlLXVyaQBmaWxlOi8vL2hvbWUvYWRtaW4vaWNvbi1mb250L3RtcC9pY29uX2hkM2Y4aWtuMjEvd2VpeGluLnN2Z+H8ddgAAAAASUVORK5CYII=',
    children: [{
      path: 'https://pay.weixin.qq.com',
      meta: { title: '商户平台' }
      // iconBase64: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAAB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9FRssfaY52nMjOVI9BRwuQkMrELUKsjHsbN4MYcEAxKgzjL3pwcUeur9dW0uN3owRQ1Njf/b8Lhyj+kp9F+4kRYV4SJOql2TO+3WNhEIbTX1/9nig8WEBwcR+aamnp621Q9a7WGabHWXyoKfSWKBwYeGsILpRUfAT7fpoJtcFP94iJy6Bugq0vVSK9KpXv21E0bX9cvyvJa93W/WOg4PR86V1hIFdDCMjzMxxSP0t3YaBwzDR2PvnnT8sIZ7bmG1FQ0K53s2blTqpQaQkeYKVfxgxYWjHeMI/qV2VnkA6gGAAw9OB8N/36vQjzGlS3hH8F0jMkaCtzFAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE5LTA4LTI2VDE3OjI2OjQxKzA4OjAwCJn6oAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOS0wOC0yNlQxNzoyNjo0MSswODowMHnEQhwAAABOdEVYdHN2ZzpiYXNlLXVyaQBmaWxlOi8vL2hvbWUvYWRtaW4vaWNvbi1mb250L3RtcC9pY29uX244eTQyYWRvODRrL3dlaXhpbnpoaWZ1LnN2Zwg/qewAAAAASUVORK5CYII=',
    }, {
      path: 'https://mpkf.weixin.qq.com',
      meta: { title: '客服' }
      // iconBase64: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAAASAAAAEgARslrPgAAAzlJREFUSMfFk11MU2cYx5/nnLYwNwRiU5BosrUJEk39YHYRbjYvKg0kDiU5EY2KifGAWalUkgEX05u5ddP043ThvJ0sZGCyHT8i9VuJiBIlqBBHbFCTJiqpLMsoBALB9pxnV3qzLKUM4//6/77P7/9/3hfgPQvna1QURVEUnh/Vj22aPFlaym1CF5VbrXgJTmn5PA+ruT1Q+uyZ6p4bnRF6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ob21lL2FkbWluL2ljb24tZm9udC90bXAvaWNvbl9sYXo0aWdwb2d2bS9rZWZ1LnN2Z4AkCGoAAAAASUVORK5CYII=',
    }, {
      path: 'https://mp.weixin.qq.com',
      meta: { title: '意见反馈' }
      // iconBase64: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAAASAAAAEgARslrPgAAAshJREFUSMfFkV1IU2EYx5/3nCN+MCjhGEM0hwgqiMj8yLxRFsGcDEHxSOBtzCXTpSEk6EWEdaHuq447zlQQxNUJjMqvLrQMEiqRdZG78KILFcIpzqUyPefpQifklJxK/e6e933e9/9//g+Bf4xda9f23U9I8I35xhQ5GxtM6MKCFuxGlQpEupRO0WioZeozBhkmUgH5hZyP2rW1ux/rx2sHRDF07lA71IKQkSGV4OvdB273pevKN74inY7q+CI4BSfLkikmjUoZHSV9UIUtCsVZJySVREcKCQnV1lprLb+Tnr73FdqgeHhYHiE+aK2paZw16o36pSWwa+3aHmNxsY2zS4Lgcl1U1KGJLegYERbm521Ntqbum1lZR/soaYyMSTwhchcpgSpZPq+wxfXU26vMzAxNTN2TZ2RTTQ3kUUY6X6sVBEEQhLi4UH/YjrsKuwq7CmNjCcNcjssoKzsa6SHPQUM1+v3mT6as21sTE9ZXvMblyc6G73upUungIJ1LbsH76mrTXMOc8d3CgnXasduz6HAEY4MaxjA0tP/J1laYgeik6KToJJreq5QfU4kqFbYQh5xG02EGXqJHal9dBTUAmAGgVVqUczIzoUg2SVscZ5ozz92J8Xr/lliYgTqxTqwTAwEQQQTo6AAAgPZjXqr/LM0e0w+D7HaDB5wQc/qVhRngeZ7n+fj44COpgqabm+Eb/iTTx6zgBMg1soPjXm+D11RgWO/vj9gAy7Isy/r9K66V+fX1yUn5KkkEOGYFJ0AVYRuWLy+DFwAGzpAAx3Ecx0nSfjU1dfowDxiPrJ2KWOCC+e8GGMou25nezU0sp5rkt8nJiPgBkRyAeF4BwSk4BWdU1HZFUIGgVGIBOn+NBAKhe4KIiEiIdfaJzqW32Ugu6MGjVpNUuIF529vnNYA7cAVmFAp4hnvwUBTN5fUJBkNn5/9O/pDfPEEiWO0j0sIAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTktMDctMjBUMTE6NDk6NTArMDg6MDDLEUCzAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE5LTA3LTIwVDExOjQ5OjUwKzA4OjAwukz4DwAAAE90RVh0c3ZnOmJhc2UtdXJpAGZpbGU6Ly8vaG9tZS9hZG1pbi9pY29uLWZvbnQvdG1wL2ljb25fZndsN2ZnN2xoNmcveWlqaWFuZmFua3VpLnN2Zw7UoVMAAAAASUVORK5CYII=',
    }]
  },

  /** when your routing map is too long, you can split it into small modules **/

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
