diff --git a/resources/views/chat/partials/scripts.blade.php b/resources/views/chat/partials/scripts.blade.php index be5f244..174d6e0 100644 --- a/resources/views/chat/partials/scripts.blade.php +++ b/resources/views/chat/partials/scripts.blade.php @@ -777,13 +777,20 @@ container2.querySelectorAll('[data-autosave="1"]').forEach(el => el.remove()); } container2.appendChild(div); - if (autoScroll) container2.scrollTop = container2.scrollHeight; + if (autoScroll) { + container2.scrollTop = container2.scrollHeight; + } } else { container.appendChild(div); scrollToBottom(); } } + /** + * 将消息追加函数暴露到全局,供页面首次加载时回填历史消息使用。 + */ + window.appendMessage = appendMessage; + // ── WebSocket 初始化 ───────────────────────────── document.addEventListener('DOMContentLoaded', () => { if (typeof window.initChat === 'function') {