迁移聊天室本地清屏入口
This commit is contained in:
@@ -38,3 +38,43 @@ export function isExpiredChatImageMessage(
|
||||
|
||||
return nowTimestamp >= sentAt.getTime() + retentionDays * 24 * 60 * 60 * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* 只清理当前浏览器的聊天窗口,并记录本地清屏的最大消息 ID。
|
||||
*
|
||||
* @param {number|string} roomId 房间 ID
|
||||
* @param {number|string} maxMessageId 当前已接收最大消息 ID
|
||||
* @returns {void}
|
||||
*/
|
||||
export function localClearScreen(roomId = window.chatContext?.roomId, maxMessageId = 0) {
|
||||
const publicPane = document.getElementById("chat-messages-container");
|
||||
const privatePane = document.getElementById("chat-messages-container2");
|
||||
|
||||
if (publicPane) {
|
||||
publicPane.innerHTML = "";
|
||||
}
|
||||
|
||||
if (privatePane) {
|
||||
privatePane.innerHTML = "";
|
||||
}
|
||||
|
||||
// 刷新页面时只恢复本地清屏点之后的新消息,避免旧消息重新回流。
|
||||
localStorage.setItem(`local_clear_msg_id_${roomId}`, maxMessageId);
|
||||
|
||||
const notice = document.createElement("div");
|
||||
notice.className = "msg-line";
|
||||
|
||||
const now = new Date();
|
||||
const timeText = [
|
||||
now.getHours().toString().padStart(2, "0"),
|
||||
now.getMinutes().toString().padStart(2, "0"),
|
||||
now.getSeconds().toString().padStart(2, "0"),
|
||||
].join(":");
|
||||
|
||||
notice.innerHTML = `<span style="color: #64748b; font-weight: bold;">🧹 您已执行本地清屏</span><span class="msg-time">(${timeText})</span>`;
|
||||
|
||||
if (publicPane) {
|
||||
publicPane.appendChild(notice);
|
||||
publicPane.scrollTop = publicPane.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,6 +296,20 @@ export function toggleBlockMenu(event = null, beforeToggle = undefined) {
|
||||
menu.style.display = menu.style.display === "none" ? "block" : "none";
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行功能菜单里的本地清屏动作,并在执行前关闭菜单。
|
||||
*
|
||||
* @param {() => void} onLocalClear 本地清屏回调
|
||||
* @returns {void}
|
||||
*/
|
||||
export function handleFeatureLocalClear(onLocalClear) {
|
||||
closeFeatureMenu();
|
||||
|
||||
if (typeof onLocalClear === "function") {
|
||||
onLocalClear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定功能菜单、每日状态编辑与系统播报屏蔽的统一事件代理。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user