Browse Source

优化on mesg
Signed-off-by: Caner <5658514@qq.com>

Caner 3 years ago
parent
commit
7122c75a2b
1 changed files with 9 additions and 12 deletions
  1. 9 12
      src/App.vue

+ 9 - 12
src/App.vue

@@ -126,18 +126,15 @@ export default {
 
 
       this.socket.on("msg", async (data) => {
       this.socket.on("msg", async (data) => {
         const key = data.type
         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 'speed':
-            const d = Math.floor(data.data)
-            this.SpeedValue = d
-          default:
-            break;
+        if (key === 'offer') {
+          await this.Peer.setRemoteDescription(data);
+          const answer = await this.Peer.createAnswer();
+          await this.Peer.setLocalDescription(answer);
+        } else if (key === 'power') {
+          console.log("电量", data);
+        } else if (key === 'speed') {
+          const d = Math.floor(data.data)
+          this.SpeedValue = d
         }
         }
       });
       });