迁移聊天室滚屏状态入口
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user