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