Просмотр исходного кода

fix: no hide button when no guide

chenlei 3 месяцев назад
Родитель
Сommit
a10ea8d5a4

+ 11 - 4
src/index/views/home/components/guide/index.tsx

@@ -1,4 +1,4 @@
-import { defineComponent, ref, watch } from 'vue';
+import { defineComponent, ref, watch, defineEmits } from 'vue';
 import { Swiper, SwiperSlide } from 'swiper/vue';
 import { FreeMode } from 'swiper/modules';
 import { useRoute } from 'vue-router';
@@ -20,7 +20,8 @@ export default defineComponent({
       default: false,
     },
   },
-  setup() {
+  emits: ['showTools'],
+  setup(props, context) {
     let disable = false;
     let partIId = 0;
     const route = useRoute();
@@ -53,7 +54,11 @@ export default defineComponent({
       checkedGuide.value = true;
     };
 
-    const resetGuide = () => {
+    const resetGuide = async (isEnd = false) => {
+      if (!isEnd) {
+        const player = await window.kankan.TourManager.player;
+        player.pause();
+      }
       baseStore.setState('guidePlaying', false);
       playingPartId.value = 0;
       progress.value = 0;
@@ -69,6 +74,8 @@ export default defineComponent({
         // 导览数据
         window.kankan.TourManager.on('loaded', (tours) => {
           tourList.value = tours;
+
+          if (!!tours.length) context.emit('showTools');
         });
 
         // 监听看看的模式
@@ -84,7 +91,7 @@ export default defineComponent({
             baseStore.setState('guidePlaying', false);
           });
           player.on('end', async () => {
-            resetGuide();
+            resetGuide(true);
           });
 
           let currPartId;

+ 27 - 17
src/index/views/home/components/menu/index.tsx

@@ -25,6 +25,7 @@ export default defineComponent({
     const { kankanInited, guidePlaying, hotList, hotListVisible, bgMusicDom, bgMusicPlaying } =
       storeToRefs(baseStore);
     const guideVisible = ref(false);
+    const guideToolsVisible = ref(false);
     const rulesRef = ref<IRulesMethods>();
 
     const handlePlayGuide = async () => {
@@ -93,6 +94,7 @@ export default defineComponent({
       guidePlaying,
       bgMusicDom,
       bgMusicPlaying,
+      guideToolsVisible,
       rulesRef,
       toggle,
       openHotList,
@@ -117,22 +119,26 @@ export default defineComponent({
               })}
             >
               <div class="pinBottom left">
-                <div id="play" class="ui-icon" onClick={this.handlePlayGuide}>
-                  <a>
-                    {!this.guidePlaying ? (
-                      <img src="images/play.png" />
-                    ) : (
-                      <img title="暂停" src="images/pause.png" />
-                    )}
-                  </a>
-                </div>
-                <div
-                  id="pullTab"
-                  class={className({ opened: this.guideVisible })}
-                  onClick={() => (this.guideVisible = !this.guideVisible)}
-                >
-                  <img class="icon icon-inside" src="images/auto.png" title="导览" />
-                </div>
+                {this.guideToolsVisible && (
+                  <>
+                    <div id="play" class="ui-icon" onClick={this.handlePlayGuide}>
+                      <a>
+                        {!this.guidePlaying ? (
+                          <img src="images/play.png" />
+                        ) : (
+                          <img title="暂停" src="images/pause.png" />
+                        )}
+                      </a>
+                    </div>
+                    <div
+                      id="pullTab"
+                      class={className({ opened: this.guideVisible })}
+                      onClick={() => (this.guideVisible = !this.guideVisible)}
+                    >
+                      <img class="icon icon-inside" src="images/auto.png" title="导览" />
+                    </div>
+                  </>
+                )}
                 {Boolean(this.hotList.length) && (
                   <div id="hotList" onClick={this.openHotList}>
                     <img class="icon icon-inside" src="images/hotlist.png" title="热点列表" />
@@ -189,7 +195,11 @@ export default defineComponent({
           </>
         )}
 
-        <Guide open={this.guideVisible} playing={this.guidePlaying} />
+        <Guide
+          open={this.guideVisible}
+          playing={this.guidePlaying}
+          onShowTools={() => (this.guideToolsVisible = true)}
+        />
         <Rules ref="rulesRef" />
       </>
     );

+ 0 - 1
src/index/views/home/index.tsx

@@ -50,7 +50,6 @@ export default defineComponent({
           window.TagView = TagView;
           // 监听手动点击事件
           TagView.on('click', (e) => {
-            console.log(e);
             const isLink = e.data.title.startsWith('(link)');
 
             if (isLink) {