2018-11-13 11:33:18 +00:00
|
|
|
import Home from "./pages/Home.vue";
|
|
|
|
import ProgramPage from "./pages/ProgramPage.vue";
|
2018-12-17 08:26:27 +00:00
|
|
|
import CoursePage from "./pages/CoursePage.vue";
|
2018-11-22 06:52:20 +00:00
|
|
|
import ContentPage from "./pages/ContentPage.vue";
|
2018-11-14 08:53:06 +00:00
|
|
|
import ListPage from "./pages/ListPage.vue";
|
2018-11-26 11:23:51 +00:00
|
|
|
import ProfilePage from "./pages/ProfilePage.vue";
|
2018-11-09 06:17:09 +00:00
|
|
|
|
2018-12-06 14:43:20 +00:00
|
|
|
const routes = [{
|
|
|
|
name: 'home',
|
|
|
|
path: '',
|
|
|
|
component: Home
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'program',
|
|
|
|
path: '/Program/:program_name',
|
|
|
|
component: ProgramPage,
|
|
|
|
props: true
|
|
|
|
},
|
2018-12-17 08:26:27 +00:00
|
|
|
{
|
|
|
|
name: 'course',
|
2019-02-26 11:17:10 +00:00
|
|
|
path: '/Program/:program_name/:course_name/',
|
2018-12-17 08:26:27 +00:00
|
|
|
component: CoursePage,
|
|
|
|
props: true,
|
|
|
|
},
|
2018-11-24 15:01:35 +00:00
|
|
|
{
|
|
|
|
name: 'content',
|
2019-02-26 11:41:01 +00:00
|
|
|
path: '/Program/:program_name/:course_name/:topic/:type/:content',
|
2018-11-24 15:01:35 +00:00
|
|
|
component: ContentPage,
|
|
|
|
props: true,
|
2019-02-27 06:54:17 +00:00
|
|
|
beforeRouteUpdate (to, from, next) {
|
|
|
|
if (lms.store.checkProgramEnrollment(to.params.program_name)) {
|
2018-11-26 06:29:12 +00:00
|
|
|
next()
|
2018-12-06 14:43:20 +00:00
|
|
|
} else {
|
|
|
|
next({
|
|
|
|
name: 'program',
|
|
|
|
params: {
|
|
|
|
program_name: to.params.program_name
|
|
|
|
}
|
|
|
|
})
|
2018-11-26 06:29:12 +00:00
|
|
|
}
|
2018-11-24 15:01:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'list',
|
|
|
|
path: '/List/:master',
|
|
|
|
component: ListPage,
|
|
|
|
props: true
|
|
|
|
},
|
2018-11-14 08:53:06 +00:00
|
|
|
{
|
|
|
|
name: 'signup',
|
|
|
|
path: '/Signup',
|
|
|
|
beforeEnter(to, from, next) {
|
2018-12-06 14:43:20 +00:00
|
|
|
window.location = window.location.origin.toString() + '/login#signup'
|
|
|
|
},
|
|
|
|
component: Home,
|
2018-11-14 08:53:06 +00:00
|
|
|
props: true
|
|
|
|
},
|
2018-12-10 13:05:27 +00:00
|
|
|
{
|
|
|
|
name: 'login',
|
|
|
|
path: '/Login',
|
|
|
|
beforeEnter(to, from, next) {
|
|
|
|
window.location = window.location.origin.toString() + '/login#login'
|
|
|
|
},
|
|
|
|
component: Home,
|
|
|
|
props: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'logout',
|
|
|
|
path: '/Logout',
|
|
|
|
beforeEnter(to, from, next) {
|
|
|
|
window.location = window.location.origin.toString() + '/?cmd=web_logout'
|
|
|
|
},
|
|
|
|
component: Home,
|
|
|
|
props: true
|
|
|
|
},
|
2018-11-26 11:23:51 +00:00
|
|
|
{
|
|
|
|
name: 'profile',
|
|
|
|
path: '/Profile',
|
|
|
|
component: ProfilePage,
|
2018-11-30 07:17:18 +00:00
|
|
|
props: true,
|
|
|
|
beforeEnter: (to, from, next) => {
|
2018-12-06 14:43:20 +00:00
|
|
|
if (!lms.store.checkLogin()) {
|
|
|
|
next({
|
|
|
|
name: 'home'
|
|
|
|
})
|
|
|
|
} else {
|
2018-11-30 07:17:18 +00:00
|
|
|
next()
|
|
|
|
}
|
|
|
|
}
|
2018-11-26 11:23:51 +00:00
|
|
|
}
|
2018-11-09 06:17:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
export default routes;
|