迁移聊天室滚屏状态入口

This commit is contained in:
2026-04-25 19:45:15 +08:00
parent 0ac12364bb
commit 62bd92c1c6
3 changed files with 57 additions and 3 deletions
@@ -49,6 +49,10 @@
let autoScroll = true;
// 给已迁移到 Vite 的模块只读判断自动滚动状态,避免直接依赖 Blade 脚本作用域。
window.isChatAutoScrollEnabled = () => autoScroll;
// 给 Vite 模块显式写回自动滚屏状态,避免模块和 Blade 闭包各自维护一份状态。
window.setChatAutoScrollEnabled = (enabled) => {
autoScroll = Boolean(enabled);
};
let userBadgeRotationTick = 0;
let userListRenderTimer = null;
let _maxMsgId = 0; // 记录当前收到的最大消息 ID
@@ -1757,7 +1761,7 @@
const autoScrollEl = document.getElementById('auto_scroll');
if (autoScrollEl) {
autoScrollEl.addEventListener('change', function() {
autoScroll = this.checked;
window.setChatAutoScrollEnabled(this.checked);
});
}
@@ -3648,6 +3652,14 @@
// ── 滚屏开关 ─────────────────────────────────────
function toggleAutoScroll() {
if (window.ChatRoomTools?.toggleAutoScroll) {
window.ChatRoomTools.toggleAutoScroll(
() => autoScroll,
(enabled) => window.setChatAutoScrollEnabled(enabled)
);
return;
}
autoScroll = !autoScroll;
const cb = document.getElementById('auto_scroll');
if (cb) cb.checked = autoScroll;