clodes / frontend /index.html
nimzuk's picture
CI: sync from GitHub
c7bb297 verified
Raw
History Blame Contribute Delete
2.18 kB
<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>Clodesigner (restored)</title>
<style>body{background:#0d1117;color:#c9d1d9;font-family:system-ui;padding:24px}img{max-width:100%}.row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}</style>
</head><body>
<h2>Clodesigner (restored)</h2>
<div class="row">
<input id="file" type="file" accept="image/*"/>
<select id="model"><option>MT</option><option>WT</option><option>KT</option></select>
<select id="view"><option>front</option><option>back</option><option>sleeveL</option><option>sleeveR</option></select>
<button id="btnPrev">Preview</button><button id="btnOrder">Order</button>
</div>
<div class="row" style="margin-top:16px">
<div style="flex:1;min-width:300px"><h3>Preview</h3><img id="prev"/></div>
<div style="flex:1;min-width:300px"><h3>Order</h3><pre id="out" style="background:#161b22;padding:12px;border-radius:8px"></pre></div>
</div>
<script>
let uploaded=null;
document.getElementById('file').addEventListener('change', async (e)=>{
const f=e.target.files[0]; if(!f) return;
const fd=new FormData(); fd.append('file',f);
const r=await fetch('/api/upload',{method:'POST',body:fd}); uploaded=await r.json();
});
document.getElementById('btnPrev').onclick=async ()=>{
if(!uploaded) return alert('Upload first');
const model=document.getElementById('model').value, view=document.getElementById('view').value;
const r=await fetch('/api/preview',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({model,view,src:uploaded.path})});
const j=await r.json(); document.getElementById('prev').src=j.url||'';
};
document.getElementById('btnOrder').onclick=async ()=>{
if(!uploaded) return alert('Upload first');
const model=document.getElementById('model').value, view=document.getElementById('view').value;
const r=await fetch('/api/order',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({model,view,src:uploaded.path,details:{}})});
const j=await r.json(); document.getElementById('out').textContent=JSON.stringify(j,null,2);
};
</script></body></html>