tremble 3 years ago
parent
commit
aed91a9c3c
3 changed files with 11 additions and 5 deletions
  1. 0 1
      src/components/RTC/PageRtcLive.vue
  2. 10 4
      src/components/RTC/Trtccom.vue
  3. 1 0
      src/components/RTC/index.vue

+ 0 - 1
src/components/RTC/PageRtcLive.vue

@@ -225,7 +225,6 @@ const setUserJoin = async (res) => {
   let name = res.user.Nickname;
   if (res.user.Role == "leader") {
     name = "主持人";
-    console.log(trtccom$.value,'trtccom$.value');
     Dialog.toast({ content: `主持人进入房间` });
 
   }

+ 10 - 4
src/components/RTC/Trtccom.vue

@@ -70,6 +70,16 @@ watch(
   }
 );
 
+
+watch(
+  () => isJoined.value,
+  () => {
+    if (!isJoined.value) {
+      handleLeave()
+    }
+  }
+);
+
 TRTC.checkSystemRequirements().then((checkResult) => {
   console.log(checkResult.result, "checkResult.result");
   if (!checkResult.result) {
@@ -205,16 +215,12 @@ async function handleUnpublish() {
 }
 
 async function handleLeave() {
-  if (!isJoined.value) {
-    return;
-  }
   if (isPublished.value) {
     await handleUnpublish();
   }
   try {
     uninstallEventHandlers();
     await localClient.leave();
-    store.commit("rtc/setIsJoined", false);
     if (localStream) {
       localStream.stop();
       localStream.close();

+ 1 - 0
src/components/RTC/index.vue

@@ -44,6 +44,7 @@ const closeDialog = (str, link) => {
 
 const confirmDialog = async () => {
   await getApp().Connect.follow.exit();
+  store.commit("rtc/setIsJoined", false);
   if (socket.value) {
     console.log(socket.value);
     socket.value.close();