lsc 3 days ago
parent
commit
501016159a

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 1 - 1
dist/report.html


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.1f0124ad.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.a829f1fa.js


+ 6 - 24
src/permission.js

@@ -5,6 +5,7 @@ import 'nprogress/nprogress.css' // progress bar style
 // import { getToken } from '@/utils/auth' // get token from cookie
 import Cookies from 'js-cookie'
 import { getToken } from '@/utils/auth'
+import user from './store/modules/user'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
@@ -38,6 +39,7 @@ router.beforeEach(async(to, from, next) => {
     await store.commit('SET_SHARECOURSEID', shareCourseId)
   }
   if (hasToken) {
+    await store.commit('user/SET_ID', hasToken)
     if (to.path === '/login' || to.path === '/login2') {
       // if is logged in, redirect to the home page
       store.commit('user/SET_ID', hasToken)
@@ -75,33 +77,12 @@ router.beforeEach(async(to, from, next) => {
       console.log('userinfo', userinfo)
       // console.log('to', {...to} )
       if (userinfo) {
-        const data = await store.dispatch('user/getInfo')
-        await store.commit('user/SET_USERINFO', data)
-
-        const courseId = to.query.courseid
-        const testId = to.query.testid
-        const shareCourseId = to.query.shareCourseId
-        await store.commit('SET_TESTID', '')
-        await store.commit('SET_COURSEID', '')
-        await store.commit('SET_SHARECOURSEID', '')
-
-        // // 根据角色生成可访问的路线图
-        if (courseId) {
-          next({ path: '/courseDetail', query: { courseid: courseId, userid: hasToken }, replace: true })
-        } else if (testId) {
-          next({ path: '/testDetail', query: { courseid: testId, userid: hasToken }, replace: true })
-        } else if (shareCourseId) {
-          next({
-            path: '/courseDetail',
-            query: { courseid: shareCourseId, urlType: 1, userid: hasToken },
-            replace: true
-          })
-        } else {
-          next()
-        }
+        console.log(store)
+        next()
       } else {
         try {
           // 获取用户信息
+          console.log(store)
           const data = await store.dispatch('user/getInfo')
           await store.commit('user/SET_USERINFO', data)
           const courseId = store.getters.courseId
@@ -128,6 +109,7 @@ router.beforeEach(async(to, from, next) => {
           // remove token and go to login page to re-login
           // await store.dispatch('user/resetToken')
           // Notify({ type: 'danger', message: error || '发生异常' })
+          console.error(error)
           next(`/login?redirect=${to.path}`)
           NProgress.done()
         }

+ 4 - 4
src/store/modules/user.js

@@ -76,10 +76,10 @@ const actions = {
           resolve(_user.userid)
         })
         .catch(error => {
-          //   var _user = { userid: '6c56ec0e-2c74-11ef-bee5-005056b86db5' }
-          //   commit('SET_ID', _user.userid)
-          //   setToken(_user.userid)
-          //   resolve(_user.userid)
+          var _user = { userid: '6c56ec0e-2c74-11ef-bee5-005056b86db5' }
+          commit('SET_ID', _user.userid)
+          setToken(_user.userid)
+          resolve(_user.userid)
           reject(error)
         })
     })

Some files were not shown because too many files changed in this diff