diff --git a/web/static/js/chat.js b/web/static/js/chat.js index 5948a767..fecd64dd 100644 --- a/web/static/js/chat.js +++ b/web/static/js/chat.js @@ -4532,6 +4532,10 @@ async function loadConversation(conversationId) { // 更新当前对话ID currentConversationId = conversationId; window._loadedConversationProjectId = conversation.projectId || conversation.project_id || ''; + const conversationRoleName = conversation.roleName || conversation.role_name || ''; + if (typeof window.setCurrentRole === 'function') { + window.setCurrentRole(conversationRoleName || '默认'); + } try { window.currentConversationId = conversationId; } catch (e) { /* ignore */ } diff --git a/web/static/js/roles.js b/web/static/js/roles.js index 79f7af16..31ae16b3 100644 --- a/web/static/js/roles.js +++ b/web/static/js/roles.js @@ -1892,6 +1892,7 @@ function getCurrentRole() { // 暴露函数到全局作用域 if (typeof window !== 'undefined') { window.getCurrentRole = getCurrentRole; + window.setCurrentRole = handleRoleChange; window.toggleRoleSelectionPanel = toggleRoleSelectionPanel; window.closeRoleSelectionPanel = closeRoleSelectionPanel; window.closeRoleSelectModal = closeRoleSelectModal; @@ -1905,6 +1906,7 @@ if (typeof window !== 'undefined') { originalHandleRoleChange(roleName); if (typeof window !== 'undefined') { window.currentSelectedRole = getCurrentRole(); + window.setCurrentRole = handleRoleChange; } }; }