import { http } from "../utils/http";
import { loadEnv } from "@build/index";

const { VITE_PROXY_USER_REAL, VITE_PURCHASE_REPORT } = loadEnv();
const yewuApi = VITE_PROXY_USER_REAL + "/admin/";
const purchaseApi = VITE_PURCHASE_REPORT + "/admin/";
interface postType extends Promise<any> {
  data?: object;
  code?: number;
  message?: string;
}

//导出
export const httpExport = (
  url: string,
  data?: object,
  isPurchase = false
): postType => {
  return http.request("post", `${isPurchase ? purchaseApi : yewuApi}${url}`, {
    data,
    responseType: "blob"
  });
};
