diff --git a/static/js/pages/market.js b/static/js/pages/market.js
index dba511c..4d1b172 100644
--- a/static/js/pages/market.js
+++ b/static/js/pages/market.js
@@ -222,15 +222,27 @@ const PageMarket = {
_upload() {
if (!this._marketToken) { Toast.show('请先登录', 'error'); return; }
const overlay = document.createElement('div'); overlay.className = 'modal-overlay';
- overlay.innerHTML = '
发布作品
选择要发布的仪表盘或场景
— 或从本地选择 —
加载中...
';
+ overlay.innerHTML = '发布作品
选择要发布的仪表盘或场景
— 或从本地选择 —
加载中...
';
document.body.appendChild(overlay);
overlay.addEventListener('click', (e) => { if (e.target === overlay) overlay.remove(); });
+
+ let previewFile = null;
+ overlay.querySelector('#pub-preview-toggle').addEventListener('change', function() {
+ 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'} };
+ 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' }
+ });
+
overlay.querySelector('#pub-file-btn').addEventListener('click', () => {
const input = document.createElement('input'); input.type = 'file'; input.accept = '.tsd,.tss';
input.onchange = async (e) => {
const file = e.target.files[0]; if (!file) return;
const isTss = file.name.endsWith('.tss');
const fd = new FormData(); fd.append('file', file); fd.append('token', this._marketToken);
+ if (previewFile) fd.append('preview', previewFile);
const res = await fetch(isTss ? '/api/market/scenes/upload' : '/api/market/upload', { method: 'POST', body: fd });
const data = await res.json();
Toast.show(data.error ? '失败: '+data.error : '发布成功', data.error ? 'error' : 'success');