2 次代碼提交 307a872081 ... d603d52243

作者 SHA1 備註 提交日期
  t_finder d603d52243 优化: 关闭页面时关闭连接及实例,释放内存 2 天之前
  t_finder 7f6c7e2c41 优化项目内跳转非webRTC的拉流页token获取方式 2 天之前
共有 3 個文件被更改,包括 21 次插入17 次删除
  1. 2 4
      pages/phone/index.vue
  2. 18 12
      pages/rtcEngine/rtc.vue
  3. 1 1
      static/webRtcYJ/WXtrialInterface.html

+ 2 - 4
pages/phone/index.vue

@@ -4,10 +4,8 @@
       <div v-for="item in diskList" :key="item.id" class="disk-item">
         <v-btn
           :to="{
-            name: 'phone-id',
-            params: {
-              id: item.id,
-            },
+            path: '/rtcEngine/rtc',
+            query: item,
           }"
           >{{ item.diskName }}</v-btn
         >

+ 18 - 12
pages/rtcEngine/rtc.vue

@@ -254,6 +254,8 @@ export default {
   },
   // 页面销毁前触发
   beforeDestroy() {
+    // 关闭通道
+    this.closeChannel();
     // 销毁页面监听事件
     this.destroyListener();
   },
@@ -762,12 +764,7 @@ export default {
         this.activeCloud = cloudData;
 
         // 重置相关数据
-        // 关闭日志上报
-        this.logReportObj?.destroy();
-        // 关闭webRTC
-        this.engine?.disconnect && this.engine?.disconnect();
-        // 关闭业务指令通道
-        this.doConnectDirectivesWs?.close();
+        this.closeChannel();
         // 重置重连次数
         this.doConnectDirectivesRequestNum = 1;
         // 重置 end
@@ -813,12 +810,8 @@ export default {
     },
     // 退出功能
     exit() {
-      // 关闭日志上报
-      this.logReportObj?.destroy();
-      // 关闭webRTC
-      this.engine?.disconnect && this.engine?.disconnect();
-      // 关闭业务指令通道
-      this.doConnectDirectivesWs?.close();
+      // 关闭通道
+      this.closeChannel();
 
       // 获取当前环境
       const env = isBrowserEnvironment();
@@ -851,6 +844,19 @@ export default {
         this.logReportObj.setParams({ clientType: Object.keys(res)[0] });
       })
     },
+    // 关闭通道
+    async closeChannel() {
+      try {
+        // 关闭日志上报
+        this.logReportObj?.destroy();
+        // 关闭webRTC
+        this.engine?.disconnect && this.engine?.disconnect();
+        // 关闭业务指令通道
+        this.doConnectDirectivesWs?.close();
+      } catch (error) {
+        console.log('closeChannel error', error);
+      }
+    },
     // 开始运行程序
     async start(activeCloud) {
       console.log('start activeCloud', activeCloud);

+ 1 - 1
static/webRtcYJ/WXtrialInterface.html

@@ -534,7 +534,7 @@
         }),
         headers: {
           'content-Type': 'application/json',
-          Authorization: token,
+          Authorization: token ?? localStorage.getItem('auth._token.password'),
         },
         dataType: 'json',
         async: false,