Browse Source

增加登陆入口
Signed-off-by: caner <5658514@qq.com>

caner 3 years ago
parent
commit
90136c37cd
2 changed files with 11 additions and 9 deletions
  1. 4 0
      README.md
  2. 7 9
      src/App.vue

+ 4 - 0
README.md

@@ -6,3 +6,7 @@
 ```
 1. 房间ID与车端ID需一致
 ```
+### TODO
+```
+1. 适配遥控手柄中....
+```

+ 7 - 9
src/App.vue

@@ -1,11 +1,9 @@
 <template>
   <div id="app">
     <template v-if="isLogin">
-      <template v-if="!showLoading">
-        <video id="v2" autoplay playsinline muted></video>
-        <div class="marke"></div>
-      </template>
-      <Loading v-else />
+      <video id="v2" autoplay playsinline muted></video>
+      <div class="marke"></div>
+      <Loading v-if="showLoading" />
     </template>
     <Login v-else :err="error" @loginBack="login" />
   </div>
@@ -52,17 +50,16 @@ export default {
             if (this.Peer.iceGatheringState === "complete") {
               const answer = this.Peer.localDescription;
               this.socket.emit("msg", answer);
-              this.showLoading = false
             }
           };
 
           // listen track
           this.Peer.ontrack = (evt) => {
-            console.log("track", evt.streams[0]);
+            console.log("track", evt);
             this.remoteVideo = document.getElementById("v2");
             this.remoteVideo.srcObject = evt.streams[0];
+            this.showLoading = false;
           };
-
         } catch (error) {
           this.socket.disconnect();
           this.isLogin = false;
@@ -71,8 +68,8 @@ export default {
       });
 
       this.socket.on("msg", async (data) => {
-        console.log(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);
@@ -130,6 +127,7 @@ body {
   user-select: none;
   width: 100%;
   height: 100%;
+  overflow: hidden;
 }
 
 video {