var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/_util/axios/index.ts
var axios_exports = {};
__export(axios_exports, {
  default: () => axios_default,
  del: () => del,
  get: () => get,
  post: () => post,
  put: () => put
});
module.exports = __toCommonJS(axios_exports);
var import_axios = __toESM(require("axios"));
var import_antd = require("antd");
var import_config = require("./config");
var service = import_axios.default.create({
  timeout: 2e5,
  // 请求超时时间
  withCredentials: true
  // 允许携带cookie
});
service.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);
service.interceptors.response.use(
  // HTTP的状态码(只有200才走这里)
  (response2) => {
    const headers = response2.headers;
    const res = response2.data;
    if (+res.code === import_config.ServerCode.SUCCESS)
      return headers.no_format ? response2 : response2.data;
    return Promise.reject({ data: res, response: response2 });
  },
  (err) => {
    return Promise.reject(err);
  }
);
function isResponseError(x) {
  return x.data;
}
function isAxiosError(x) {
  return x.response;
}
var errHandle = (err) => {
  let errResult = {};
  let code = -1;
  let errorMsg = "";
  if (isAxiosError(err) && err.response) {
    code = +err.response.status;
    errorMsg = import_config.ServerCodeMap[code];
  }
  if (isResponseError(err)) {
    code = +err.data.code;
    errorMsg = err.data.msg || import_config.ServerCodeMap[code];
    errResult = err.data;
  }
  ![import_config.ServerCode.CONTINUE].includes(code) && import_antd.message.error(errorMsg);
  if (import_config.ServerCode.NO_LOGIN == code) {
  }
  if (import_config.ServerCode.FORBIDDEN == code) {
  }
  return Promise.reject(errResult);
};
var response = (axiosObj) => {
  return axiosObj.then((res) => res.data).catch((err) => errHandle(err));
};
var get = ({ url, data, ...req }) => response(service.get(url, { params: { ...data, time: Date.now() }, ...req }));
var post = ({ url, data, ...req }) => response(service.post(url, data, { ...req }));
var put = ({ url, data, ...req }) => response(service.put(url, data, { ...req }));
var del = ({ url, data, ...req }) => response(service.delete(url, { data, ...req }));
var axios_default = service;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  del,
  get,
  post,
  put
});
