forked from datawhale/whale-town-front
feat(chat): 优化聊天UI布局和WebSocket连接
- 更新 WebSocket URL 以支持 Socket.IO 握手参数 (EIO=4) - 重构聊天面板布局,使用绝对定位和百分比锚点 - 优化输入框样式,添加装饰元素 - 修复输入框焦点释放的事件冲突问题 - 将 ChatUI 集成到主场景中 - 改进主场景容器布局设置
This commit is contained in:
@@ -28,7 +28,7 @@ extends Control
|
||||
# ============================================================================
|
||||
|
||||
# 聊天面板
|
||||
@onready var chat_panel: Panel = %ChatPanel
|
||||
@onready var chat_panel: Control = %ChatPanel
|
||||
|
||||
# 聊天历史容器
|
||||
@onready var chat_history: ScrollContainer = %ChatHistory
|
||||
@@ -134,11 +134,16 @@ func _gui_input(event: InputEvent) -> void:
|
||||
func _handle_click_outside() -> void:
|
||||
# 检查点击是否在聊天面板外部
|
||||
if not chat_panel.get_global_rect().has_point(get_global_mouse_position()):
|
||||
# 释放输入框焦点(取消输入状态)
|
||||
# 延迟释放输入框焦点,避免事件冲突
|
||||
if chat_input.has_focus():
|
||||
chat_input.release_focus()
|
||||
call_deferred("_release_input_focus")
|
||||
print("🖱️ 点击外部,取消输入状态")
|
||||
|
||||
# 延迟释放输入框焦点(由 call_deferred 调用)
|
||||
func _release_input_focus() -> void:
|
||||
if chat_input and chat_input.has_focus():
|
||||
chat_input.release_focus()
|
||||
|
||||
# ============================================================================
|
||||
# 显示/隐藏逻辑
|
||||
# ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user