修复:重写本地清屏逻辑,使用 localStorage 记录拉取游标,避免进房带历史功能导致清屏失效
This commit is contained in:
@@ -108,11 +108,16 @@
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const historyMsgs = @json($historyMessages);
|
||||
const clearId = parseInt(localStorage.getItem(`local_clear_msg_id_{{ $room->id }}`) || '0', 10);
|
||||
|
||||
if (historyMsgs && historyMsgs.length > 0) {
|
||||
// 全局函数 appendMessage 在 scripts.blade.php 中定义
|
||||
historyMsgs.forEach(msg => {
|
||||
if (typeof window.appendMessage === 'function') {
|
||||
window.appendMessage(msg);
|
||||
// 如果开启了本地清屏,之前的历史记录不再显示
|
||||
if (msg.id > clearId) {
|
||||
if (typeof window.appendMessage === 'function') {
|
||||
window.appendMessage(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user