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
+9 -6
View File
@@ -193,7 +193,7 @@
if (btn.id === 'mqttAiSend') {
var text = (document.getElementById('mqttAiInput').value || '').trim();
if (!text) { toast('请输入问题', 'error'); return; }
post('/api/display/command', { action: 'ai_input', params: { text: text } }, function () {
post('/api/display/command', { action: 'ai_input', params: { text: text }, screen_id: screenId, screen_role: screenRole }, function () {
toast('已发送问题到大屏 AI 页');
});
return;
@@ -203,17 +203,20 @@
if (btn.id === 'mqttAlertSend') {
var alertText = (document.getElementById('mqttAlertText').value || '').trim();
if (!alertText) { toast('请输入通知内容', 'error'); return; }
post('/api/display/command', { action: 'alert', params: { text: alertText } }, function () {
toast('通知已广播');
post('/api/display/command', { action: 'alert', params: { text: alertText }, screen_id: screenId, screen_role: screenRole }, function () {
toast('通知已发送');
});
return;
}
// 页面切换
// 页面切换(绑定目标屏幕:screen_id 精确某台;空=全部)
if (btn.hasAttribute('data-nav')) {
var page = btn.getAttribute('data-nav');
post('/api/display/command', { action: 'navigate', params: { page: page } }, function () {
toast('已切换大屏至「' + btn.textContent.trim() + '');
var tgtTxt = screenId
? (screenRole === 'main' ? '主屏' : screenRole === 'secondary' ? '副屏' : '屏幕') + '·' + String(screenId).slice(0, 10)
: '全部';
post('/api/display/command', { action: 'navigate', params: { page: page }, screen_id: screenId, screen_role: screenRole }, function () {
toast('已切换大屏至「' + btn.textContent.trim() + '」 → ' + tgtTxt);
});
return;
}