import ServerSideLogin from '@/view/serverside/login.vue'
import Home from '@/view/Home.vue'
import FrontEndMain from '@/components/public/frontEndMain/Index.vue'
// import HTTP404 from '@/view/404'
// import { resolve } from 'url'

let identity = localStorage.getItem('identity')

export const routes = [
	{
		path: '*',
		redirect: '/404'
	},
	{
		name: '404',
		path: '/404',
		component: resolve => require(['@/view/404.vue'], resolve)
	},
	{
		name: 'index',
		path: '',
		redirect: identity == 'student' ? '/studentWeb' : '/home'
	},
	// {
	// 	path: '/login',
	// 	component: FrontEndMain,
	// 	children: [{
	// 			name: 'login',
	// 			path: '/',
	// 			meta: {
	// 				middleware: ['login?']
	// 			},
	// 			component: resolve => require(['@/view/login/Index.vue'], resolve)
	// 		}]
	// },
	{
		path: '/login',
		component: FrontEndMain,
		children: [
			{
				name: 'login',
				path: '/',
				meta: {
					middleware: ['login?']
				},
				component: resolve => require(['@/view/login/test.vue'], resolve)
			},
			{
				name: 'loginTeacher',
				path: 'teacher',
				meta: {
					middleware: ['login?']
				},
				component: resolve => require(['@/view/login/page/Teacher.vue'], resolve)
			},
			{
				name: 'loginStudent',
				path: 'student',
				meta: {
					middleware: ['login?']
				},
				component: resolve => require(['@/view/login/page/Student.vue'], resolve)
			}
		]
	},	
	{
		path: '/regist',
		component: FrontEndMain,
		children: [{
			name: 'regist',
			path: '/',
			meta: {
				middleware: ['login?']
			},
			component: resolve => require(['@/view/regist/Index.vue'], resolve)
		}]
	},
	{
		path: '/forgotpw',
		component: FrontEndMain,
		children: [{
			name: 'forgotpw',
			path: '/',
			meta: {
				middleware: ['login?']
			},
			component: resolve => require(['@/view/forgotPw/Index.vue'], resolve)
		}]
	},
	{
		path: '/joinclass',
		component: resolve => require(['@/view/joinclass/JoinClass.vue'], resolve)
	},
	{
		path: '/MarkView',
		name:'FullMarkView',
		component: resolve => require(['@/view/learnactivity/markpaper/MarkView.vue'], resolve)
	},
	{
		path: '/schoolList',
		component: Home,
		children: [{
			name: 'schoolList',
			path: '/',
			meta: {
				middleware: ['login']
			},
			component: resolve => require(['@/view/schoolList/Index.vue'], resolve),
		}]
	},
	{
		name: 'ServerSideLogin',
		path: '/serverside/login',
		component: ServerSideLogin
	},

	// 教师端
	{
		name: 'home',
		path: '/home',
		redirect: '/home/HomePage',
		component: resolve => require(['@/view/Home'], resolve),
		meta: {
			middleware: ['login', 'role:admin|teacher'], // 强制登录（会自动跳转到登录页），角色为管理员或教师
		},
		children: [{
			name: 'totalIndex',
			path: '/totalIndex',
			component: resolve => require(['@/view/student-analysis/total-analysis/EvaluationList/TotalIndex.vue'], resolve),
			meta: {
				activeName: 'totalIndex'
			}
		},
		{
			name: 'total',
			path: 'total',
			component: resolve => require(['@/view/student-analysis/total-analysis/index.vue'], resolve),
			children: [{
				path: '/total',
				component: resolve => require([
					'@/view/student-analysis/total-analysis/AchievementAnalysis/AchievementAnalysis.vue'
				], resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/evaluationList',
				component: resolve => require(['@/view/student-analysis/total-analysis/EvaluationList/EvaluationList.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/achievement',
				component: resolve => require([
					'@/view/student-analysis/total-analysis/AchievementAnalysis/AchievementAnalysis.vue'
				], resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/achievement/entryTables',
				component: resolve => require(['@/view/student-analysis/total-analysis/AchievementAnalysis/EntryTables.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/achievement/earlyWarning',
				component: resolve => require(['@/view/student-analysis/total-analysis/AchievementAnalysis/EarlyWarning.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/scatter',
				component: resolve => require(['@/view/student-analysis/total-analysis/ScatterAnalysis/ScatterAnalysis.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/knowledge',
				component: resolve => require([
					'@/view/student-analysis/total-analysis/KnowledgeAnalysis/KnowledgeAnalysis.vue'
				], resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/knowledge/details',
				component: resolve => require(['@/view/student-analysis/total-analysis/KnowledgeAnalysis/ScoreDetails.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/cognitionLevel',
				component: resolve => require(['@/view/student-analysis/total-analysis/LevelAnalysis/LevelAnalysis.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/cognitionLevel/details',
				component: resolve => require(['@/view/student-analysis/total-analysis/LevelAnalysis/ScoreDetails.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}
			},
			{
				path: '/total/test',
				component: resolve => require(['@/view/student-analysis/total-analysis/TestAnalysis/TestAnalysis.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}

			},
			{
				path: '/total/questionList',
				component: resolve => require(['@/view/student-analysis/total-analysis/TestAnalysis/QuestionList.vue'],
					resolve),
				meta: {
					activeName: 'totalIndex'
				}
			}
			]
		},
		//废弃 阅卷和批注代码混合，不方便维护
		{
			path: 'MarkView',
			name:'MarkView',
			component: resolve => require(['@/view/learnactivity/markpaper/MarkView.vue'], resolve)
		},
		// 按人阅卷
		{
			path: 'ByStu',
			name:'ByStu',
			component: resolve => require(['@/view/task/mark/ByStu.vue'], resolve),
			meta: {
				activeName: 'taskList'
			}
		},
		// 按题阅卷
		{
			path: 'ByQu',
			name:'ByQu',
			component: resolve => require(['@/view/task/mark/ByQu.vue'], resolve),
			meta: {
				activeName: 'taskList'
			}
		},
		//校园基础数据管理
		{
			name: 'system',
			path: 'system',
			meta: {
				middleware: ['login', 'ability:admin,schoolSetting-read|schoolSetting-upd'],
				activeName: 'system',
				// isKeep: true
			},
			// component: resolve => require(['@/view/schoolmgmt/SystemSetting/SystemSetting.vue'], resolve) //原来的基础设置UI
			component: resolve => require(['@/view/schoolmgmt/SystemSetting/NewSystemSetting.vue'], resolve) //调整中的UI
		},
		//班级教室管理
		{
			name: 'classroom',
			path: 'classroom',
			meta: {
				middleware: ['login', 'ability:admin,classroom-read|classroom-upd'],
				activeName: 'classroom'
			},
			component: resolve => require(['@/view/schoolmgmt/ClassroomSetting/ClassroomSetting.vue'], resolve)
		},
		//学生账号管理
		{
			name: 'studentAccount',
			path: 'studentAccount',
			component: resolve => require(['@/view/student-account/Index.vue'], resolve),
			meta: {
				middleware: ['login', 'ability:admin,student-read|student-upd'],
				activeName: 'studentAccount'
			},

		},
		//教师账号
		{
			path: 'teachermgmt',
			name: 'teachermgmt',
			meta: {
				middleware: ['login', 'ability:admin,teacher-read|teacher-upd']
			},
			component: () => import('@/view/teachermgmt/Index.vue'),
			meta: {
				activeName: 'teachermgmt'
			},
		},
		{
			path: 'evaluation',
			name: 'evaluation',
			redirect: '/home/evaluation/testPaperList',
			meta: {
				activeName: 'schoolBank'
			},
			component: resolve => require(['@/view/evaluation/index/index.vue'], resolve),
			children: [{
				path: 'newSchoolExercise',
				name: 'newSchoolExercise',
				component: resolve => require(['@/view/evaluation/index/CreateExercises.vue'], resolve),
				meta: {
					activeName: 'schoolBank'
				},
			},
			{
				path: 'newPrivateExercise',
				name: 'newPrivateExercise',
				component: resolve => require(['@/view/evaluation/index/CreateExercises.vue'], resolve),
				meta: {
					activeName: 'personalBank'
				},
			},
			{
				path: 'answerSheet',
				name: 'answerSheet',
				component: resolve => require(['@/view/answersheet/index.vue'], resolve),
				meta: {
					activeName: 'schoolBank'
				},
			},
			{
				path: 'testPaper',
				name: 'testPaper',
				component: resolve => require(['@/view/evaluation/index/TestPaper.vue'], resolve),
				meta: {
					activeName: 'schoolBank'
				},
			},
			{
				path: 'testPaperList',
				name: 'testPaperList',
				component: resolve => require(['@/view/evaluation/bank/index.vue'], resolve),
				meta: {
					activeName: 'schoolBank'
				},
			},
			{
				path: 'schoolBank',
				name: 'schoolBank',
				component: resolve => require(['@/view/evaluation/bank/index.vue'], resolve),
				meta: {
					activeName: 'schoolBank'
				},
			},
			{
				path: 'personalBank',
				name: 'personalBank',
				component: resolve => require(['@/view/evaluation/bank/index.vue'], resolve),
				meta: {
					activeName: 'personalBank'
				}
			}
			]
		},
		{
			path: 'newSchoolPaper',
			name: 'newSchoolPaper',
			component: resolve => require(['@/view/evaluation/index/CreatePaper.vue'], resolve),
			meta: {
				activeName: 'schoolBank'
			}
		},
		{
			path: 'newPrivatePaper',
			name: 'newPrivatePaper',
			component: resolve => require(['@/view/evaluation/index/CreatePaper.vue'], resolve),
			meta: {
				activeName: 'personalBank'
			}
		},
		{
			path: 'myCourse',
			name: 'myCourse',
			component: resolve => require(['@/view/newcourse/MyCourse.vue'], resolve),
			meta: {
				activeName: 'myCourse',
				// isKeep: true
			}
		},
		{
			path: 'taskList',
			name: 'taskList',
			component: resolve => require(['@/view/task/index.vue'], resolve),
			meta: {
				activeName: 'taskList',
				// isKeep: true
			}
		},
		//自定义名单管理页面
		{
			path: 'MgtStuList',
			name: 'MgtStuList',
			component: resolve => require(['@/view/student-account/MgtStuList.vue'], resolve),
			meta: {
				activeName: 'myCourse'
			}
		},

		//我的课程查看评测详细数据
		{
			path: 'EvDetail',
			name: 'EvDetail',
			component: resolve => require(['@/view/newcourse/EvDetail.vue'], resolve),
			meta: {
				activeName: 'myCourse'
			}
		},

		//课程管理(废弃)
		{
			path: 'ManageCourse',
			name: 'ManageCourse',
			component: resolve => require(['@/view/newcourse/ManageCourse.vue'], resolve)
		},
		//新版课程管理
		{
			path: 'NewCusMgt',
			name: 'NewCusMgt',
			component: resolve => require(['@/view/newcourse/NewCusMgt.vue'], resolve),
			meta: {
				activeName: 'NewCusMgt'
			}
		},
		//排课管理新版（废弃）
		{
			path: 'DelCoursePlan',
			name: 'DelCoursePlan',
			component: resolve => require(['@/view/newcourse/DelCoursePlan.vue'], resolve)
		},
		//课程表版本排课
		{
			path: 'CoursePlan',
			name: 'CoursePlan',
			component: resolve => require(['@/view/newcourse/CoursePlan.vue'], resolve),
			meta: {
				activeName: 'NewCusMgt'
			}
		},
		// 新课纲管理
		{
			path: 'syllabus',
			name: 'syllabus',
			component: resolve => require(['@/view/syllabus/Syllabus.vue'], resolve),
			meta: {
				activeName: 'syllabus'
			}
		},
		// 新课纲管理
		{
			path: 'personalSyllabus',
			name: 'personalSyllabus',
			component: resolve => require(['@/view/syllabus/Syllabus.vue'], resolve),
			meta: {
				activeName: 'personalSyllabus'
			}
		},
		//校本资源管理
		{
			path: 'schoolcontent',
			name: 'schoolcontent',
			component: resolve => require(['@/view/teachcontent/index.vue'], resolve),
			meta: {
				activeName: 'schoolcontent'
			}
		},
		//个人内容管理
		{
			path: 'personalcontent',
			name: 'personalcontent',
			component: resolve => require(['@/view/teachcontent/index.vue'], resolve),
			meta: {
				activeName: 'personalcontent'
			}
		},
		// 知识点管理
		{
			path: 'knowledge',
			name: 'knowledge',
			component: resolve => require(['@/view/knowledge-point/index/Index.vue'], resolve),
			meta: {
				activeName: 'knowledge'
			}
		},
		// 创建校本评测
		{
			path: 'createSchoolEva',
			name: 'createSchoolEva',
			component: resolve => require(['@/view/learnactivity/CreateSchoolEva.vue'], resolve),
			meta: {
				activeName: 'schoolEvaluation'
			}
		},
		// 创建个人评测
		{
			path: 'createPrivEva',
			name: 'createPrivEva',
			component: resolve => require(['@/view/learnactivity/CreatePrivEva.vue'], resolve),
			meta: {
				activeName: 'privateEvaluation'
			}
		},
		//创建学习单元
		{
			path: 'createLearnUnit',
			name: 'createLearnUnit',
			component: resolve => require(['@/view/selflearn/CreateLearnUnit.vue'], resolve),
			meta: {
				activeName: 'selfLearn'
			}
		},
		//创建作业活动
		//{
		//    path: 'createHomeWork',
		//    name: 'createHomeWork',
		//    component: resolve => require(['@/view/selflearning/CreateHomeWork.vue'], resolve)
		//},
		//创建编序式学习
		{
			path: 'createOrderLearn',
			name: 'createOrderLearn',
			component: resolve => require(['@/view/selflearn/CreateOrderLearn.vue'], resolve),
			meta: {
				activeName: 'selfLearn'
			}
		},
		//管理评测页面(学校)
		{
			path: 'schoolEvaluation',
			name: 'schoolEvaluation',
			component: resolve => require(['@/view/learnactivity/MgtSchoolEva.vue'], resolve),
			meta: {
				activeName: 'schoolEvaluation'
			}
		},
		//管理评测页面（个人）
		{
			path: 'privateEvaluation',
			name: 'privateEvaluation',
			component: resolve => require(['@/view/learnactivity/MgtPrivEva.vue'], resolve),
			meta: {
				activeName: 'privateEvaluation'
			}
		},
		//管理活动记录页面(暂未使用)
		{
			path: 'manageRecord',
			name: 'manageRecord',
			component: resolve => require(['@/view/learnactivity/ManageRecord.vue'], resolve)
		},
		//管理问卷调查
		{
			path: 'manageQuestionnaire',
			name: 'manageQuestionnaire',
			component: resolve => require(['@/view/questionnaire/ManageQuestionnaire.vue'], resolve),
			meta: {
				activeName: 'manageQuestionnaire'
			}
		},
		//管理问卷调查
		{
			path: 'personalSurvey',
			name: 'personalSurvey',
			component: resolve => require(['@/view/questionnaire/ManageQuestionnaire.vue'], resolve),
			meta: {
				activeName: 'personalSurvey'
			}
		},
		//新版自主学习
		{
			path: 'SelfLearn',
			name: 'selfLearn',
			component: resolve => require(['@/view/selflearn/SelfLearn.vue'], resolve),
			meta: {
				activeName: 'selfLearn'
			}
		},
		{
			path: 'manageHomeWork',
			name: 'manageHomeWork',
			component: resolve => require(['@/view/homework/ManageHomeWork.vue'], resolve),
			meta: {
				activeName: 'manageHomeWork'
			}
		},
		{
			path: 'manageVote',
			name: 'manageVote',
			component: resolve => require(['@/view/vote/ManageVote.vue'], resolve),
			meta: {
				activeName: 'manageVote'
			}
		},
		{
			path: 'personalVote',
			name: 'personalVote',
			component: resolve => require(['@/view/vote/ManageVote.vue'], resolve),
			meta: {
				activeName: 'personalVote'
			}
		},
		//主页
		{
			path: 'homePage',
			name: 'homePage',
			component: resolve => require(['@/view/homepage/HomePage.vue'], resolve),
			meta: {
				activeName: 'homePage'
			}
		},
		//班级管理
		{
			path: 'manageClass',
			name: 'manageClass',
			component: resolve => require(['@/view/classmgt/ManageClass.vue'], resolve),
			meta: {
				activeName: 'manageClass'
			}
		},
		//用户反馈
		{
			path: 'feedback',
			name: 'feedback',
			component: resolve => require(['@/view/feedback/Feedback.vue'], resolve),
			meta: {
				activeName: 'feedback'
			}
		},
		//设置
		{
			path: 'settings',
			name: 'settings',
			component: resolve => require(['@/view/settings/Index.vue'], resolve),
			meta: {
				activeName: 'settings'
			}
		},
		//课堂记录
		{
			path: 'classRecord',
			name: 'classRecord',
			component: resolve => require(['@/view/classrecord/ClassRecord.vue'], resolve),
			meta: {
				activeName: 'myCourse'
			}
		},

		//Louise的智能教室使用分析儀表板
		{
			path: 'scboard',
			name: 'scboard',
			component: resolve => require(['@/view/scboard/Index.vue'], resolve),
			meta: {
				activeName: 'scboard'
			}
		},

		//Louise的教師儲存空間授權管理分頁
		{
			path: 'serviceDriveAuth',
			name: 'serviceDriveAuth',
			component: resolve => require(['@/view/serviceDriveAuth/Index.vue'], resolve),
			meta: {
				activeName: 'serviceDriveAuth'
			}
		}
		]
	},
	//学生端
	{
		name: 'studentWeb',
		path: '/studentWeb',
		redirect: '/studentWeb/homeView',
		component: resolve => require(['@/view/student-web/App'], resolve),
		meta: {
			// 暫時連其他權限也可以登入 日後要改成只有學生
			middleware: ['login', 'role:admin|teacher|student'], // 强制登录（会自动跳转到登录页），角色为管理员或教师
		},
		children: [{
			name: "homeView",
			path: "homeView",
			component: resolve => require(['@/components/student-web/HomeView/HomeView'], resolve),
		},
		{
			name: "courseList",
			path: "courseList",
			component: resolve => require(['@/components/student-web/HomeView/CourseListView'], resolve), //是元件不用''
		},
		{
			name: "setting",
			path: "setting",
			component: resolve => require(['@/components/student-web/SettingView/SettingView'], resolve), //是元件不用'
		},
		{
			name: "eventView",
			path: "eventView",
			component: resolve => require(['@/components/student-web/EventView/EventView'], resolve),
		},
		{
			name: "eventView/:name",
			path: "eventView/:name",
			component: resolve => require(['@/components/student-web/EventView/EventView'], resolve),
		},
		{
			name: "eventLatest",
			path: "eventLatest",
			component: resolve => require(['@/components/student-web/EventView/EventOverView/EventLatest'], resolve),
		},
		{
			// 自主学习
			name: "studyView",
			path: "studyView",
			component: resolve => require(['@/components/student-web/StudyView/StudyView'], resolve),
		},
		{
			name: "hiteachView",
			path: "hiteachView",
			component: resolve => require(['@/components/student-web/HiteachView/HiteachView'], resolve),
		},
		{
			// 通知
			name: "informView",
			path: "informView",
			component: resolve => require(['@/components/student-web/InformView/InformView'], resolve),
		}
		]
	},
	// 評測測試
	{
		path: '/uploadEvaluation',
		name: 'uploadEvaluation',
		component: resolve => require(['@/view/uploadEvaluation/Index.vue'], resolve),
		meta: {
			middleware: ['login']
		}
	},
]
