迁移聊天消息安全工具

This commit is contained in:
2026-04-25 19:27:39 +08:00
parent 891e18e83f
commit 4cdcaa537f
4 changed files with 125 additions and 63 deletions
+11 -3
View File
@@ -2,7 +2,7 @@
/**
* 模块引用说明:
* - html.js:提供聊天内容通用 HTML 转义工具。
* - html.js:提供聊天内容通用 HTML 转义和安全链接规整工具。
* - appointment-announcement.js:处理任命/撤销公告的大卡片和系统消息。
* - banner.js:提供 window.chatBanner 居中大卡片通知。
* - chat-bot.js:处理 AI 小班长发送消息和清空上下文。
@@ -54,10 +54,11 @@
* - reward-modal.js:处理职务奖励金币弹窗入口。
* - red-packet-panel.js:处理礼包红包发包、抢包、倒计时和广播监听。
* - message-queue.js:提供聊天消息分批渲染队列。
* - message-utils.js:提供图片消息过期等消息渲染辅助判断。
*/
// 统一转发各子模块导出,方便测试或后续模块继续复用同一组工具。
export { escapeHtml, escapeHtmlWithLineBreaks } from "./chat-room/html.js";
export { escapeHtml, escapeHtmlWithLineBreaks, normalizeSafeChatUrl } from "./chat-room/html.js";
export { bindAppointmentAnnouncementControls, showAppointmentBanner } from "./chat-room/appointment-announcement.js";
export { bindChatBanner } from "./chat-room/banner.js";
export { bindChatBotControls, clearChatBotContext, sendToChatBot } from "./chat-room/chat-bot.js";
@@ -241,8 +242,9 @@ export {
updateRedPacketClaimsUI,
} from "./chat-room/red-packet-panel.js";
export { createMessageQueue } from "./chat-room/message-queue.js";
export { isExpiredChatImageMessage } from "./chat-room/message-utils.js";
import { escapeHtml, escapeHtmlWithLineBreaks } from "./chat-room/html.js";
import { escapeHtml, escapeHtmlWithLineBreaks, normalizeSafeChatUrl } from "./chat-room/html.js";
import { bindAppointmentAnnouncementControls, showAppointmentBanner } from "./chat-room/appointment-announcement.js";
import { bindChatBanner } from "./chat-room/banner.js";
import { bindChatBotControls, clearChatBotContext, sendToChatBot } from "./chat-room/chat-bot.js";
@@ -426,12 +428,14 @@ import {
updateRedPacketClaimsUI,
} from "./chat-room/red-packet-panel.js";
import { createMessageQueue } from "./chat-room/message-queue.js";
import { isExpiredChatImageMessage } from "./chat-room/message-utils.js";
if (typeof window !== "undefined") {
// 保留聚合入口,给新迁移模块、测试和仍在 Blade 内的存量脚本统一读取工具。
window.ChatRoomTools = {
escapeHtml,
escapeHtmlWithLineBreaks,
normalizeSafeChatUrl,
bindAppointmentAnnouncementControls,
showAppointmentBanner,
bindChatBanner,
@@ -643,10 +647,14 @@ if (typeof window !== "undefined") {
showRedPacketModal,
updateRedPacketClaimsUI,
createMessageQueue,
isExpiredChatImageMessage,
};
// 直接挂载只服务暂未迁移的 Blade 调用点;新代码优先通过模块导入或 ChatRoomTools 复用。
window.closeChatImageLightbox = closeChatImageLightbox;
window.escapeHtml = escapeHtml;
window.isExpiredChatImageMessage = isExpiredChatImageMessage;
window.normalizeSafeChatUrl = normalizeSafeChatUrl;
window.openChatImageLightbox = openChatImageLightbox;
window.closeFriendPanel = closeFriendPanel;
window.friendSearch = friendSearch;