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 emptyApi = VITE_PROXY_USER_REAL;

interface postType extends Promise<any> {
  data?: object;
  code?: number;
  message?: string;
}

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