haoxuan
2023-11-21 e43528753b71b00d6a751f449e1becaabf2968de
src/utils/request.js
@@ -1,8 +1,11 @@
import axios from "axios";
import util from "@/libs/util.js";
import { Message } from "element-ui";
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,12 +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
        })
        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
          })
        }
        // MessageBox.confirm( res.data.msg+"?", "提示", {
        //   confirmButtonText: "确定",
        //   cancelButtonText: "取消",
        //   type: "warning",
        // })
        //   .then(() => {
        //   })
        //   .catch(() => {});
      }
      return res.data ? res.data : {};
    }
@@ -60,8 +75,15 @@
    Message({
      message: message,
      type: 'error',
      duration: 5 * 1000
      duration: 3 * 1000
    })
    // MessageBox.confirm( message+"?", "提示", {
    //   confirmButtonText: "确定",
    //   cancelButtonText: "取消",
    //   type: "warning",
    // })
    //   .then(() => {})
    //   .catch(() => {});
    return Promise.reject(error)
  }
)