songshankun
2023-11-22 f6739d7542be48f7f8139c3d5fc7b2326e5cfc8d
src/utils/request.js
@@ -1,8 +1,11 @@
import axios from "axios";
import util from "@/libs/util.js";
import { Message,MessageBox } from "element-ui";
import {FilterMessage} from "@/utils/filterMessage";
// import router from '@/router'
const m= new FilterMessage(3000)
let Axios = axios.create({
  responseType: "json",
@@ -38,20 +41,24 @@
      return res.data ? res.data : {};
    } else {
      if(!res.config.loadingFlag){
        // Message({
        //   // message: res.data.msg==res.data.data?res.data.data:res.data.msg+','+res.data.data,
        //   message: res.data.msg,
        //   type: 'error',
        //   duration: 5 * 1000
        // })
        MessageBox.confirm( res.data.msg+"?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
        if (!m.has(res.data.msg)){
          m.add(res.data.msg)
          Message({
            // message: res.data.msg==res.data.data?res.data.data:res.data.msg+','+res.data.data,
            message: res.data.msg,
            type: 'error',
            duration: 3 * 1000
          })
          .catch(() => {});
        }
        // MessageBox.confirm( res.data.msg+"?", "提示", {
        //   confirmButtonText: "确定",
        //   cancelButtonText: "取消",
        //   type: "warning",
        // })
        //   .then(() => {
        //   })
        //   .catch(() => {});
      }
      return res.data ? res.data : {};
    }
@@ -65,18 +72,18 @@
    } else if (message.includes('Request failed with status code')) {
      message = '系统接口' + message.substr(message.length - 3) + '异常'
    }
    // Message({
    //   message: message,
    //   type: 'error',
    //   duration: 5 * 1000
    // })
    MessageBox.confirm( message+"?", "提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    Message({
      message: message,
      type: 'error',
      duration: 3 * 1000
    })
      .then(() => {})
      .catch(() => {});
    // MessageBox.confirm( message+"?", "提示", {
    //   confirmButtonText: "确定",
    //   cancelButtonText: "取消",
    //   type: "warning",
    // })
    //   .then(() => {})
    //   .catch(() => {});
    return Promise.reject(error)
  }
)