lsc 2 years ago
parent
commit
7986519d07

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


+ 1 - 0
dist/static/css/chunk-01fee073.ad81e6e5.css

@@ -0,0 +1 @@
+.loginBox[data-v-4db72bf8]{position:relative;width:100vw;height:100vh;overflow:hidden}.loginBox>iframe[data-v-4db72bf8]{width:100%;height:100%;border:0}

File diff suppressed because it is too large
+ 0 - 0
dist/static/css/chunk-95a5d692.567f4569.css


+ 0 - 1
dist/static/css/chunk-ddf9f6a2.a862a943.css

@@ -1 +0,0 @@
-.loginBox[data-v-36b7e306]{position:relative;width:100vw;height:100vh;overflow:hidden}.loginBox>iframe[data-v-36b7e306]{width:100%;height:100%;border:0}

File diff suppressed because it is too large
+ 0 - 0
dist/static/css/chunk-f86d6f0a.01c4b8e8.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/chunk-vantUI.544b34f0.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/chunk-vantUI.59e9178d.css


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


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


+ 1 - 0
dist/static/js/chunk-01fee073.2d322cbe.js

@@ -0,0 +1 @@
+(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-01fee073"],{"68b8":function(e,t,r){"use strict";var n=r("954d"),i=r.n(n);i.a},"954d":function(e,t,r){},"9ed6":function(e,t,r){"use strict";r.r(t);var n=function(){var e=this,t=e.$createElement;e._self._c;return e._m(0)},i=[function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"loginBox"},[r("iframe",{attrs:{src:"//edu.cocorobo.cn/course/login?type=2",frameborder:"0"}})])}],c=(r("96cf"),r("1da1")),o=r("5530"),u=r("2f62"),a={data:function(){return{redirect:void 0,timer:null}},watch:{$route:{handler:function(e){this.redirect=e.query&&e.query.redirect},immediate:!0}},methods:Object(o["a"])(Object(o["a"])({},Object(u["b"])({login:"user/login"})),{},{handleLogin:function(){this.$router.push({path:this.redirect||"/"})},getLogin:function(){var e=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.login;case 2:r=t.sent,r&&e.$router.push({path:e.redirect||"/"});case 4:case"end":return t.stop()}}),t)})))()}}),beforeDestroy:function(){clearInterval(this.timer),this.timer=null},mounted:function(){var e=this;this.timer=setInterval((function(){e.getLogin()}),2e3)}},s=a,l=(r("68b8"),r("2877")),d=Object(l["a"])(s,n,i,!1,null,"4db72bf8",null);t["default"]=d.exports}}]);

File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-0cf437fc.ef1187f0.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-95a5d692.74349733.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-9b0892b0.f6480e58.js


+ 0 - 1
dist/static/js/chunk-ddf9f6a2.9c0b6591.js

@@ -1 +0,0 @@
-(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-ddf9f6a2"],{"1cac":function(e,t,r){},"9ed6":function(e,t,r){"use strict";r.r(t);var n=function(){var e=this,t=e.$createElement;e._self._c;return e._m(0)},c=[function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"loginBox"},[r("iframe",{attrs:{src:"https://edu.cocorobo.cn/course/login?type=2",frameborder:"0"}})])}],i={data:function(){return{redirect:void 0}},watch:{$route:{handler:function(e){this.redirect=e.query&&e.query.redirect},immediate:!0}},methods:{handleLogin:function(){this.$router.push({path:this.redirect||"/"})}}},o=i,a=(r("b64b0"),r("2877")),u=Object(a["a"])(o,n,c,!1,null,"36b7e306",null);t["default"]=u.exports},b64b0:function(e,t,r){"use strict";var n=r("1cac"),c=r.n(n);c.a}}]);

File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-f86d6f0a.cc5ce57d.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-libs.80edb424.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-libs.915c5fcb.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-vantUI.1fb0481d.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-vantUI.2c46554a.js


+ 10 - 0
src/api/course.js

@@ -48,3 +48,13 @@ export function addPz2(data) {
     hideloading: false
   })
 }
