handle zip files

This commit is contained in:
JovannMC 2025-01-13 06:19:04 +03:00
parent 5314629b45
commit d359d8e0c0
No known key found for this signature in database
2 changed files with 14 additions and 4 deletions

View File

@ -48,9 +48,7 @@ export class VipsConverter extends Converter {
} else if (message.type === "error") {
error(["converters", this.name], `error in worker: ${message.error}`);
throw new Error(message.error);
} else {
error(["converters", this.name], `unknown message type ${message.type}`);
}
}
};
}

View File

@ -153,9 +153,21 @@ class Files {
const { downloadZip } = await import("client-zip");
const blob = await downloadZip(dlFiles, "converted.zip").blob();
const url = URL.createObjectURL(blob);
const filenameFormat =
localStorage.getItem("filenameFormat") ?? "VERT_%name%";
const format = (name: string) => {
const date = new Date().toISOString();
return name
.replace(/%date%/g, date)
.replace(/%name%/g, 'Multi')
.replace(/%extension%/g, '');
};
const a = document.createElement("a");
a.href = url;
a.download = `VERT-Converted_${new Date().toISOString()}.zip`;
a.download = `${format(filenameFormat)}.zip`;
a.click();
URL.revokeObjectURL(url);
a.remove();