diff --git a/gui/flask_server.py b/gui/flask_server.py index febc073..2e557eb 100644 --- a/gui/flask_server.py +++ b/gui/flask_server.py @@ -373,6 +373,43 @@ def api_get_run_status(): except Exception as e: return jsonify({'status': False, 'message': f'获取运行状态时出错: {e}'}), 500 +@__app.route('/api/get-system-status', methods=['get']) +def api_get_system_status(): + # 获���系统各组件连接状态 + try: + username = request.args.get('username') + server_status = True + + # 数字人状态 (HumanServer 10002) + # 检查指定用户是否连接了数字人端 + digital_human_status = False + try: + wsa_instance = wsa_server.get_instance() + if wsa_instance and username: + digital_human_status = wsa_instance.is_connected(username) + except Exception: + digital_human_status = False + + # 远程音频状态 (Socket 10001) + # 检查指定用户是否连接了远程音频 + remote_audio_status = False + try: + if username and hasattr(fay_booter, 'DeviceInputListenerDict'): + for listener in fay_booter.DeviceInputListenerDict.values(): + if listener.username == username: + remote_audio_status = True + break + except Exception: + remote_audio_status = False + + return jsonify({ + 'server': server_status, + 'digital_human': digital_human_status, + 'remote_audio': remote_audio_status + }) + except Exception as e: + return jsonify({'server': False, 'digital_human': False, 'remote_audio': False, 'error': str(e)}), 500 + @__app.route('/api/adopt-msg', methods=['POST']) def adopt_msg(): # 采纳消息 diff --git a/gui/static/css/index.css b/gui/static/css/index.css index ca133d2..c493e32 100644 --- a/gui/static/css/index.css +++ b/gui/static/css/index.css @@ -765,7 +765,31 @@ html { max-width: 150px; } -.prestart-content-inline .message-image-thumbnail { - max-width: 150px; - max-height: 100px; + +/* 状态指示器样式 */ +.status-indicators { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + display: flex; + flex-direction: column; + gap: 6px; + z-index: 100; +} + +.status-dot { + width: 8px; + height: 8px; + border-radius: 50%; + background-color: #ccc; /* 默认灰色 */ + cursor: pointer; + transition: all 0.3s; + border: 1px solid #fff; + box-shadow: 0 1px 2px rgba(0,0,0,0.1); +} + +.status-dot.connected { + background-color: #4CAF50; /* 绿色 */ + box-shadow: 0 0 4px #4CAF50; } \ No newline at end of file diff --git a/gui/static/js/index.js b/gui/static/js/index.js index 48411d4..d3fd161 100644 --- a/gui/static/js/index.js +++ b/gui/static/js/index.js @@ -326,6 +326,12 @@ new Vue({ isThinkPanelMinimized: false, mcpOnlineStatus: false, mcpCheckTimer: null, + systemStatus: { + server: false, + digital_human: false, + remote_audio: false + }, + systemStatusTimer: null, }; }, watch: { @@ -337,8 +343,51 @@ new Vue({ this.startUserListTimer(); this.checkMcpStatus(); this.startMcpStatusTimer(); + this.startSystemStatusTimer(); }, methods: { + // 检查系统各组件连接状态 + checkSystemStatus() { + let username = ''; + if (this.selectedUser && this.selectedUser.length > 1) { + username = this.selectedUser[1]; + } + + const statusUrl = `${this.base_url}/api/get-system-status?username=${encodeURIComponent(username)}`; + + fetch(statusUrl) + .then(response => response.json()) + .then(data => { + this.systemStatus = { + server: data.server, + digital_human: data.digital_human, + remote_audio: data.remote_audio + }; + }) + .catch(error => { + console.warn('获取系统状态失败:', error); + this.systemStatus = { + server: false, + digital_human: false, + remote_audio: false + }; + }); + }, + + // 启动系统状态检查定时器 + startSystemStatusTimer() { + // 立即执行一次 + this.checkSystemStatus(); + + if (this.systemStatusTimer) { + clearInterval(this.systemStatusTimer); + } + // 每3秒检查一次 + this.systemStatusTimer = setInterval(() => { + this.checkSystemStatus(); + }, 3000); + }, + initFayService() { const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; const wsHost = window.location.hostname; @@ -521,6 +570,10 @@ new Vue({ clearInterval(this.mcpCheckTimer); this.mcpCheckTimer = null; } + if (this.systemStatusTimer) { + clearInterval(this.systemStatusTimer); + this.systemStatusTimer = null; + } }, selectUser(user) { this.selectedUser = user; diff --git a/gui/templates/index.html b/gui/templates/index.html index 2584945..829633e 100644 --- a/gui/templates/index.html +++ b/gui/templates/index.html @@ -17,7 +17,12 @@
-