+
+// 删除批注
+export function deletePz(data) {
+  return request({
+    url: '/deletePz',
+    method: 'post',
+    data,
+    hideloading: false
+  })
+}

+ 27 - 3
src/api/user.js

@@ -1,6 +1,30 @@
-// import api from './index'
-// // axios
-// import request from '@/utils/request'
+// axios
+import request from '@/utils/request'
+
+// 用户信息 post 方法
+export function eduGet() {
+  return request({
+    url: '//beta.api.cocorobo.cn/api/getcookieuserid',
+    method: 'GET',
+    hideloading: true
+  })
+}
+export function eduGetUserinfo(rk) {
+  return request({
+    url: `//api.edu.cocorobo.cn/edu/admin/userinfo/userinfoById/${rk}`,
+    method: 'GET',
+    hideloading: true
+  })
+}
+
+export function getUser(data) {
+  return request({
+    url: `/selectUser`,
+    method: 'GET',
+    params: data,
+    hideloading: true
+  })
+}
 
 // // 登录
 // export function login(data) {

+ 10 - 19
src/permission.js

@@ -26,22 +26,13 @@ router.beforeEach(async(to, from, next) => {
       NProgress.done()
     } else {
       const hasRoles = store.getters.roles && store.getters.roles.length > 0
-      debugger
       if (hasRoles) {
         next()
       } else {
         try {
           // 获取用户信息
-          const { roles } = await store.dispatch('user/getInfo')
-
+          store.dispatch('user/getInfo')
           // // 根据角色生成可访问的路线图
-          const accessRoutes = await store.dispatch('permission/generateRoutes', roles)
-          // // 动态添加可访问的路线
-
-          var routes = router.options.routes
-          routes = routes.concat(accessRoutes)
-          router.options.routes = routes
-          router.addRoutes(accessRoutes)
           next({ ...to, replace: true })
         } catch (error) {
           // remove token and go to login page to re-login
@@ -53,16 +44,16 @@ router.beforeEach(async(to, from, next) => {
       }
     }
   } else {
+    // next()
     /* has no token*/
-    next()
-    // if (whiteList.indexOf(to.path) !== -1) {
-    //   // in the free login whitelist, go directly
-    //   next()
-    // } else {
-    //   //   // other pages that do not have permission to access are redirected to the login page.
-    //   next(`/login?redirect=${to.path}`)
-    //   NProgress.done()
-    // }
+    if (whiteList.indexOf(to.path) !== -1) {
+      // in the free login whitelist, go directly
+      next()
+    } else {
+      //   // other pages that do not have permission to access are redirected to the login page.
+      next(`/login?redirect=${to.path}`)
+      NProgress.done()
+    }
   }
 })
 

+ 2 - 1
src/plugins/vant.js

@@ -1,6 +1,6 @@
 // 按需全局引入 vant组件
 import Vue from 'vue'
-import { Button, List, Cell, Tabbar, TabbarItem, Notify, Field, CellGroup, Toast } from 'vant'
+import { Button, List, Cell, Tabbar, TabbarItem, Notify, Field, CellGroup, Toast, Dialog } from 'vant'
 Vue.use(Button)
   .use(Cell)
   .use(List)
@@ -10,3 +10,4 @@ Vue.use(Button)
   .use(Field)
   .use(CellGroup)
   .use(Toast)
+  .use(Dialog)

+ 3 - 1
src/store/index.js

@@ -2,12 +2,14 @@ import Vue from 'vue'
 import Vuex from 'vuex'
 import getters from './getters'
 import app from './modules/app'
+import user from './modules/user'
 
 Vue.use(Vuex)
 
 const store = new Vuex.Store({
   modules: {
-    app
+    app,
+    user
   },
   getters
 })

+ 3 - 14
src/store/modules/app.js

@@ -1,17 +1,6 @@
-const state = {
-  userName: ''
-}
-const mutations = {
-  SET_USER_NAME(state, name) {
-    state.userName = name
-  }
-}
-const actions = {
-  // 设置name
-  setUserName({ commit }, name) {
-    commit('SET_USER_NAME', name)
-  }
-}
+const state = {}
+const mutations = {}
+const actions = {}
 export default {
   state,
   mutations,

+ 60 - 27
src/store/modules/user.js

@@ -1,7 +1,7 @@
-import { user_info, login } from '@/api/user'
+// import { user_info, login } from '@/api/user'
+import { eduGet, getUser } from '@/api/user'
 import { getToken, removeToken, setToken } from '@/utils/auth'
 import { resetRouter } from '@/router'
-
 const getDefaultState = () => {
   return {
     token: getToken(),
@@ -10,12 +10,12 @@ const getDefaultState = () => {
     name: '',
     username: '',
     avatar: '',
-    is_init: false
+    is_init: false,
+    userinfo: ''
   }
 }
 
 const state = getDefaultState()
-
 const mutations = {
   RESET_STATE: state => {
     Object.assign(state, getDefaultState())
@@ -40,32 +40,46 @@ const mutations = {
   },
   SET_AVATAR: (state, avatar) => {
     state.avatar = avatar
+  },
+  SET_USERINFO: (state, userinfo) => {
+    state.userinfo = userinfo
   }
 }
 
 const actions = {
   // user login
-  login({ commit }, userInfo) {
-    const { username, password } = userInfo
+  // login({ commit }, userInfo) {
+  //   const { username, password } = userInfo
+  //   return new Promise((resolve, reject) => {
+  //     login({ username: username.trim(), password: password })
+  //       .then(response => {
+  //         const { data } = response
+  //         const token = 'JWT ' + data.token
+  //         commit('SET_TOKEN', token)
+  //         setToken(token)
+  //         resolve()
+  //       })
+  //       .catch(error => {
+  //         reject(error)
+  //       })
+  //   })
+  // },
+  login({ commit }) {
     return new Promise((resolve, reject) => {
-      login({ username: username.trim(), password: password })
+      eduGet()
         .then(response => {
-          const { data } = response
-          const token = 'JWT ' + data.token
-          commit('SET_TOKEN', token)
-          setToken(token)
-          resolve()
+          var _user = response.value[0][0]
+          setToken(_user.userid)
+          resolve(_user.userid)
         })
         .catch(error => {
           reject(error)
         })
     })
   },
-
-  // get user info
   getInfo({ commit, state }) {
     return new Promise((resolve, reject) => {
-      user_info()
+      getUser()
         .then(response => {
           const { data } = response
 
@@ -73,18 +87,7 @@ const actions = {
             reject('验证失败,请重新登录。')
           }
           console.log(response)
-
-          const { id, roles, is_init, cn, avatar, username } = response.data
-          // roles must be a non-empty array
-          if (!roles || roles.length <= 0) {
-            reject('getInfo: 角色必须为非空数组!')
-          }
-          commit('SET_NAME', cn)
-          commit('SET_USERNAME', username)
-          commit('SET_ROLES', roles)
-          commit('SET_ID', id)
-          commit('SET_AVATAR', avatar)
-          commit('SET_IS_INIT', is_init)
+          commit('SET_USERINFO', response.data)
           resolve(data)
         })
         .catch(error => {
@@ -92,6 +95,36 @@ const actions = {
         })
     })
   },
+  // get user info
+  // getInfo({ commit, state }) {
+  //   return new Promise((resolve, reject) => {
+  //     getUser()
+  //       .then(response => {
+  //         const { data } = response
+
+  //         if (!data) {
+  //           reject('验证失败,请重新登录。')
+  //         }
+  //         console.log(response)
+
+  //         const { id, roles, is_init, cn, avatar, username } = response.data
+  //         // roles must be a non-empty array
+  //         if (!roles || roles.length <= 0) {
+  //           reject('getInfo: 角色必须为非空数组!')
+  //         }
+  //         commit('SET_NAME', cn)
+  //         commit('SET_USERNAME', username)
+  //         commit('SET_ROLES', roles)
+  //         commit('SET_ID', id)
+  //         commit('SET_AVATAR', avatar)
+  //         commit('SET_IS_INIT', is_init)
+  //         resolve(data)
+  //       })
+  //       .catch(error => {
+  //         reject(error)
+  //       })
+  //   })
+  // },
 
   // user logout
   logout({ commit, state }) {

+ 1 - 2
src/utils/request.js

@@ -8,8 +8,7 @@ import { baseApi } from '@/config'
 // create an axios instance
 const service = axios.create({
   baseURL: baseApi, // url = base api url + request url
-  withCredentials: true, // send cookies when cross-domain requests
-  timeout: 5000 // request timeout
+  withCredentials: true // send cookies when cross-domain requests
 })
 
 // request拦截器 request interceptor

+ 35 - 3
src/views/course/components/commentBox.vue

@@ -8,7 +8,8 @@
           <div>
             {{ pz.username && pz.username.length > 8 ? pz.username.substring(0, 8) + '...' : pz.username }}的批注
           </div>
-          <div class="pzDelete" v-if="pz.userid == userid" @click="deletePz(pz.id)">
+          <!-- v-if="pz.userid == userid" -->
+          <div class="pzDelete" @click="deletePz(pz.id)">
             删除
           </div>
         </div>
@@ -44,7 +45,7 @@
 
 <script>
 import commentPanel from './commentPanel.vue'
-import { getCoursePz } from '@/api/course'
+import { getCoursePz, deletePz } from '@/api/course'
 export default {
   props: {
     courseid: {
@@ -82,6 +83,37 @@ export default {
     }
   },
   methods: {
+    deletePz(id) {
+      this.$dialog({
+        message: '确定删除此批注吗?',
+        showCancelButton: true,
+        beforeClose: (action, done) => {
+          if (action === 'confirm') {
+            const params = [
+              {
+                id: id
+              }
+            ]
+            deletePz(params)
+              .then(res => {
+                this.$toast({
+                  message: '删除成功',
+                  type: 'success'
+                })
+                this.getData()
+                done()
+              })
+              .catch(err => {
+                console.error(err)
+                done()
+              })
+          } else {
+            // 拦截取消操作
+            done()
+          }
+        }
+      })
+    },
     getData() {
       const params = {
         cid: this.courseid,
@@ -170,7 +202,7 @@ export default {
     cursor: pointer;
     margin-left: auto;
     font-size: 14px;
-    color: rgb(248, 248, 248);
+    color: rgb(135, 135, 135);
   }
 
   .pzNavTop > div:nth-child(1) {

+ 23 - 2
src/views/login/index.vue

@@ -1,15 +1,17 @@
 <template>
   <div class="loginBox">
-    <iframe src="https://edu.cocorobo.cn/course/login?type=2" frameborder="0"></iframe>
+    <iframe src="//edu.cocorobo.cn/course/login?type=2" frameborder="0"></iframe>
     <!-- <button @click="handleLogin">登录</button> -->
   </div>
 </template>
 
 <script>
+import { mapActions } from 'vuex'
 export default {
   data() {
     return {
-      redirect: undefined
+      redirect: undefined,
+      timer: null
     }
   },
   watch: {
@@ -21,9 +23,28 @@ export default {
     }
   },
   methods: {
+    ...mapActions({
+      login: 'user/login'
+    }),
     handleLogin() {
       this.$router.push({ path: this.redirect || '/' })
+    },
+    async getLogin() {
+      const userid = await this.login
+      if (userid) {
+        this.$router.push({ path: this.redirect || '/' })
+      }
+      // eduGet().then(res => {})
     }
+  },
+  beforeDestroy() {
+    clearInterval(this.timer)
+    this.timer = null
+  },
+  mounted() {
+    this.timer = setInterval(() => {
+      this.getLogin()
+    }, 2000)
   }
 }
 </script>

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