gemercheung 2 роки тому
батько
коміт
3a9fc4b370

+ 16 - 3
src/App.vue

@@ -26,6 +26,8 @@
   import BaseDialog from '/@/components/chatRoom/dialog/base.vue';
   import PasswordDialog from '/@/components/chatRoom/dialog/password.vue';
   import { useRoom, roomId, currentSceneIndex } from './hooks/useRoom';
+  import dayjs from 'dayjs';
+  import Dialog from './components/basic/dialog';
 
   const { createTourPlayer } = useTourPlayer();
   const showDebug = ref(Number(import.meta.env.VITE_SHOW_DEBUGPANEL) === 1);
@@ -56,7 +58,7 @@
   // const isJoined = computed(() => rtcStore.isJoined);
   const isLoaded = computed(() => appStore.isLoaded);
   const showPasswordDialog = ref(false);
-
+  // const connectStatus = computed(() => rtcStore.connectStatus);
   const controls = computed(() => {
     return metadata.value.controls;
   });
@@ -285,6 +287,16 @@
     if (unref(isTourMode)) {
       const { room, currentSceneIndex, firstNum } = useRoom();
       console.log('room', room);
+      //设置自由模式并时间未到
+
+      if (unref(room)?.useEndTime) {
+        const now = dayjs();
+        const isNotEnd = dayjs(unref(room)?.useEndTime).diff(now, 'second');
+        if (isNotEnd > 0) {
+          console.log('存在带看有效存活', isNotEnd);
+          Dialog.toast({ content: t('action.endUpRoom'), type: 'error' });
+        }
+      }
       if (unref(room)?.takeLookLock === 1) {
         if (unref(currentSceneIndex) > 0) {
           const hasInput = localStorage.getItem(`${roomId}-${unref(firstNum)}`);
@@ -311,10 +323,11 @@
       {{ maxNumber }}
     </span> -->
     <span>
-      {{ t('base.debuginfo') }}:公告,测试1.1.0-0412-05,角色:{{ rtcStore.role }} rId:{{
+      {{ t('base.debuginfo') }}:公告,测试1.1.0-0423-01,角色:{{ rtcStore.role }} rId:{{
         rtcStore.roomId || browser.getURLParam('roomId')
       }}
-      sceneIndex:{{ currentSceneIndex }}
+      sceneIndex:{{ currentSceneIndex }} uid::
+      {{ rtcStore.userId || browser.getURLParam('vruserId') }}
     </span>
     <span class="close" @click.stop="showDebug = false">X</span>
   </div>

+ 5 - 5
src/components/basic/guide.vue

@@ -26,11 +26,11 @@
   const lang = computed(() => browser.getURLParam('lang') || 'zh');
 
   onMounted(() => {
-    appStore.showUserGuide(true);
-    // const isGuide = localStorage.getItem('user_guide');
-    // if (!isGuide) {
-    //   appStore.showUserGuide(true);
-    // }
+    // appStore.showUserGuide(true);
+    const isGuide = localStorage.getItem('user_guide');
+    if (!isGuide) {
+      appStore.showUserGuide(true);
+    }
   });
 
   const onSet = () => {

+ 40 - 4
src/components/chatRoom/controls/actions.ts

@@ -14,6 +14,7 @@ import duration from 'dayjs/plugin/duration';
 import { useRtcSdk } from '/@/hooks/useTRTC';
 import { useMiniApp } from '/@/hooks/useMiniApp';
 dayjs.extend(duration);
+const { isUsingMiniApp } = useMiniApp();
 // import { useRtcSdk } from '/@/hooks/useTRTC';
 interface ActionDataType {
   type: string;
@@ -105,7 +106,9 @@ export function handleActions({
     default:
       break;
     case 'user-be-kicked':
-      handleError();
+      const { t } = useI18n();
+      Dialog.toast({ content: t('action.endUpRoom') });
+      handleMaxRoomsError();
       break;
   }
   if (members?.length) {
@@ -395,10 +398,26 @@ const handleLeaderDismiss = () => {
       closeTxt: t('base.cancel'),
       isSingle: true,
     },
-    () => {},
+    () => {
+      if (isUsingMiniApp.value) {
+        //@ts-ignore
+        wx.miniProgram.switchTab({
+          url: '/pages/index/index',
+        });
+      } else {
+        closeSocket();
+      }
+    },
   );
   setTimeout(() => {
-    closeSocket();
+    if (isUsingMiniApp.value) {
+      //@ts-ignore
+      wx.miniProgram.switchTab({
+        url: '/pages/index/index',
+      });
+    } else {
+      closeSocket();
+    }
   }, 5000);
 };
 
@@ -421,10 +440,27 @@ export const handleError = () => {
     },
   );
 };
+// 满员提示
+export const handleMaxRoomsError = () => {
+  // const rtcStore = useRtcStore();
+  // const { t } = useI18n();
+
+  setTimeout(() => {
+    if (isUsingMiniApp.value) {
+      //@ts-ignore
+      wx.miniProgram.switchTab({
+        url: '/pages/index/index',
+      });
+    } else {
+      const { closeSocket } = useSocket();
+      closeSocket();
+    }
+  }, 3000);
+};
 
 export const handleTimeOutError = () => {
   const rtcStore = useRtcStore();
-  const { isUsingMiniApp } = useMiniApp();
+
   const { t } = useI18n();
   rtcStore.showBaseDialog(
     {

+ 0 - 2
src/components/chatRoom/dialog/password.vue

@@ -41,8 +41,6 @@
   import Dialog from '/@/components/basic/dialog';
   import { useI18n } from '/@/hooks/useI18n';
   import browser from '/@/utils/browser';
-  // import { useSocket } from '/@/hooks/userSocket';
-  // import VOtpInput from 'vue3-otp-input';
   import { useRoom } from '/@/hooks/useRoom';
   import { useRtcStore } from '/@/store/modules/rtc';
 

+ 14 - 3
src/components/chatRoom/index.vue

@@ -289,16 +289,20 @@
       if (unref(currentSceneIndex) > 0) {
         const hasInput = localStorage.getItem(`${rtcStore.roomId}-${unref(firstNum)}`);
         console.log('密码::', hasInput);
+
         if (Number(hasInput) === 1) {
           showPasswordDialog.value = false;
+          //多场景已输入,放行加入
         } else {
+          // 存在密码中断rtc connect
           showPasswordDialog.value = true;
+          return;
         }
       } else {
+        // 存在密码中断rtc connect
         showPasswordDialog.value = true;
+        return;
       }
-
-      return;
     }
 
     const socket = createSocket();
@@ -550,7 +554,14 @@
       roomId: rtcStore.roomId,
       userId: rtcStore.userId,
     });
-    closeSocket();
+    if (isUsingMiniApp.value) {
+      //@ts-ignore
+      wx.miniProgram.switchTab({
+        url: '/pages/index/index',
+      });
+    } else {
+      closeSocket();
+    }
   };
 
   const handleCreateShare = async () => {

+ 11 - 1
src/components/chatRoom/roomControl.ts

@@ -8,7 +8,12 @@ import Dialog from '/@/components/basic/dialog';
 import { roomId, useRoom } from '/@/hooks/useRoom';
 import { useI18n } from '/@/hooks/useI18n';
 import dayjs from 'dayjs';
-import { handleTimeOutError, handleEarlyError, handleError } from '../chatRoom/controls/actions';
+import {
+  handleTimeOutError,
+  handleEarlyError,
+  handleError,
+  handleMaxRoomsError,
+} from '../chatRoom/controls/actions';
 // 所有socket业务事件集中点
 
 export function initSocketEvent(socket: SocketIOClient.Socket): void {
@@ -102,18 +107,23 @@ export function initSocketEvent(socket: SocketIOClient.Socket): void {
       switch (type) {
         case 'repeat-login':
           Dialog.toast({ content: t('action.errorRepeatLogin') });
+          handleMaxRoomsError();
           break;
         case 'room-maxing':
           Dialog.toast({ content: t('action.errorRoomMaxing') });
+          handleMaxRoomsError();
           break;
         case 'invalid-master':
           Dialog.toast({ content: t('action.errorInvalidMaster') });
+          handleError();
           break;
         case 'invalid-match-role':
           Dialog.toast({ content: t('base.errorRoom') });
+          handleError();
           break;
         case 'invalid-room-params':
           Dialog.toast({ content: t('base.errorRoom') });
+          handleError();
           break;
         case 'ttl-out':
           handleError();