// 直播投流源管理 const LiveStreamManager = { // 初始化 init: function() { this.loadLiveStreams(); }, // 加载直播投流源 loadLiveStreams: function() { LiveStreamAPI.getActiveLiveStreams() .then(data => { if (data && data.length > 0) { this.renderLiveStreams(data); $('#livestreamSection').show(); } else { $('#livestreamSection').hide(); } }) .catch(error => { console.error('加载直播投流源失败:', error); $('#livestreamSection').hide(); }); }, // 渲染直播投流源列表 renderLiveStreams: function(streams) { const grid = $('#livestreamGrid'); grid.empty(); streams.forEach(stream => { const card = this.createStreamCard(stream); grid.append(card); }); }, // 创建直播卡片 createStreamCard: function(stream) { const platformColors = { '抖音': '#000', '快手': '#ff6600', '淘宝': '#ff4400', '京东': '#e60012', '小红书': '#ff2442', '视频号': '#07c160' }; const platformColor = platformColors[stream.platform] || '#666'; const isLive = !!stream.stream_url; // 判断是否有直播源 const card = $('
'); // 如果未开播,添加未开播样式类 if (!isLive) { card.addClass('not-live'); } // 封面图片 if (stream.cover_image) { card.append(`${stream.description || (isLive ? '欢迎来到直播间' : '主播暂时不在,敬请期待')}