迁移聊天室滚屏状态入口
This commit is contained in:
@@ -249,7 +249,7 @@ export {
|
||||
updateRedPacketClaimsUI,
|
||||
} from "./chat-room/red-packet-panel.js";
|
||||
export { createMessageQueue } from "./chat-room/message-queue.js";
|
||||
export { isExpiredChatImageMessage, localClearScreen } from "./chat-room/message-utils.js";
|
||||
export { isExpiredChatImageMessage, localClearScreen, syncAutoScrollControls, toggleAutoScroll } from "./chat-room/message-utils.js";
|
||||
|
||||
import { escapeHtml, escapeHtmlWithLineBreaks, normalizeSafeChatUrl } from "./chat-room/html.js";
|
||||
import { bindAppointmentAnnouncementControls, showAppointmentBanner } from "./chat-room/appointment-announcement.js";
|
||||
@@ -442,7 +442,7 @@ import {
|
||||
updateRedPacketClaimsUI,
|
||||
} from "./chat-room/red-packet-panel.js";
|
||||
import { createMessageQueue } from "./chat-room/message-queue.js";
|
||||
import { isExpiredChatImageMessage, localClearScreen } from "./chat-room/message-utils.js";
|
||||
import { isExpiredChatImageMessage, localClearScreen, syncAutoScrollControls, toggleAutoScroll } from "./chat-room/message-utils.js";
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
// 保留聚合入口,给新迁移模块、测试和仍在 Blade 内的存量脚本统一读取工具。
|
||||
@@ -670,6 +670,8 @@ if (typeof window !== "undefined") {
|
||||
createMessageQueue,
|
||||
isExpiredChatImageMessage,
|
||||
localClearScreen,
|
||||
syncAutoScrollControls,
|
||||
toggleAutoScroll,
|
||||
};
|
||||
|
||||
// 直接挂载只服务暂未迁移的 Blade 调用点;新代码优先通过模块导入或 ChatRoomTools 复用。
|
||||
@@ -678,6 +680,7 @@ if (typeof window !== "undefined") {
|
||||
window.isExpiredChatImageMessage = isExpiredChatImageMessage;
|
||||
window.localClearScreen = localClearScreen;
|
||||
window.normalizeSafeChatUrl = normalizeSafeChatUrl;
|
||||
window.syncAutoScrollControls = syncAutoScrollControls;
|
||||
window.openChatImageLightbox = openChatImageLightbox;
|
||||
window.closeFriendPanel = closeFriendPanel;
|
||||
window.friendSearch = friendSearch;
|
||||
|
||||
@@ -78,3 +78,42 @@ export function localClearScreen(roomId = window.chatContext?.roomId, maxMessage
|
||||
publicPane.scrollTop = publicPane.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步自动滚屏复选框与状态文字。
|
||||
*
|
||||
* @param {boolean} enabled 是否开启自动滚屏
|
||||
* @returns {void}
|
||||
*/
|
||||
export function syncAutoScrollControls(enabled) {
|
||||
const checkbox = document.getElementById("auto_scroll");
|
||||
const status = document.getElementById("scroll-status");
|
||||
|
||||
if (checkbox) {
|
||||
checkbox.checked = enabled;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
status.textContent = enabled ? "开" : "关";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换自动滚屏状态。
|
||||
* 真实状态仍由 Blade 大脚本闭包保存,这里通过 getter/setter 桥接,避免 Vite 模块持有第二份状态。
|
||||
*
|
||||
* @param {() => boolean} getCurrent 读取当前状态
|
||||
* @param {(enabled:boolean) => void} setCurrent 写回当前状态
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function toggleAutoScroll(getCurrent, setCurrent) {
|
||||
const nextEnabled = !Boolean(typeof getCurrent === "function" ? getCurrent() : true);
|
||||
|
||||
if (typeof setCurrent === "function") {
|
||||
setCurrent(nextEnabled);
|
||||
}
|
||||
|
||||
syncAutoScrollControls(nextEnabled);
|
||||
|
||||
return nextEnabled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user