Feat: 实现全屏特效系统(烟花/下雨/雷电),管理员一键触发全房间广播

This commit is contained in:
2026-02-27 14:14:35 +08:00
parent adab033afc
commit 709e0d4975
47 changed files with 621 additions and 1751 deletions
@@ -614,6 +614,38 @@
// DOMContentLoaded 后启动,确保 Vite 编译的 JS 已加载
document.addEventListener('DOMContentLoaded', setupScreenClearedListener);
// ── 全屏特效事件监听(烟花/下雨/雷电)───────────────
window.addEventListener('chat:effect', (e) => {
const type = e.detail?.type;
if (type && typeof EffectManager !== 'undefined') {
EffectManager.play(type);
}
});
/**
* 管理员点击特效按钮,向后端 POST /command/effect
*
* @param {string} type 特效类型:fireworks / rain / lightning
*/
function triggerEffect(type) {
const roomId = window.chatContext?.roomId;
if (!roomId) return;
fetch('/command/effect', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content ?? '',
},
body: JSON.stringify({
room_id: roomId,
type
}),
}).then(r => r.json()).then(data => {
if (data.status !== 'success') alert(data.message);
}).catch(err => console.error('特效触发失败:', err));
}
window.triggerEffect = triggerEffect;
// ── 发送消息(Enter 发送) ───────────────────────
document.getElementById('content').addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {