feat: 增加 screen_id 参数以支持针对特定屏幕的工具执行,优化大屏控制逻辑

This commit is contained in:
Pine
2026-08-19 14:28:10 +08:00
parent e72442dae0
commit 3688d5d0b1
7 changed files with 52 additions and 42 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ import Icon from './Icons';
import ShowCard from './ShowCard';
import { getApiBase as API_BASE } from '../config';
import { Sfx } from '../utils/sounds';
import { getMqttStatus } from '../utils/mqtt';
import { getMqttStatus, getClientId } from '../utils/mqtt';
import { aiStatus } from '../utils/statusBus';
import { renderMarkdown } from '../voice/markdown.jsx';
@@ -161,7 +161,7 @@ export default function AiChatPanel() {
const res = await fetch(`${API_BASE()}/api/ai/chat`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ messages: history }),
body: JSON.stringify({ messages: history, screen_id: getClientId() }),
});
if (res.ok) {
data = await res.json();
+2 -1
View File
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { S2sWsRealtimeClient } from '../voice/s2s-ws-client.js';
import useVisionDetection, { VISION_DWELL_MS } from '../voice/useVisionDetection.js';
import { getApiBase as API_BASE, getVoiceWsUrl } from '../config';
import { getClientId } from '../utils/mqtt';
import { aiStatus } from '../utils/statusBus';
import '../styles/datascreen.css';
import './voice-original.css';
@@ -242,7 +243,7 @@ export default function VoiceAssistant() {
const res = await fetch(`${API_BASE()}/api/tools/exec`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, args }),
body: JSON.stringify({ name, args, screen_id: getClientId() }),
});
const data = await res.json();
output = data?.result ?? JSON.stringify(data);