fix(website): Clear file input after selection to prevent re-selection issues

This commit is contained in:
Kazuki Yamada
2025-06-08 13:53:25 +09:00
parent 8694df19aa
commit 25a208b81d
2 changed files with 20 additions and 7 deletions

View File

@@ -99,6 +99,10 @@ export function useFileUpload(config: FileUploadConfig) {
function clearSelection() {
selectedItem.value = null;
errorMessage.value = null;
// Clear file input to prevent re-selection issues
if (fileInput.value) {
fileInput.value.value = '';
}
}
// Validate and process files
@@ -139,6 +143,11 @@ export function useFileUpload(config: FileUploadConfig) {
// Update selection
selectedItem.value = folderName || resultFile.name;
// Clear file input to prevent re-selection issues
if (fileInput.value) {
fileInput.value.value = '';
}
return { success: true, result: resultFile };
} catch (error) {
const errorMsg = error instanceof Error ? error.message : 'Processing failed';

View File

@@ -2,15 +2,19 @@ import JSZip from 'jszip';
export function useZipProcessor() {
async function createZipFromFiles(files: File[], folderName: string): Promise<File> {
const zip = new JSZip();
try {
const zip = new JSZip();
for (const file of files) {
const path = file.webkitRelativePath || file.name;
zip.file(path, file);
for (const file of files) {
const path = file.webkitRelativePath || file.name;
zip.file(path, file);
}
const zipBlob = await zip.generateAsync({ type: 'blob' });
return new File([zipBlob], `${folderName}.zip`, { type: 'application/zip' });
} catch (error) {
throw new Error(`Failed to create ZIP file: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
const zipBlob = await zip.generateAsync({ type: 'blob' });
return new File([zipBlob], `${folderName}.zip`, { type: 'application/zip' });
}
function validateZipFile(file: File): { valid: boolean; error?: string } {