SOURCE

console 命令行工具 X clear

                    
>
console
document.getElementById("zipInput").addEventListener("change", handleFile);

function handleFile(event) {
  const file = event.target.files[0];
  const reader = new FileReader();

  reader.onload = function (e) {
    const base64String = e.target.result.split(",")[1]; // 获取 Base64 编码
    document.body.innerHTML =
      "Base64 编码:" + base64String.length + "\n" + base64String;
    // for (let i = 0; i < base64String.length; i += 1000) {
    //   console.log(base64String.split(0, i));
    // }

    // 触发下载 ZIP
    // createZipFromBase64(base64String, file.name);
  };

  reader.readAsDataURL(file); // 以 Base64 方式读取文件
}

// function createZipFromBase64(base64String, fileName) {
//     const zip = new JSZip();
//     zip.file(fileName, base64String, { base64: true });

//     zip.generateAsync({ type: "blob" }).then(function(content) {
//         const link = document.createElement("a");
//         link.href = URL.createObjectURL(content);
//         link.download = fileName;
//         link.click();
//     });
// }

// const base64=123
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="robots" content="noindex, nofollow" />
    <meta name="googlebot" content="noindex, nofollow" />
    <title>测试erxiaxia - JSRUN 驱动</title>

    <script type="text/javascript" src=""></script>
    <link rel="stylesheet" type="text/css" href="main.css" />
  </head>
  <body>
    <input type="text" id="zipInput" />
    <button style="display: none" onclick="convertAndDownload()">
      转换并下载
    </button>
    <script type="application/javascript" src="main.js"></script>
  </body>
</html>