Explorar o código

feat: 长图可以通过鼠标左键进行滑动; fix:router.replace尽量都改成router.push

任一存 hai 1 ano
pai
achega
268470d67e

+ 4 - 4
src/useFunctions/useSmoothSwipe.js

@@ -259,10 +259,10 @@ export default function useSmoothSwipe({
     watch(scrollTargetRef, (v) => {
       if (v) {
         v.addEventListener('wheel', onWheel)
-        // v.addEventListener('mousedown', onMouseDown)
-        // v.addEventListener('mouseleave', onMouseLeave)
-        // v.addEventListener('mousemove', onMouseMove)
-        // v.addEventListener('mouseup', onMouseUp)
+        v.addEventListener('mousedown', onMouseDown)
+        v.addEventListener('mouseleave', onMouseLeave)
+        v.addEventListener('mousemove', onMouseMove)
+        v.addEventListener('mouseup', onMouseUp)
         // v.addEventListener('touchstart', onTouchStart)
         // v.addEventListener('touchmove', onTouchMove)
         // v.addEventListener('touchend', onTouchEnd)

+ 1 - 1
src/views/GameView.vue

@@ -62,7 +62,7 @@ onMounted(() => {
   }
 
   window.closeGame = () => {
-    router.replace('/more-content?anchorIdx=2')
+    router.go('-1')
   }
 })
 </script>

+ 19 - 4
src/views/MoreContent.vue

@@ -193,10 +193,7 @@
           </div>
           <div
             class="restart"
-            @click="() => {
-              store.state.haveShownStartup = false;
-              router.replace('/?back=1');
-            }"
+            @click="onClickRestart"
           >
             重新开始
           </div>
@@ -267,6 +264,7 @@ const maxTranslateLength = computed(() => {
 
 const {
   translateLength,
+  haveSwipedThisTime, // 用于在click事件中判断是否是鼠标按下后左右滑动导致的
 } = useSmoothSwipe({
   scrollTargetRef: scrollTarget,
   maxTranslateLength,
@@ -312,12 +310,18 @@ watch(
 )
 
 function onClickShuangGouEntry() {
+  if (haveSwipedThisTime.value) {
+    return
+  }
   router.push({
     name: 'ShuangGou',
   })
 }
 
 function onClickEntryAtMoZhu(pathName) {
+  if (haveSwipedThisTime.value) {
+    return
+  }
   router.push({
     name: pathName,
   })
@@ -325,11 +329,22 @@ function onClickEntryAtMoZhu(pathName) {
 
 // 点击线上展厅
 const OpenScene = () => {
+  if (haveSwipedThisTime.value) {
+    return
+  }
   const musicDom = document.getElementById("bg-music")
   musicDom.pause()
   router.push('/scene')
 }
 
+function onClickRestart() {
+  if (haveSwipedThisTime.value) {
+    return
+  }
+  store.state.haveShownStartup = false
+  router.replace('/')
+}
+
 const isShowCast = ref(false)
 
 </script>

+ 8 - 1
src/views/PaintingList.vue

@@ -118,6 +118,7 @@
               class="top-wrap-img"
             >
               <img
+                draggable="false"
                 :style="{height:item['音图'] == 'zhaomengfu1.png' ? '78%':''}"
                 :src="`${$env.BASE_URL}configMultiMedia/author/${item['音图']}`"
               >
@@ -249,6 +250,7 @@ const {
   translateLength,
   computeMaxTranslateLengthInnerByScrollTarget,
   speedUp,
+  haveSwipedThisTime, // 用于在click事件中判断是否是鼠标按下后左右滑动导致的
 } = useSmoothSwipe({
   scrollTargetRef: menuEl,
   maxTranslateLength: undefined,
@@ -322,6 +324,9 @@ const unwatch = watch(menuElScrollLeft, (v) => {
 })
 
 function onClickAge(ageName, evt) {
+  if (haveSwipedThisTime.value) {
+    return
+  }
   isShowOperationTip.value = false
   if (expandedAgeNameList.value.has(ageName)) {
     expandedAgeNameList.value.delete(ageName)
@@ -341,7 +346,9 @@ function onClickAge(ageName, evt) {
 const isShowPaintingStyleDesc = ref(false)
 
 function onClickPainting(item) {
-  console.log('sdfsdfsdf', item)
+  if (haveSwipedThisTime.value) {
+    return
+  }
   router.push({
     name: 'PaintingDetail',
     query: {

+ 1 - 1
src/views/SceneView.vue

@@ -9,7 +9,7 @@ const router = useRouter()
 const closeScene = () => {
   const musicDom = document.getElementById('bg-music')
   musicDom.play()
-  router.replace('/more-content?anchorIdx=3')
+  router.go('-1')
 }
 </script>