export const KeepAliveLayout = {
  template: '<KeepAlive><RouterView /></KeepAlive>'
}

export const features = [
  {
    path: 'electronic-textbook',
    meta: { title: '电子化教材', icon: 'i-xitongguanli' },
    component: () => import('@/views/electronic-textbook')
  },
  // {
  // path: 'app1',
  // meta: { title: '测试', icon: 'i-xitongguanli', type: 'qiankun' }
  // component: () => import('@/views/test')
  // },
  {
    path: 'system',
    meta: { title: '系统管理', icon: 'i-xitongguanli' },
    component: KeepAliveLayout,
    children: [
      {
        path: 'user',
        meta: { title: '用户管理' },
        component: () => import('@/views/system/user')
      },
      {
        path: 'org',
        meta: { title: '组织机构管理' },
        component: () => import('@/views/system/org')
      },
      {
        path: 'role',
        meta: { title: '角色管理' },
        component: () => import('@/views/system/role')
      },
      {
        path: 'electronic-textbook-manage',
        meta: { title: '手册管理', icon: 'i-xitongguanli' },
        component: () => import('@/views/textbook-manage')
      }
    ]
  },
  {
    path: 'train',
    meta: { title: '训练管理', icon: 'i-zaixiankecheng' },
    component: KeepAliveLayout,
    children: [
      {
        path: 'subject',
        meta: { title: '科目设置' },
        component: () => import('@/views/training/subject')
      },
      {
        path: 'training',
        meta: { title: '组织训练' },
        component: () => import('@/views/training/training')
      },
      {
        path: 'device',
        meta: { title: '设备管理' },
        component: () => import('@/views/training/device')
      },
      {
        path: 'evealuation',
        meta: { title: '统计分析' },
        component: () => import('@/views/training/evealuation')
      }
    ]
  },
  {
    path: 'resource',
    meta: { title: '资源管理', icon: 'i-zaixiankecheng' },
    component: KeepAliveLayout,
    children: [
      {
        path: 'resource-manage',
        meta: { title: '资源管理' },
        component: () => import('@/views/system/resource')
      },
      {
        path: 'resource-share',
        meta: { title: '资源分享' },
        component: () => import('@/views/system/resource/share')
      }
    ]
  },
  {
    path: 'online-course',
    meta: { title: '在线授课', icon: 'i-zaixianjiaoxue' },
    component: KeepAliveLayout,
    children: [
      {
        path: 'course-manage',
        meta: { title: '课程管理' },
        component: () => import('@/views/online-course/course-manage')
      },
      {
        path: 'my-course',
        meta: { title: '我的课程' },
        component: () => import('@/views/online-course/my-course')
      },
      {
        path: 'class-notes',
        meta: { title: '课堂笔记' },
        component: () => import('@/views/online-course/class-notes')
      },
      {
        path: 'online-FAQ',
        meta: { title: '在线答疑' },
        component: () => import('@/views/online-course/online-FAQ')
      },
      {
        path: 'live-lectures',
        meta: { title: '直播授课' },
        component: () => import('@/views/online-teaching/live-lectures')
      },
      {
        path: 'live-in-class',
        meta: { title: '直播上课' },
        component: () => import('@/views/online-teaching/live-in-class')
      }
    ]
  },

  // {
  //   path: 'online-teaching',
  //   meta: { title: '在线教学', icon: 'i-zaixianjiaoxue' },
  //   component: KeepAliveLayout,
  //   children: [

  //   ]
  // },

  {
    path: 'assessment-evaluation',
    meta: { title: '课程考核', icon: 'i-kaoheceping' },
    component: KeepAliveLayout,
    children: [
      {
        path: 'question-bank-manage',
        meta: { title: '题库管理' },
        component: () =>
          import('@/views/assessment-evaluation/question-bank-manage')
      },
      {
        path: 'examination-paper-manage',
        meta: { title: '试卷管理' },
        component: () =>
          import('@/views/assessment-evaluation/examination-paper-manage')
      },
      {
        path: 'exam-arrangement',
        meta: { title: '考试安排' },
        component: () =>
          import('@/views/assessment-evaluation/exam-arrangement')
      },
      {
        path: 'human-evaluation',
        meta: { title: '人工评卷' },
        component: () =>
          import('@/views/assessment-evaluation/human-evaluation')
      },
      {
        path: 'simulation-test',
        meta: { title: '模拟考试' },
        component: () =>
          import('@/views/assessment-evaluation/simulation-test')
      },
      {
        path: 'online-test',
        meta: { title: '在线考试' },
        component: () => import('@/views/assessment-evaluation/online-test')
      },
      {
        path: 'wrong-topic-consolidate',
        meta: { title: '错题巩固' },
        component: () =>
          import('@/views/assessment-evaluation/wrong-topic-consolidate')
      }
    ]
  },

  {
    path: 'evaluation',
    meta: { title: '综合评价', icon: 'i-pingjia' },
    component: KeepAliveLayout,
    children: [
      {
        path: 'student-evaluation',
        meta: { title: '学员评价' },
        component: () => import('@/views/evaluation/student-evaluation')
      },
      {
        path: 'evaluation-setting',
        meta: { title: '评价设置' },
        component: () => import('@/views/evaluation/evaluation-setting')
      },
      {
        path: 'my-evaluation',
        meta: { title: '我的评价' },
        component: () => import('@/views/evaluation/my-evaluation')
      }
    ]
  }
]

export function findAllFeature () {
  const fn = (list) => {
    const ls = []
    for (const v of list) {
      const item = { name: v.path, label: v.meta.title }
      if (v.children && v.children.length) {
        item.children = fn(v.children)
      } else {
        item.children = []
      }

      ls.push(item)
    }
    return ls
  }
  return fn(features)
}
