const readFile = (file) => {
  return new Promise((resolve) => {
    try {
      const reader = new FileReader();
      reader.onload = (evt) => {
        if (evt.target) {
          resolve(evt.target.result);
        }
      };
      reader.readAsText(file);
    } catch (error) {
      window["$message"].error("文件读取失败！");
    }
  });
};
const downloadByA = (url, filename = (/* @__PURE__ */ new Date()).getTime(), fileSuffix) => {
  const ele = document.createElement("a");
  ele.download = `${filename}.${fileSuffix}`;
  ele.style.display = "none";
  ele.href = url;
  document.body.appendChild(ele);
  ele.click();
  document.body.removeChild(ele);
};
const downloadTextFile = (content, filename = (/* @__PURE__ */ new Date()).getTime(), fileSuffix) => {
  const blob = new Blob([content]);
  downloadByA(URL.createObjectURL(blob), filename, fileSuffix);
};
export {
  downloadByA,
  downloadTextFile,
  readFile
};
