Browse Source

Merge branch 'gcj'

# Conflicts:
#	src/utils/request.js
guanchunjie 3 years ago
parent
commit
5599a5bfe8

+ 2 - 0
src/components/Adult/inputModules/DialogueArticleChs/index.vue

@@ -425,6 +425,7 @@ export default {
         let data = {
           fileName: file.raw.name,
           speechBase64: base_res[1],
+          language: "ch",
         };
         prepareTranscribe(data).then((res) => {
           _this.$set(_this.curQue, "taskId", res.data.taskId);
@@ -459,6 +460,7 @@ export default {
             taskId: this.curQue.taskId,
             verseList: JSON.stringify(verseList),
             matchType: "chinese",
+            language: "ch",
           };
           getWordTime(data).then((res) => {
             this.curQue.wordTime = res.data.result;

+ 1 - 1
src/components/Header.vue

@@ -250,7 +250,7 @@ export default {
     QuitLogin() {
       window.location.href = "/";
       removeSession("SysList");
-      removeToken();
+      // removeToken();
       this.userShow = false;
       this.userMessage = null;
     },

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

@@ -70,7 +70,7 @@ const actions = {
   // remove token
   resetToken({ commit }) {
     return new Promise(resolve => {
-      removeToken() // must remove  token  first
+      // removeToken() // must remove  token  first
       commit('RESET_STATE')
       resolve()
     })

+ 77 - 77
src/utils/request.js

@@ -10,94 +10,94 @@ axios.defaults.dataType = 'json'
 axios.defaults.headers['cache-control'] = 'no-cache'
 axios.defaults.headers['Content-Type'] = 'application/json'
 axios.defaults.headers['X-Requested-With'] = 'XMLHttpRequest'
-    // create an axios instance
+// create an axios instance
 const service = axios.create({
-    baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
-    // withCredentials: true, // send cookies when cross-domain requests
-    timeout: 60000 // request timeout
+  baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
+  // withCredentials: true, // send cookies when cross-domain requests
+  timeout: 60000 // request timeout
 })
 
 // request interceptor
 service.interceptors.request.use(
-    config => {
-        // do something before request is sent
-        // let each request carry token
-        // ['X-Token'] is a custom headers key
-        // please modify it according to the actual situation
-        config.headers['Content-Type'] = 'application/json'
-        return config
-    },
-    error => {
-        // do something with request error
-        console.log(error) // for debug
-        return Promise.reject(error)
-    }
+  config => {
+    // do something before request is sent
+    // let each request carry token
+    // ['X-Token'] is a custom headers key
+    // please modify it according to the actual situation
+    config.headers['Content-Type'] = 'application/json'
+    return config
+  },
+  error => {
+    // do something with request error
+    console.log(error) // for debug
+    return Promise.reject(error)
+  }
 )
 
 // response interceptor
 service.interceptors.response.use(
-    /**
-     * If you want to get http information such as headers or status
-     * Please return  response => response
-     */
+  /**
+   * If you want to get http information such as headers or status
+   * Please return  response => response
+   */
 
-    /**
-     * Determine the request status by custom code
-     * Here is just an example
-     * You can also judge the status by HTTP Status Code
-     */
-    response => {
-        const res = response.data
-            // console.log(res)
-        let msg = null
-            // if the custom code is not 20000, it is judged as an error.
-        if (res.status == 0 || res.status == -2) {
-            // 执行错误  JSON 数据格式错误
-            msg = Message({
-                message: res.msg || res.error || 'Error',
-                type: 'error',
-                showClose: true,
-                duration: 0
-            })
-            return Promise.reject(new Error(res.message || res.error || 'Error'))
-        } else if (res.status === -1) {
-            // 登录失效
-            Cookies.remove('session_id')
-            Cookies.remove('user_code')
-            Cookies.remove('user_real_name')
-            Cookies.remove('user_type')
-            removeToken();
-            msg = Message({
-                message: '登录会话失效,请重新登录',
-                type: 'error',
-                showClose: true,
-                duration: 0
-            })
-            if (process.env.NODE_ENV === 'development') {
-                router.push(`/login`)
-            } else {
-                window.location.href = '/';
-            }
-            return false
-        } else {
-            Message.closeAll()
-            return res
-        }
-    },
-    error => {
-        // || (error+1).indexOf('500') > -1
-        if ((error + 1).indexOf('401') > -1) {
-            // console.log(router)
-            // store.dispatch('user/postError')
-            // router.push(`/login`)
-        }
-        Message({
-            message: '网络错误,请稍后重试',
-            type: 'error',
-            duration: 2 * 1000
-        })
-        return Promise.reject(error)
+  /**
+   * Determine the request status by custom code
+   * Here is just an example
+   * You can also judge the status by HTTP Status Code
+   */
+  response => {
+    const res = response.data
+    // console.log(res)
+    let msg = null
+    // if the custom code is not 20000, it is judged as an error.
+    if (res.status == 0 || res.status == -2) {
+      // 执行错误  JSON 数据格式错误
+      msg = Message({
+        message: res.msg || res.error || 'Error',
+        type: 'error',
+        showClose: true,
+        duration: 0
+      })
+      return Promise.reject(new Error(res.message || res.error || 'Error'))
+    } else if (res.status === -1) {
+      // 登录失效
+      Cookies.remove('session_id')
+      Cookies.remove('user_code')
+      Cookies.remove('user_real_name')
+      Cookies.remove('user_type')
+      removeToken();
+      msg = Message({
+        message: '登录会话失效,请重新登录',
+        type: 'error',
+        showClose: true,
+        duration: 0
+      })
+      if (process.env.NODE_ENV === 'development') {
+        router.push(`/login`)
+      } else {
+        window.location.href = '/';
+      }
+      return false
+    } else {
+      Message.closeAll()
+      return res
+    }
+  },
+  error => {
+    // || (error+1).indexOf('500') > -1
+    if ((error + 1).indexOf('401') > -1) {
+      // console.log(router)
+      // store.dispatch('user/postError')
+      // router.push(`/login`)
     }
+    Message({
+      message: '网络错误,请稍后重试',
+      type: 'error',
+      duration: 2 * 1000
+    })
+    return Promise.reject(error)
+  }
 )
 
 export default service

+ 1 - 1
vue.config.js

@@ -42,7 +42,7 @@ module.exports = {
       // change xxx-api/login => mock/login
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://gcls.helxsoft.cn/`,
+        target: `http://gcls.utschool.cn/`,
         changeOrigin: true,
         pathRewrite: {
           ['^' + process.env.VUE_APP_BASE_API]: ''