重构:将聊天室所有原生弹窗替换为全局弹窗,公告增加发送者与时间

- 将设公告、公屏讲话、全员清屏按钮弹窗改为使用 window.chatDialog 全局弹窗
- 所有弹窗改用 .then() 回调注册事件,避免 async/await 行为不一致问题
- 公告内容末尾追加「——发送者 MM-dd HH:mm」,无需新增数据库字段
- 前端编辑公告时自动剥离末尾元信息,用户仅编辑纯内容
- 修复 red-packet-panel.blade.php 中 3 处原生 alert() 残留
- 修复 shop-panel.blade.php 中购买确认 confirm() 原生弹窗残留
This commit is contained in:
2026-03-12 07:33:32 +08:00
parent f1062b34d2
commit b9c703b755
4 changed files with 93 additions and 79 deletions
@@ -416,11 +416,13 @@
// 【前置拦截1】如果有时间戳并算出已过期,直接杀死不弹窗
if (sentAtUnix && Date.now() >= calculatedExpireAt) {
if (typeof window.chatToast === 'function') {
window.chatToast('该红包已过期', 'info');
} else {
alert('该红包已过期。');
}
window.chatToast?.show({
title: '⏰ 礼包已过期',
message: '该红包已过期,无法领取。',
icon: '⏰',
color: '#9ca3af',
duration: 4000,
});
console.log('红包已准确断定过期,拦截弹窗显示:', envelopeId);
return;
}
@@ -499,7 +501,7 @@
const modalEl = document.getElementById('red-packet-modal');
if (!modalEl) {
alert('致命错误:红包视图容器 #red-packet-modal 找不到!');
window.chatDialog?.alert('致命错误:红包视图容器 #red-packet-modal 找不到!', '系统错误', '#cc4444');
return;
}
@@ -543,7 +545,7 @@
}
} catch (err) {
console.error('showRedPacketModal 执行失败:', err);
alert('红包弹窗初始化异常: ' + err.message);
window.chatDialog?.alert('红包弹窗初始化异常: ' + err.message, '系统错误', '#cc4444');
}
// 启动倒计时