支持JPEG照片并保留原始尺寸

This commit is contained in:
2026-11-19 14:45:26 +08:00
parent 7520949b3b
commit 08f18b784f
5 changed files with 25 additions and 10 deletions
+1 -1
View File
@@ -337,7 +337,7 @@
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
<script src="/js/app.js?v=39"></script>
<script src="/js/app.js?v=40"></script>
</div>
</body>
</html>
+2 -2
View File
@@ -939,7 +939,7 @@
function centerUploadFields(prefix) {
return `<label>活动照片<input name="photos" type="file" accept="image/jpeg,image/png,image/webp" multiple /></label>
<p class="muted">可直接多选相册照片或拍照,每次最多${CENTER_PHOTO_BATCH_LIMIT}张(含ZIP内照片),每张不超过${CENTER_PHOTO_MAX_MB}MB。</p><div id="${prefix}-selected-photos" class="selected-photo-summary muted"></div>
<p class="muted">可直接多选相册照片或拍照,支持JPG、PNG、WebP并自动转为统一JPEG;每次最多${CENTER_PHOTO_BATCH_LIMIT}张(含ZIP内照片),每张不超过${CENTER_PHOTO_MAX_MB}MB。</p><div id="${prefix}-selected-photos" class="selected-photo-summary muted"></div>
<label>ZIP附件 <span class="hint-inline">(选填)</span><input name="materials" type="file" accept=".zip,application/zip" /></label>
<p class="muted">需要附PDF、Word、Excel等文档时再上传ZIP,最大${CENTER_ZIP_MAX_MB}MB,可不含照片。</p>`;
}
@@ -989,7 +989,7 @@
return async () => {
const files = [...form.photos.files], zip = form.materials.files[0];
if (files.length > CENTER_PHOTO_BATCH_LIMIT) throw new Error(`每次最多上传${CENTER_PHOTO_BATCH_LIMIT}张照片,请重新选择`);
if (files.some(file => file.size > CENTER_PHOTO_MAX_MB * MB || !(/\.(jpe?g|png|webp)$/i.test(file.name) || /^image\/(jpeg|png|webp)$/.test(file.type)))) throw new Error(`照片支持JPG、PNG、WebP,每张最大${CENTER_PHOTO_MAX_MB}MB`);
if (files.some(file => file.size > CENTER_PHOTO_MAX_MB * MB || !(/\.(jpe?g|jpg|jpeg|jpe|jfif|png|webp)$/i.test(file.name) || /^image\/(jpeg|jpg|jpe|jfif|pjpeg|png|webp)$/.test(file.type)))) throw new Error(`照片支持JPG、PNG、WebP,每张最大${CENTER_PHOTO_MAX_MB}MB`);
if (zip && (zip.size > CENTER_ZIP_MAX_MB * MB || !zip.name.toLowerCase().endsWith('.zip'))) throw new Error(`请提交${CENTER_ZIP_MAX_MB}MB以内的ZIP附件`);
if (files.length || zip) box.classList.remove('hidden');
for (let i = 0; i < files.length; i++) {