Commit 9fe8a7e8 authored by fisherdaddy's avatar fisherdaddy

chore: fix some bugs in ImageCompressor

parent e47b8caf
...@@ -468,9 +468,10 @@ function ImageCompressor() { ...@@ -468,9 +468,10 @@ function ImageCompressor() {
const handleCompress = async () => { const handleCompress = async () => {
if (images.length === 0) return; if (images.length === 0) return;
// 清除之前的压缩结果,允许重新压缩
setCompressedImages([]);
for (const image of images) { for (const image of images) {
if (compressedImages.find(img => img.id === image.id)) continue;
setProcessing(prev => ({ ...prev, [image.id]: 0 })); setProcessing(prev => ({ ...prev, [image.id]: 0 }));
try { try {
...@@ -488,7 +489,8 @@ function ImageCompressor() { ...@@ -488,7 +489,8 @@ function ImageCompressor() {
preview: URL.createObjectURL(compressedFile), preview: URL.createObjectURL(compressedFile),
size: compressedFile.size, size: compressedFile.size,
name: compressedFile.name, name: compressedFile.name,
originalSize: image.size originalSize: image.size,
compressionSettings: { ...settings } // 保存压缩时使用的设置
}; };
setCompressedImages(prev => [...prev, compressedImage]); setCompressedImages(prev => [...prev, compressedImage]);
...@@ -638,7 +640,10 @@ function ImageCompressor() { ...@@ -638,7 +640,10 @@ function ImageCompressor() {
> >
{Object.keys(processing).length > 0 ? {Object.keys(processing).length > 0 ?
t('tools.imageCompressor.compressing') : t('tools.imageCompressor.compressing') :
t('tools.imageCompressor.compress')} compressedImages.length > 0 ?
t('tools.imageCompressor.recompress') :
t('tools.imageCompressor.compress')
}
</Button> </Button>
{compressedImages.length > 0 && ( {compressedImages.length > 0 && (
......
...@@ -136,25 +136,27 @@ ...@@ -136,25 +136,27 @@
} }
}, },
"imageCompressor": { "imageCompressor": {
"title": "Image Compressor", "title": "Image Compression",
"description": "Compress images online, supports batch processing", "description": "Online image compression, supports batch processing",
"dropzoneText": "Click or drag images here (multiple selection supported)", "dropzoneText": "Click or drag images here (multiple selection supported)",
"quality": "Compression Quality", "quality": "Compression Quality",
"maxSize": "Max File Size", "maxSize": "Max File Size",
"compress": "Start Compression", "compress": "Start Compression",
"compressing": "Compressing...", "compressing": "Compressing...",
"download": "Download Compressed Image", "download": "Download Compressed Image",
"original": "Original Image", "original": "Original",
"compressed": "Compressed Image", "compressed": "Compressed",
"originalSize": "Original Size", "originalSize": "Original Size",
"compressedSize": "Compressed Size", "compressedSize": "Compressed Size",
"savedSpace": "Space Saved", "savedSpace": "Space Saved",
"filename": "Filename", "filename": "Filename",
"qualityTooltip": "Set the compression quality. Higher values give better image quality but larger file size.", "qualityTooltip": "Set the compression quality; higher values result in better image quality but larger file sizes",
"maxSizeTooltip": "Set the maximum file size after compression. If exceeded, the compression parameters will be adjusted automatically.", "maxSizeTooltip": "Set the maximum size for compressed files; parameters will adjust automatically if exceeded",
"downloadAll": "Download All", "downloadAll": "Download All",
"clearAll": "Clear All", "clearAll": "Clear All",
"maxImagesError": "You can upload up to 10 images", "maxImagesError": "You can upload up to 10 images only",
"maxImagesHint": "Up to 10 images can be uploaded" "maxImagesHint": "You can upload a maximum of 10 images",
"recompress": "Recompress",
"compressionSettings": "Compression Settings"
} }
} }
\ No newline at end of file
...@@ -137,24 +137,26 @@ ...@@ -137,24 +137,26 @@
}, },
"imageCompressor": { "imageCompressor": {
"title": "画像圧縮", "title": "画像圧縮",
"description": "オンラインで画像を圧縮、バッチ処理対応", "description": "オンライン画像圧縮、バッチ処理に対応",
"dropzoneText": "ここに画像をクリックまたはドラッグ(複数選択対応)", "dropzoneText": "クリックまたは画像をここにドラッグ(複数選択可)",
"quality": "圧縮品質", "quality": "圧縮品質",
"maxSize": "最大ファイルサイズ", "maxSize": "最大ファイルサイズ",
"compress": "圧縮開始", "compress": "圧縮開始",
"compressing": "圧縮中...", "compressing": "圧縮中...",
"download": "圧縮後の画像をダウンロード", "download": "圧縮後の画像をダウンロード",
"original": "元画像", "original": "元画像",
"compressed": "圧縮された画像", "compressed": "圧縮済み",
"originalSize": "元のサイズ", "originalSize": "元のサイズ",
"compressedSize": "圧縮後のサイズ", "compressedSize": "圧縮後のサイズ",
"savedSpace": "節約たスペース", "savedSpace": "節約されたスペース",
"filename": "ファイル名", "filename": "ファイル名",
"qualityTooltip": "圧縮品質を設定します。数値が高いほど画像品質が良くなりますが、ファイルサイズも大きくなります。", "qualityTooltip": "圧縮品質を設定します。値が高いほど画質が良くなり、ファイルサイズも大きくなります",
"maxSizeTooltip": "圧縮後の最大ファイルサイズを設定します。このサイズを超えると、圧縮パラメータが自動調整されます。", "maxSizeTooltip": "圧縮後の最大ファイルサイズを設定します。このサイズを超える場合、自動的に調整されます",
"downloadAll": "すべてダウンロード", "downloadAll": "すべてダウンロード",
"clearAll": "すべてクリア", "clearAll": "すべてクリア",
"maxImagesError": "最大10枚の画像をアップロードできます", "maxImagesError": "最大10枚まで画像をアップロードできます",
"maxImagesHint": "最大10枚の画像がアップロード可能です" "maxImagesHint": "最大10枚の画像をアップロードできます",
"recompress": "再圧縮",
"compressionSettings": "圧縮設定"
} }
} }
\ No newline at end of file
...@@ -138,24 +138,26 @@ ...@@ -138,24 +138,26 @@
}, },
"imageCompressor": { "imageCompressor": {
"title": "이미지 압축", "title": "이미지 압축",
"description": "온라인으로 이미지 압축, 일괄 처리 지원", "description": "온라인 이미지 압축, 일괄 처리를 지원합니다",
"dropzoneText": "여기에 이미지를 클릭하거나 드래그하세요 (다중 선택 지원)", "dropzoneText": "클릭하거나 이미지를 여기에 드래그하세요 (다중 선택 가능)",
"quality": "압축 품질", "quality": "압축 품질",
"maxSize": "최대 파일 크기", "maxSize": "최대 파일 크기",
"compress": "압축 시작", "compress": "압축 시작",
"compressing": "압축 중...", "compressing": "압축 중...",
"download": "압축된 이미지 다운로드", "download": "압축된 이미지 다운로드",
"original": "원본 이미지", "original": "원본",
"compressed": "압축된 이미지", "compressed": "압축",
"originalSize": "원본 크기", "originalSize": "원본 크기",
"compressedSize": "압축 후 크기", "compressedSize": "압축 후 크기",
"savedSpace": "절약된 공간", "savedSpace": "절약된 공간",
"filename": "파일명", "filename": "파일명",
"qualityTooltip": "압축 품질을 설정합니다. 값이 높을수록 이미지 품질이 좋아지지만, 파일 크기가 커집니다.", "qualityTooltip": "압축 품질을 설정합니다. 값이 높을수록 품질이 좋아지지만 파일 크기도 커집니다",
"maxSizeTooltip": "압축 후 최대 파일 크기를 설정합니다. 이 크기를 초과하면 자동으로 압축 매개변수가 조정됩니다.", "maxSizeTooltip": "압축 후 최대 파일 크기를 설정합니다. 이 크기를 초과하면 자동으로 조정됩니다",
"downloadAll": "전체 다운로드", "downloadAll": "모두 다운로드",
"clearAll": "모두 삭제", "clearAll": "모두 지우기",
"maxImagesError": "최대 10개의 이미지를 업로드할 수 있습니다", "maxImagesError": "최대 10개의 이미지만 업로드할 수 있습니다",
"maxImagesHint": "최대 10개의 이미지를 업로드할 수 있습니다" "maxImagesHint": "최대 10개의 이미지를 업로드할 수 있습니다",
"recompress": "재압축",
"compressionSettings": "압축 설정"
} }
} }
\ No newline at end of file
...@@ -154,6 +154,8 @@ ...@@ -154,6 +154,8 @@
"downloadAll": "下载全部", "downloadAll": "下载全部",
"clearAll": "清除全部", "clearAll": "清除全部",
"maxImagesError": "最多只能上传 10 张图片", "maxImagesError": "最多只能上传 10 张图片",
"maxImagesHint": "最多可上传 10 张图片" "maxImagesHint": "最多可上传 10 张图片",
"recompress": "重新压缩",
"compressionSettings": "压缩设置"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment