const FeatureDetail = { id: null, async render(id) { this.id = id; return '
'; }, async mount() { const id = this.id; document.getElementById('page-title').textContent = `更新 #${id}`; document.getElementById('page-actions').innerHTML = ''; try { const item = await API.get('/features/'+id); this.renderDetail(item); } catch(e) { document.getElementById('page-content').innerHTML = `
${e.message}
`; } }, renderDetail(i) { const sc = i.status==='done'?'var(--s)':i.status==='planned'?'var(--p)':'var(--g5)'; const sl = i.status==='done'?'已完成':i.status==='planned'?'计划中':'待定'; const ct = document.getElementById('page-content'); ct.innerHTML = `
${i.status==='done'?'\u2713':i.status==='planned'?'\u25C9':'\u25CB'} ${U.esc(i.title)} ${sl} · ${i.votes_count||0} 票
${i.description?`

${U.esc(i.description)}

`:''} ${i.group_name?`${U.esc(i.group_name)}/${U.esc(i.server_name)}`:''} ${U.date(i.created_at)}
讨论 (${(i.comments||[]).length})
${(i.comments||[]).length===0?'

暂无讨论

':i.comments.map(c=>`
${U.esc(c.username||'用户')} ${c.role ? U.badge(c.role,'role') : ''} ${U.date(c.created_at)}
${U.esc(c.content)}
`).join('')}
`; document.getElementById('feat-detail-vote').onclick = async () => { try { await API.post(`/features/${id}/vote`); this.mount(); } catch(ex){alert(ex.message);} }; document.getElementById('feat-comment-form').onsubmit = async e => { e.preventDefault(); const inp = document.getElementById('feat-comment-input'); try { await API.post(`/features/${id}/comment`, {content:inp.value}); inp.value=''; this.mount(); } catch(ex){alert(ex.message);} }; } };