gemercheung %!s(int64=2) %!d(string=hai) anos
pai
achega
50bf307bcc

+ 3 - 1
src/App.vue

@@ -280,15 +280,17 @@
 
   const handleSyncTags = (tag: null | tagType) => {
     const { socket } = useSocket();
+    const sceneStore = useSceneStore();
     console.log('handleSyncTags', tag);
     if (rtcStore.isLeader) {
       if (socket) {
-        console.log('同步tag-', tag?.sid);
+        console.log('同步tag-', tag?.sid, sceneStore.showCurrentTagLayer);
         socket.emit('action', {
           type: 'sync-tag',
           data: {
             roomId: rtcStore.roomId,
             id: tag?.sid || null,
+            showCurrentTagLayer: sceneStore.showCurrentTagLayer,
           },
         });
       }

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

@@ -558,6 +558,10 @@ const handleSyncTag = (data) => {
       sceneStore.setCurrentTag(tag || null);
     } else {
       sceneStore.setCurrentTag(null);
+      sceneStore.setCurrentTagLayer(false);
+    }
+    if ('showCurrentTagLayer' in data && data?.id) {
+      sceneStore.setCurrentTagLayer(data.showCurrentTagLayer);
     }
   }
 

+ 6 - 25
src/components/chatRoom/index.vue

@@ -190,7 +190,7 @@
   import dayjs from 'dayjs';
   import duration from 'dayjs/plugin/duration';
   import { useMiniApp } from '/@/hooks/useMiniApp';
-  import { useSceneStore } from '/@/store/modules/scene';
+
   const { closeSocket } = useSocket();
   dayjs.extend(duration);
   // hook
@@ -241,8 +241,6 @@
   let roomCount: NodeJS.Timeout;
   const { t } = useI18n();
   const { sceneList } = useRoom();
-  const sceneStore = useSceneStore();
-  const currentTag = computed(() => sceneStore.currentTag);
 
   watchEffect(() => {
     console.log('sceneList', sceneList);
@@ -381,36 +379,15 @@
     );
     //初始化同屏等
     watch(
-      () => [isJoined, isNativeLeader, currentTag],
+      () => [isJoined, isNativeLeader],
       async (val) => {
         try {
-          // console.log('初始化同屏', unref(val[0]), unref(val[1]));
-          // if (unref(val[0])) {
-          //   const app = await useApp();
-
-          //   app.Scene.
-
-          //   if (unref(isNativeLeader)) {
-          //     setTimeout(() => {
-          //       app.Connect.follow.start({ follow: false });
-          //     }, 1000);
-          //   } else {
-          //     console.log('customer-follow');
-          //     setTimeout(() => {
-          //       app.Connect.follow.start({ follow: true });
-          //     }, 1000);
-          //   }
-          //   app.Connect.follow.on('data', leaderSync);
-          //   app.Connect.paint.on('data', leaderPaint);
-          // }
           const app = await useApp();
           if (app.Scene.loaded) {
             sceneInit(app, val);
           } else {
             app.Scene.on('loaded', () => sceneInit(app, val));
           }
-
-          //同步tag
         } catch (error) {
           console.log('error', error);
         }
@@ -419,6 +396,10 @@
         deep: true,
       },
     );
+
+    // watch(currentTag, (val) => {
+    //   console.log('currentTag', val);
+    // });
   });
   onUnmounted(async () => {
     const { handleLeave } = useRtcSdk();

+ 7 - 4
src/components/hotspot/index.vue

@@ -62,7 +62,7 @@
   const tags = computed(() => sceneStore.tags);
   const currentTag: ComputedRef<tagType | null> = computed(() => sceneStore.currentTag);
   const isClick = ref(false);
-  const showLayer = ref(false);
+  const showLayer = computed(() => sceneStore.currentTagLayer);
   const emit = defineEmits(['setCurrentTag']);
 
   const isShowTag = computed(() => {
@@ -73,14 +73,16 @@
   const isMobile = computed(() => browser.isMobile());
 
   const openLayer = (tag: tagType) => {
-    showLayer.value = true;
+    // showLayer.value = true;
+    sceneStore.setCurrentTagLayer(true);
     // currentTag.value = tag;
     emit('setCurrentTag', tag);
     sceneStore.setCurrentTag(tag);
     console.error('open-layer');
   };
   const closeLayer = () => {
-    showLayer.value = false;
+    // showLayer.value = false;
+    sceneStore.setCurrentTagLayer(false);
     // currentTag.value = null;
     emit('setCurrentTag', null);
     sceneStore.setCurrentTag(null);
@@ -96,7 +98,8 @@
   const goTag = (_, item: tagType) => {
     console.warn('gototag', item.sid);
     emit('setCurrentTag', item);
-    showLayer.value = false;
+    // showLayer.value = false;
+    sceneStore.setCurrentTagLayer(false);
     if (unref(isClick)) {
       // currentTag.value = null;
       sceneStore.setCurrentTag(null);

+ 6 - 0
src/store/modules/scene.ts

@@ -79,6 +79,9 @@ export const useSceneStore = defineStore({
       }
       return null;
     },
+    showCurrentTagLayer(): boolean {
+      return this.currentTagLayer;
+    },
   },
   actions: {
     load(metadata: KankanMetaDataType): void {
@@ -105,5 +108,8 @@ export const useSceneStore = defineStore({
     setCurrentTag(tag: null | tagType): void {
       this.currentTag = tag;
     },
+    setCurrentTagLayer(status: boolean): void {
+      this.currentTagLayer = status;
+    },
   },
 });