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

虚拟实验室-智能家居:
1、窗帘日志输出

liyanbo 6 месяцев назад
Родитель
Сommit
afb62209ef
1 измененных файлов с 15 добавлено и 17 удалено
  1. 15 17
      src/views/block/Blockly2.vue

+ 15 - 17
src/views/block/Blockly2.vue

@@ -39,23 +39,23 @@
 
     <!-- 右下角按钮组 -->
     <div class="button-group">
-      <el-button class="control-button run-button" @click="runCode">运行</el-button>
+      <el-button class="control-button run-button" @click="toggleLight">运行</el-button>
       <el-button class="control-button code-button" @click="handleViewCode">代码</el-button>
     </div>
 
     <!-- 显示当前灯光信息 -->
-    <div v-if="state.lamp.isLightOn" class="lamp-info">
+<!--    <div v-if="state.lamp.isLightOn" class="lamp-info">
       <p>颜色: {{ state.lamp.colorLog }}色</p>
       <p>亮度: {{ state.lamp.brightness }}%</p>
 
-      <!-- 音乐播放状态显示和控制按钮 -->
+      &lt;!&ndash; 音乐播放状态显示和控制按钮 &ndash;&gt;
       <div v-if="state.isMusicPlaying" class="music-info">
         <p>正在播放: {{ state.currentMusicName }}</p>
         <button class="stop-music-btn" @click="handleStopMusic">
           停止播放
         </button>
       </div>
-    </div>
+    </div>-->
   </div>
 
 
@@ -179,7 +179,7 @@
         <h2>工作区</h2>
         <div id="blocklyDiv"></div>
         <div class="controls">
-          <button id="runCode" @click="runCode">运行代码</button>
+          <button id="runCode" @click="toggleLight">运行代码</button>
           <button @click="clearWorkspace">清空工作区</button>
         </div>
       </div>
@@ -792,7 +792,7 @@ const aiService = {
   // 打开顶灯
   topLampOn: withErrorHandling('打开顶灯', async function() {
     state.showLightOpen = true
-    console.log("打开顶灯");
+    console.log("顶灯已打开");
     showStatus("顶灯已打开");
     return true;
   }, '打开顶灯失败'),
@@ -800,10 +800,10 @@ const aiService = {
   // 关闭顶灯
   topLampOff: withErrorHandling('关闭顶灯', async function() {
     state.showLightOpen = false
-    console.log("关闭顶灯");
+    console.log("顶灯已关闭");
     showStatus("顶灯已关闭");
     return true;
-  }, '关闭窗帘失败'),
+  }, '关闭顶灯失败'),
 
   // 控制电视状态
   controlTv: withErrorHandling('控制电视状态', async function(isOn) {
@@ -849,9 +849,7 @@ const aiService = {
   // 打开窗帘
   openCurtain: withErrorHandling('打开窗帘', async function() {
 
-    console.log("打开窗帘");
-
-    if (state.showCurtainLeft && state.showCurtainRight) {
+    if (!state.showCurtainLeft && !state.showCurtainRight) {
       console.log("窗帘已经是打开的状态");
       return true;
     }
@@ -886,6 +884,7 @@ const aiService = {
       state.showCurtainLeft = false;
       state.showCurtainRight = false;
 
+      console.log("窗帘已打开");
       showStatus("窗帘已打开");
       return true;
     } catch (error) {
@@ -897,8 +896,7 @@ const aiService = {
 
   // 关闭窗帘
   closeCurtain: withErrorHandling('关闭窗帘', async function() {
-    console.log("关闭窗帘");
-    if (!state.showCurtainLeft && !state.showCurtainRight) {
+    if (state.showCurtainLeft && state.showCurtainRight) {
       console.log("窗帘已经是关闭的状态");
       return true;
     }
@@ -927,6 +925,7 @@ const aiService = {
       // 等待动画完成 - 3秒
       await new Promise(resolve => setTimeout(resolve, 3000));
 
+      console.log("窗帘已关闭");
       showStatus("窗帘已关闭"); // 修正状态消息
       return true;
     } catch (error) {
@@ -959,7 +958,7 @@ const aiService = {
       }
     }
 
-    return "命令执行完成";
+    return "智能音箱命令执行完成";
   }, '智能音箱命令执行失败'),
 
   // 智能音箱命令处理 - 多参数版本
@@ -969,7 +968,7 @@ const aiService = {
     this.controlCurtain(curtainStatus)
     this.controlTv(tvStatus)
 
-    return "命令执行完成";
+    return "智能音箱命令执行完成";
   }, '智能音箱命令执行失败'),
 
   // 启动任务轮询
@@ -1651,7 +1650,6 @@ const loadWorkspaceFromJson = () => {
   try {
     // const json = JSON.parse(jsonData.value);
     const json = device.value.jsonData;
-    console.log(typeof json);
     Blockly.serialization.workspaces.load(json, workspace);
     showStatus('工作区已成功从JSON加载!');
   } catch (error) {
@@ -1864,7 +1862,7 @@ const showStatus = (message, type = 'success') => {
   left: 0;
   right: 0;
   bottom: 0;
-  background-image: url('@/assets/images/desklamp.png');
+  background-image: url('@/assets/images/smart-home/base-map.png');
   background-size: cover;
   background-position: center;
   background-repeat: no-repeat;