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' } });