|
@@ -18,14 +18,16 @@ router.beforeEach(async(to, from, next) => {
|
|
|
// const hasToken = getToken()
|
|
|
const hasToken = store.getters.id
|
|
|
|
|
|
- if (to.query.courseid) {
|
|
|
+ if (to.query.courseid !== '' && to.query.courseid !== undefined) {
|
|
|
+ console.log(to.query.courseid);
|
|
|
await store.commit('SET_COURSEID', to.query.courseid)
|
|
|
}
|
|
|
- if (to.query.testid) {
|
|
|
+ if (to.query.testid !== '' && to.query.testid !== undefined) {
|
|
|
await store.commit('SET_TESTID', to.query.testid)
|
|
|
}
|
|
|
- if (to.query.shareCourseId) {
|
|
|
- await store.commit('SET_SHARECOURSEID', to.query.shareCourseId)
|
|
|
+ let shareCourseId = window.location.href.indexOf("?shareCourseId=")!=-1?window.location.href.split("?shareCourseId=")[1].toString():''
|
|
|
+ if (shareCourseId) {
|
|
|
+ await store.commit('SET_SHARECOURSEID', shareCourseId)
|
|
|
}
|
|
|
if (hasToken) {
|
|
|
if (to.path === '/login') {
|
|
@@ -48,13 +50,16 @@ router.beforeEach(async(to, from, next) => {
|
|
|
const courseId = store.getters.courseId
|
|
|
const testId = store.getters.testId
|
|
|
const shareCourseId = store.getters.shareCourseId
|
|
|
+ await store.commit('SET_TESTID', '')
|
|
|
+ await store.commit('SET_COURSEID', '')
|
|
|
+ await store.commit('SET_SHARECOURSEID', '')
|
|
|
// // 根据角色生成可访问的路线图
|
|
|
if (courseId) {
|
|
|
next({ ...to, query: { courseid: courseId }, replace: true })
|
|
|
} else if (testId) {
|
|
|
next({ ...to, query: { courseid: testId }, replace: true })
|
|
|
} else if (shareCourseId) {
|
|
|
- next({ path: '/course', query: { courseid: shareCourseId, urlType: 1 }, replace: true })
|
|
|
+ next({ path: '/courseDetail', query: { courseid: shareCourseId, urlType: 1 }, replace: true })
|
|
|
} else {
|
|
|
next({ ...to, replace: true })
|
|
|
}
|