|
@@ -1,7 +1,13 @@
|
|
|
<template>
|
|
|
<div class="abody">
|
|
|
<div class="ablockly">
|
|
|
- <el-button type="primary" class="btnPosition" @click="start()" v-if="type == '2'">{{loading ? "运行" : "加载中..." }}</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ class="btnPosition"
|
|
|
+ @click="start()"
|
|
|
+ v-if="type == '2'"
|
|
|
+ >{{ loading ? "运行" : "加载中..." }}</el-button
|
|
|
+ >
|
|
|
<div id="blocklyDiv"></div>
|
|
|
<xml id="toolbox" style="display: none">
|
|
|
<category name="逻辑" colour="%{BKY_LOGIC_HUE}">
|
|
@@ -22,10 +28,17 @@
|
|
|
<sep></sep>
|
|
|
<category id="police" name="电子警察组件" colour="#1b5873">
|
|
|
<block type="iot_lcd_policeinit"></block>
|
|
|
+ <block type="iot_lcd_trunLeftinit"></block>
|
|
|
+ <block type="iot_lcd_trunRightinit"></block>
|
|
|
</category>
|
|
|
</xml>
|
|
|
</div>
|
|
|
- <iframe src="https://meta.cocorobo.cn" frameborder="0" ref="unityvue" allow="microphone;camera;midi;encrypted-media;"></iframe>
|
|
|
+ <iframe
|
|
|
+ src="https://meta.cocorobo.cn"
|
|
|
+ frameborder="0"
|
|
|
+ ref="unityvue"
|
|
|
+ allow="microphone;camera;midi;encrypted-media;"
|
|
|
+ ></iframe>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -86,9 +99,24 @@ export default {
|
|
|
},
|
|
|
//运行
|
|
|
start() {
|
|
|
+ var a = this.myUpdateFunction();
|
|
|
+ console.log(a);
|
|
|
+ var array = a.split(";");
|
|
|
if (this.loading) {
|
|
|
if (this.active) {
|
|
|
- this.$refs.unityvue.contentWindow.postMessage({ do: "1" }, "*");
|
|
|
+ // this.$refs.unityvue.contentWindow.postMessage({ do: "1" }, "*");
|
|
|
+ // this.$refs.unityvue.contentWindow.postMessage({ do: "trunLeft" }, "*");
|
|
|
+ for (let i = 0; i < array.length; i++) {
|
|
|
+ setTimeout(() => {
|
|
|
+ if (array[i].indexOf("screen") != -1) {
|
|
|
+ this.$refs.unityvue.contentWindow.postMessage({ do: "1" }, "*");
|
|
|
+ }else if (array[i].indexOf("trunLeft") != -1) {
|
|
|
+ this.$refs.unityvue.contentWindow.postMessage({ do: "trunLeft" }, "*");
|
|
|
+ }else if (array[i].indexOf("trunRight") != -1) {
|
|
|
+ this.$refs.unityvue.contentWindow.postMessage({ do: "trunRight" }, "*");
|
|
|
+ }
|
|
|
+ }, 200 * i);
|
|
|
+ }
|
|
|
} else {
|
|
|
this.$message.error("请拼接完才能执行");
|
|
|
}
|
|
@@ -181,6 +209,54 @@ export default {
|
|
|
var _code = "police=1;";
|
|
|
return _code;
|
|
|
};
|
|
|
+
|
|
|
+ Blockly.Blocks["iot_lcd_trunLeftinit"] = {
|
|
|
+ init: function () {
|
|
|
+ this.appendDummyInput().appendField(
|
|
|
+ new Blockly.FieldImage(
|
|
|
+ require("../assets/img/screen_init_header.png"),
|
|
|
+ 45,
|
|
|
+ 45
|
|
|
+ )
|
|
|
+ );
|
|
|
+ this.appendDummyInput().appendField("向左移动");
|
|
|
+ this.setInputsInline(false);
|
|
|
+ this.setPreviousStatement(true);
|
|
|
+ this.setNextStatement(true);
|
|
|
+ this.setColour("#1b5873");
|
|
|
+ this.setTooltip("");
|
|
|
+ this.setHelpUrl("");
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ Blockly.JavaScript.iot_lcd_trunLeftinit = function (block) {
|
|
|
+ var _code = "trunLeft=1;";
|
|
|
+ return _code;
|
|
|
+ };
|
|
|
+
|
|
|
+ Blockly.Blocks["iot_lcd_trunRightinit"] = {
|
|
|
+ init: function () {
|
|
|
+ this.appendDummyInput().appendField(
|
|
|
+ new Blockly.FieldImage(
|
|
|
+ require("../assets/img/screen_init_header.png"),
|
|
|
+ 45,
|
|
|
+ 45
|
|
|
+ )
|
|
|
+ );
|
|
|
+ this.appendDummyInput().appendField("向右移动");
|
|
|
+ this.setInputsInline(false);
|
|
|
+ this.setPreviousStatement(true);
|
|
|
+ this.setNextStatement(true);
|
|
|
+ this.setColour("#1b5873");
|
|
|
+ this.setTooltip("");
|
|
|
+ this.setHelpUrl("");
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ Blockly.JavaScript.iot_lcd_trunRightinit = function (block) {
|
|
|
+ var _code = "trunRight=1;";
|
|
|
+ return _code;
|
|
|
+ };
|
|
|
var that = this;
|
|
|
window.addEventListener("message", function (e) {
|
|
|
// 监听 message 事件
|
|
@@ -191,11 +267,10 @@ export default {
|
|
|
|
|
|
if (e.data.active) {
|
|
|
that.active = true;
|
|
|
- }else if (e.data.active != undefined) {
|
|
|
+ } else if (e.data.active != undefined) {
|
|
|
that.active = false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (e.data.noCamera) {
|
|
|
that.$message.error(e.data.noCamera);
|
|
|
}
|