|
@@ -6,11 +6,11 @@
|
|
|
<!-- 信号 -->
|
|
<!-- 信号 -->
|
|
|
<Signal :signalValue="signalValue" />
|
|
<Signal :signalValue="signalValue" />
|
|
|
<!-- 手柄状态 -->
|
|
<!-- 手柄状态 -->
|
|
|
- <div class="contrl" :style="`color:${contrlState ? '#00CED1':'rgba(0, 0, 0, 0.3)'}`"></div>
|
|
|
|
|
|
|
+ <div class="contrl" :style="`color:${contrlState ? '#00CED1' : 'rgba(0, 0, 0, 0.3)'}`"></div>
|
|
|
<!-- 音频 -->
|
|
<!-- 音频 -->
|
|
|
<Record class="audio" @callBack="sendAudio" :audioState="audioState" />
|
|
<Record class="audio" @callBack="sendAudio" :audioState="audioState" />
|
|
|
<!-- 喇叭 -->
|
|
<!-- 喇叭 -->
|
|
|
- <div class="arcode" :style="`color:${muted ? '#00CED1':'rgba(0, 0, 0, 0.3)'}`"></div>
|
|
|
|
|
|
|
+ <div class="arcode" :style="`color:${muted ? '#00CED1' : 'rgba(0, 0, 0, 0.3)'}`"></div>
|
|
|
<!-- 电量 -->
|
|
<!-- 电量 -->
|
|
|
<Battery :quantity="60" />
|
|
<Battery :quantity="60" />
|
|
|
</div>
|
|
</div>
|
|
@@ -129,26 +129,31 @@ export default {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
this.socket.on("msg", async (data) => {
|
|
this.socket.on("msg", async (data) => {
|
|
|
- if (data.type === "offer") {
|
|
|
|
|
- console.log(data.sdp);
|
|
|
|
|
- await this.Peer.setRemoteDescription(data);
|
|
|
|
|
- const answer = await this.Peer.createAnswer();
|
|
|
|
|
- await this.Peer.setLocalDescription(answer);
|
|
|
|
|
- } else if (data.type === "power") {
|
|
|
|
|
- console.log("电量", data);
|
|
|
|
|
- } else if (data.type === "signal") {
|
|
|
|
|
- const v = data.data <= 20 ? Math.floor(data.data / 4) : 5
|
|
|
|
|
- this.signalValue = v || 1
|
|
|
|
|
- } else if (data.type === 'speed') {
|
|
|
|
|
- const v = Math.floor(data.data)
|
|
|
|
|
- this.SpeedValue = v
|
|
|
|
|
|
|
+ const key = data.type
|
|
|
|
|
+ switch (key) {
|
|
|
|
|
+ case "offer":
|
|
|
|
|
+ await this.Peer.setRemoteDescription(data);
|
|
|
|
|
+ const answer = await this.Peer.createAnswer();
|
|
|
|
|
+ await this.Peer.setLocalDescription(answer);
|
|
|
|
|
+ case 'power':
|
|
|
|
|
+ console.log("电量", data);
|
|
|
|
|
+ case 'signal':
|
|
|
|
|
+ const s = data.data <= 20 ? Math.floor(data.data / 4) : 5
|
|
|
|
|
+ this.signalValue = s || 1
|
|
|
|
|
+ case 'speed':
|
|
|
|
|
+ const d = Math.floor(data.data)
|
|
|
|
|
+ this.SpeedValue = d
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
this.socket.on("joined", async () =>
|
|
this.socket.on("joined", async () =>
|
|
|
this.socket.emit("msg", { type: "startRTC" })
|
|
this.socket.emit("msg", { type: "startRTC" })
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
this.socket.on("leaved", () => this.close("车端断开"));
|
|
this.socket.on("leaved", () => this.close("车端断开"));
|
|
|
|
|
+
|
|
|
this.socket.on("connect_error", () => this.close('服务器连接失败'));
|
|
this.socket.on("connect_error", () => this.close('服务器连接失败'));
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -273,13 +278,13 @@ export default {
|
|
|
if (v && this.socket && this.socket.connected) this.socket.emit("msg", { type: "warnAudio", warnAudio: v });
|
|
if (v && this.socket && this.socket.connected) this.socket.emit("msg", { type: "warnAudio", warnAudio: v });
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- beforeDestroy(){
|
|
|
|
|
|
|
+ beforeDestroy() {
|
|
|
this.close()
|
|
this.close()
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|
|
|
<style scoped>
|
|
<style scoped>
|
|
|
- #app {
|
|
|
|
|
|
|
+#app {
|
|
|
font-family: "fonts";
|
|
font-family: "fonts";
|
|
|
font-style: normal;
|
|
font-style: normal;
|
|
|
}
|
|
}
|
|
@@ -367,5 +372,4 @@ body {
|
|
|
min-width: 1000px;
|
|
min-width: 1000px;
|
|
|
min-height: 900px;
|
|
min-height: 900px;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
</style>
|
|
</style>
|