feat: download certificate archive

This commit is contained in:
Fu Diwei
2025-01-18 07:07:50 +08:00
parent d28b89f03e
commit d5e4ea385d
16 changed files with 265 additions and 139 deletions

View File

@@ -1,5 +1,3 @@
import JSZip from "jszip";
export function readFileContent(file: File): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@@ -17,19 +15,3 @@ export function readFileContent(file: File): Promise<string> {
reader.readAsText(file, "utf-8");
});
}
export const saveFiles2Zip = async (zipName: string, files: { name: string; content: string }[]) => {
const zip = new JSZip();
files.forEach((file) => {
zip.file(file.name, file.content);
});
const content = await zip.generateAsync({ type: "blob" });
// Save the zip file to the local system
const link = document.createElement("a");
link.href = URL.createObjectURL(content);
link.download = zipName;
link.click();
};