// Showcase platform JavaScript const MEDIA_LABELS = { music: '🎡 音乐', mtv: '🎬 MTV', short_video: 'πŸ“± ηŸ­θ§†ι’‘', long_video: '🎞️ 长视钑', ktv: '🎀 KTV' }; const MEDIA_ICONS = { music: '🎡', mtv: '🎬', short_video: 'πŸ“±', long_video: '🎞️', ktv: '🎀' }; let currentFilter = ''; async function loadFeed(mediaType) { currentFilter = mediaType || ''; const container = document.getElementById('showcase_feed_grid'); if (!container) return; const url = `${MODULE_PREFIX}/api/showcase_feed.dspy?media_type=${currentFilter}&page=1&page_size=30`; try { const resp = await fetch(url); const result = await resp.json(); if (result.status !== 'ok' || !result.data) { container.innerHTML = '
ζš‚ζ— δ½œε“
'; return; } renderFeedCards(container, result.data); } catch (e) { container.innerHTML = '
加载倱θ΄₯
'; } } function renderFeedCards(container, posts) { if (!posts.length) { container.innerHTML = '
ζš‚ζ— δ½œε“
'; return; } container.innerHTML = posts.map(p => `
${p.thumbnail_url ? `` : MEDIA_ICONS[p.media_type] || 'πŸ“„'}
${MEDIA_LABELS[p.media_type] || p.media_type}
${escHtml(p.title)}
❀ ${p.like_count || 0} πŸ’¬ ${p.comment_count || 0} πŸ‘ ${p.view_count || 0} ${parseFloat(p.price) > 0 ? `πŸ’° Β₯${p.price}` : ''}
`).join(''); } function openDetail(postId) { window.location.href = `${MODULE_PREFIX}/detail.ui?post_id=${postId}`; } function escHtml(s) { if (!s) return ''; return s.replace(/&/g,'&').replace(//g,'>'); } // Register filterByType function if (typeof registerFunction !== 'undefined') { registerFunction('filterByType', function(opts) { loadFeed(opts.type); }); } // Auto-load on page ready document.addEventListener('DOMContentLoaded', function() { if (document.getElementById('showcase_feed_grid')) { loadFeed(''); } });