From 44c0383dc17513d7e1c65365c24ab48c05fc04ac Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 27 Jul 2026 10:44:12 +0800 Subject: [PATCH] fix: 6MB limit for preview images (client + server) --- static/js/pages/market.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/js/pages/market.js b/static/js/pages/market.js index 4d1b172..8d67ce1 100644 --- a/static/js/pages/market.js +++ b/static/js/pages/market.js @@ -231,7 +231,10 @@ const PageMarket = { if (this.checked) { const inp = document.createElement('input'); inp.type = 'file'; inp.accept = 'image/*'; inp.style.display = 'none'; inp.id = 'pub-preview-input'; - inp.onchange = function() { previewFile = this.files[0]; const el = document.getElementById('pub-preview-file'); if(el){el.textContent=previewFile?previewFile.name:'';el.style.display=previewFile?'':'none'} }; + inp.onchange = function() { + previewFile = this.files[0]; + if (previewFile && previewFile.size > 6291456) { Toast.show('预览图不能超过 6MB', 'error'); previewFile = null; this.value = ''; } + const el = document.getElementById('pub-preview-file'); if(el){el.textContent=previewFile?previewFile.name:'';el.style.display=previewFile?'':'none'} }; document.body.appendChild(inp); inp.click(); } else { previewFile=null; const o=document.getElementById('pub-preview-input');if(o)o.remove(); const el=document.getElementById('pub-preview-file');if(el)el.style.display='none' } });