Эх сурвалжийг харах

fix请求学生信息网络请求失败

Michael Wang 6 жил өмнө
parent
commit
d5791978bb

+ 11 - 0
src/features/Login/Login.vue

@@ -177,6 +177,10 @@ export default {
           Math.abs(moment(response.headers.date).diff(moment())) >
           30 * 1000
         ) {
+          this.$Message.error({
+            content: "与服务器时间差异超过30秒,请校准本机时间之后再重试!",
+            duration: 30
+          });
           throw "与服务器时间差异超过30秒,请校准本机时间之后再重试!";
         }
         if (data.token) {
@@ -189,6 +193,13 @@ export default {
           const student = (await this.$http.get(
             "/api/ecs_core/student/getStudentInfoBySession"
           )).data;
+          if (student === undefined) {
+            this.$Message.error({
+              content: "获取学生信息失败,请重试!",
+              duration: 30
+            });
+            throw "获取学生信息失败,请重试!";
+          }
           const user = { ...data, ...student };
           this.updateUser(user);
           window.localStorage.setItem("user-for-reload", JSON.stringify(user));