style: Fixed route.js
This commit is contained in:
parent
28dd4c139e
commit
18a1a8d4f4
@ -6,88 +6,87 @@ import ListPage from "./pages/ListPage.vue";
|
|||||||
import ProfilePage from "./pages/ProfilePage.vue";
|
import ProfilePage from "./pages/ProfilePage.vue";
|
||||||
|
|
||||||
const routes = [{
|
const routes = [{
|
||||||
name: 'home',
|
name: 'home',
|
||||||
path: '',
|
path: '',
|
||||||
component: Home
|
component: Home
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'program',
|
name: 'program',
|
||||||
path: '/Program/:program_name',
|
path: '/Program/:program_name',
|
||||||
component: ProgramPage,
|
component: ProgramPage,
|
||||||
props: true
|
props: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'course',
|
name: 'course',
|
||||||
path: '/Program/:program_name/:course_name/',
|
path: '/Program/:program_name/:course_name/',
|
||||||
component: CoursePage,
|
component: CoursePage,
|
||||||
props: true,
|
props: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'content',
|
name: 'content',
|
||||||
path: '/Program/:program_name/:course_name/:topic/:type/:content',
|
path: '/Program/:program_name/:course_name/:topic/:type/:content',
|
||||||
component: ContentPage,
|
component: ContentPage,
|
||||||
props: true,
|
props: true,
|
||||||
beforeRouteUpdate (to, from, next) {
|
beforeRouteUpdate (to, from, next) {
|
||||||
if (lms.store.checkProgramEnrollment(to.params.program_name)) {
|
if (lms.store.checkProgramEnrollment(to.params.program_name)) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
next({
|
next({
|
||||||
name: 'program',
|
name: 'program',
|
||||||
params: {
|
params: {
|
||||||
program_name: to.params.program_name
|
program_name: to.params.program_name
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'list',
|
|
||||||
path: '/List/:master',
|
|
||||||
component: ListPage,
|
|
||||||
props: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'signup',
|
|
||||||
path: '/Signup',
|
|
||||||
beforeEnter(to, from, next) {
|
|
||||||
window.location = window.location.origin.toString() + '/login#signup'
|
|
||||||
},
|
|
||||||
component: Home,
|
|
||||||
props: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
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
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'profile',
|
|
||||||
path: '/Profile',
|
|
||||||
component: ProfilePage,
|
|
||||||
props: true,
|
|
||||||
beforeEnter: (to, from, next) => {
|
|
||||||
if (!lms.store.checkLogin()) {
|
|
||||||
next({
|
|
||||||
name: 'home'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
next()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
},
|
||||||
|
{
|
||||||
|
name: 'list',
|
||||||
|
path: '/List/:master',
|
||||||
|
component: ListPage,
|
||||||
|
props: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'signup',
|
||||||
|
path: '/Signup',
|
||||||
|
beforeEnter(to, from, next) {
|
||||||
|
window.location = window.location.origin.toString() + '/login#signup'
|
||||||
|
},
|
||||||
|
component: Home,
|
||||||
|
props: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'profile',
|
||||||
|
path: '/Profile',
|
||||||
|
component: ProfilePage,
|
||||||
|
props: true,
|
||||||
|
beforeEnter: (to, from, next) => {
|
||||||
|
if (!lms.store.checkLogin()) {
|
||||||
|
next({
|
||||||
|
name: 'home'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
export default routes;
|
export default routes;
|
||||||
Loading…
x
Reference in New Issue
Block a user