Browse Source

错误消息字段修改

黄琪勇 2 months ago
parent
commit
b9b3908e5d
5 changed files with 18 additions and 18 deletions
  1. 4 4
      src/libs/axios.ts
  2. 11 11
      src/plugins/httpAjax.ts
  3. 1 1
      src/router/index.ts
  4. 1 1
      src/store/user.ts
  5. 1 1
      src/type.d.ts

+ 4 - 4
src/libs/axios.ts

@@ -42,7 +42,7 @@ class HttpAsynAxios {
         Nprogress.done()
         const rejectData: apiResDataType = {
           code: 500,
-          msg: "系统运行异常,请联系管理员处理",
+          message: "系统运行异常,请联系管理员处理",
           data: null
         }
         return Promise.reject(rejectData)
@@ -57,7 +57,7 @@ class HttpAsynAxios {
           // 如果token登录状态 才提示和退出
           if (TokenInvalidFlag) {
             // const responseData: apiResDataType = response.data
-            // ElMessage.error(responseData.msg)
+            // ElMessage.error(responseData.message)
             // 登出
             userStore().resetUser()
           }
@@ -77,12 +77,12 @@ class HttpAsynAxios {
           error.code === CODE_ERR_CANCELED
             ? {
                 code: error.code,
-                msg: "系统取消接口",
+                message: "系统取消接口",
                 data: null
               }
             : {
                 code: 500,
-                msg: "系统运行异常,请联系管理员处理",
+                message: "系统运行异常,请联系管理员处理",
                 data: null
               }
         return Promise.reject(rejectData) // 返回接口返回的错误信息

+ 11 - 11
src/plugins/httpAjax.ts

@@ -25,7 +25,7 @@ export const httpAjaxErrMsg = function <T extends axiosApiType, P extends Parame
         if (data.code !== 200) {
           ElMessage({
             showClose: true,
-            message: data.msg,
+            message: data.message,
             type: "error"
           })
         }
@@ -34,7 +34,7 @@ export const httpAjaxErrMsg = function <T extends axiosApiType, P extends Parame
       .catch(err => {
         ElMessage({
           showClose: true,
-          message: err.msg,
+          message: err.message,
           type: "error"
         })
         resolve(err)
@@ -69,7 +69,7 @@ export const httpAjaxLoadingErrMsg = function <T extends axiosApiType, P extends
         if (data.code !== 200) {
           ElMessage({
             showClose: true,
-            message: data.msg,
+            message: data.message,
             type: "error"
           })
         }
@@ -79,7 +79,7 @@ export const httpAjaxLoadingErrMsg = function <T extends axiosApiType, P extends
         LoadingBar.loading(false)
         ElMessage({
           showClose: true,
-          message: err.msg,
+          message: err.message,
           type: "error"
         })
         resolve(err)
@@ -98,7 +98,7 @@ export const httpAjaxCrud = function <T extends axiosApiType, P extends Paramete
           ElNotification({
             type: "success",
             title: "成功",
-            message: data.msg,
+            message: data.message,
             position: "top-right",
             duration: 3000
           })
@@ -106,7 +106,7 @@ export const httpAjaxCrud = function <T extends axiosApiType, P extends Paramete
           ElNotification({
             type: "error",
             title: "失败",
-            message: data.msg,
+            message: data.message,
             position: "top-right",
             duration: 3000
           })
@@ -118,7 +118,7 @@ export const httpAjaxCrud = function <T extends axiosApiType, P extends Paramete
         ElNotification({
           type: "error",
           title: "失败",
-          message: err.msg,
+          message: err.message,
           position: "top-right",
           duration: 3000
         })
@@ -136,12 +136,12 @@ export const httpAjaxAlert = function <T extends axiosApiType, P extends Paramet
         LoadingBar.loading(false)
         const data = res.data as apiResDataType
         if (data.code === 200) {
-          ElMessageBox.alert(data.msg, "提示", {
+          ElMessageBox.alert(data.message, "提示", {
             confirmButtonText: "关闭",
             type: "success"
           })
         } else {
-          ElMessageBox.alert(data.msg, "提示", {
+          ElMessageBox.alert(data.message, "提示", {
             confirmButtonText: "关闭",
             type: "error"
           })
@@ -150,7 +150,7 @@ export const httpAjaxAlert = function <T extends axiosApiType, P extends Paramet
       })
       .catch(err => {
         LoadingBar.loading(false)
-        ElMessageBox.alert(err.msg, "提示", {
+        ElMessageBox.alert(err.message, "提示", {
           confirmButtonText: "关闭",
           type: "error"
         })
@@ -180,7 +180,7 @@ export const httpAjaxDownload = function <T extends axiosApiType, P extends Para
       LoadingBar.loading(false)
       ElMessage({
         showClose: true,
-        message: err.msg,
+        message: err.message,
         type: "error"
       })
     })

+ 1 - 1
src/router/index.ts

@@ -44,7 +44,7 @@ router.beforeEach((to, from, next) => {
         .catch((err: apiResDataType) => {
           //退出 清空,当是登录权限问题时候 axios 里面会清空
           if (err.code !== CODE401) {
-            //ElMessage.error(err.msg)
+            //ElMessage.error(err.message)
             userStoreHook.resetUser()
           }
         })

+ 1 - 1
src/store/user.ts

@@ -43,7 +43,7 @@ const useStore = defineStore("user", {
         return Promise.reject({
           code: "500",
           data: null,
-          msg: "获取用户信息出错,请联系管理员!"
+          message: "获取用户信息出错,请联系管理员!"
         })
       }
       this.userInfo = userInfo

+ 1 - 1
src/type.d.ts

@@ -6,7 +6,7 @@
 declare interface apiResDataType {
   code: number | "ERR_CANCELED"
   data: any
-  msg: string
+  message: string
 }
 
 /*