Просмотр исходного кода

Merge branch 'master' of http://59.110.91.129:3000/zhangmengying/AIClass into wanzi

丸子 6 месяцев назад
Родитель
Сommit
73e262d1b8
1 измененных файлов с 9 добавлено и 29 удалено
  1. 9 29
      src/views/block/Blockly2.vue

+ 9 - 29
src/views/block/Blockly2.vue

@@ -681,7 +681,7 @@ const aiService = {
     // 如果没有活跃的对话ID,创建新对话
     if (!state.activeConversationId) {
       // 使用与TextToText.vue相同的方式创建对话
-      const res = await CreateDialogue({ roleId: 75 });
+      const res = await CreateDialogue({ roleId: 94 });
       state.activeConversationId = res.data;
       console.log("AI智能体创建成功,请等待。。。");
     }
@@ -940,38 +940,16 @@ const aiService = {
   controlSmartSpeaker: withErrorHandling('智能音箱命令处理(单参数)', async function(params) {
     console.log(`智能音箱执行命令: ${params}`);
 
-
-    // 解析命令字符串 (格式: light=on,curtain=open,tv=on)
     const commandPairs = params.split(',');
-
     for (const pair of commandPairs) {
       const [device, action] = pair.split('=');
-
       if (!device || !action) continue;
-
-      // 根据设备类型和动作执行相应的操作
       if (device === 'light') {
-        if (action === 'on' || action.toLowerCase() === 'true' || action === '1') {
-          // 这里可以添加开灯光的具体逻辑
-          console.log('打开灯光');
-          showStatus('灯光已打开');
-        } else if (action === 'off' || action.toLowerCase() === 'false' || action === '0') {
-          // 这里可以添加关灯光的具体逻辑
-          console.log('关闭灯光');
-          showStatus('灯光已关闭');
-        }
+        await this.controlTopLamp(action)
       } else if (device === 'curtain') {
-        if (action === 'open') {
-          await this.openCurtain();
-        } else if (action === 'close') {
-          await this.closeCurtain();
-        }
+        await this.controlCurtain(action)
       } else if (device === 'tv') {
-        if (action === 'on') {
-          await this.turnOnTv();
-        } else if (action === 'off') {
-          await this.turnOffTv();
-        }
+        await this.controlTv(action)
       }
     }
 
@@ -980,10 +958,12 @@ const aiService = {
 
   // 智能音箱命令处理 - 多参数版本
   controlSmartSpeakers: withErrorHandling('智能音箱命令处理(多参数)', async function(lightStatus, curtainStatus, tvStatus) {
-    // 模拟智能音箱执行命令
+    console.log(`智能音箱执行命令: light=${lightStatus}, curtain=${curtainStatus}, tv=${tvStatus}`);
+    await this.controlTopLamp(lightStatus)
+    await this.controlCurtain(curtainStatus)
+    await this.controlTv(tvStatus)
 
-
-    return "result";
+    return "命令执行完成";
   }, '智能音箱命令执行失败'),
 
   // 启动任务轮询