Browse Source

feat(permission): 添加用户登录时的API请求处理

在用户登录时新增向beta.api.cocorobo.cn发送POST请求的功能,静默处理可能的错误
同时更新了dist目录下的相关构建文件
lsc 1 month ago
parent
commit
65bee47d5a
4 changed files with 21 additions and 1 deletions
  1. 0 0
      dist/index.html
  2. 1 1
      dist/report.html
  3. 0 0
      dist/static/js/app.f7aaaa00.js
  4. 20 0
      src/permission.js

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.f7aaaa00.js


+ 20 - 0
src/permission.js

@@ -36,6 +36,26 @@ router.beforeEach(async(to, from, next) => {
     await store.commit('SET_SHARECOURSEID', shareCourseId)
   }
   if (hasToken) {
+    const loginData = JSON.stringify({
+      openid: hasToken,
+      edu: true
+    })
+    const myHeaders = new Headers()
+    myHeaders.append('Content-Type', 'application/json')
+    const requestOptionsLogin = {
+      method: 'POST',
+      headers: myHeaders,
+      body: loginData,
+      redirect: 'follow',
+      credentials: 'include'
+    }
+
+    try {
+      const response = await fetch('https://beta.api.cocorobo.cn/api/user', requestOptionsLogin)
+      await response.text()
+    } catch (e) {
+      // 静默处理,不影响后续流程
+    }
     await store.commit('user/SET_ID', hasToken)
     if (to.path === '/login' || to.path === '/login2') {
       // if is logged in, redirect to the home page

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