jinx 1 miesiąc temu
rodzic
commit
81c04372f5

+ 6 - 0
index.html

@@ -12,5 +12,11 @@
   <body>
     <div id="app"></div>
     <script type="module" src="/src/main.js"></script>
+    <!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
+    <script>
+      // 初始化vConsole
+      var vConsole = new VConsole();
+      console.log("Hello, vConsole!"); // 测试日志输出
+    </script> -->
   </body>
 </html>

+ 84 - 2
src/Mobile.vue

@@ -1,5 +1,5 @@
 <script setup>
-import { computed } from "vue";
+import { onBeforeUnmount, onMounted } from "vue";
 import { useStore } from "vuex";
 import { useRoute } from "vue-router";
 import MobileTabBar from "@/views/mobile/components/MobileTabBar.vue";
@@ -8,6 +8,82 @@ const route = useRoute();
 const store = useStore();
 
 // const cachedViews = computed(() => store.getters.cachedViews);
+
+let touchStartX = 0;
+let touchStartY = 0;
+
+const getScrollableParent = (target) => {
+  let element = target instanceof Element ? target : target?.parentElement;
+
+  while (element && element !== document.body) {
+    const style = window.getComputedStyle(element);
+    const canScrollY =
+      /(auto|scroll)/.test(style.overflowY) &&
+      element.scrollHeight > element.clientHeight;
+
+    if (canScrollY) {
+      return element;
+    }
+
+    element = element.parentElement;
+  }
+
+  return document.querySelector(".app-main-m");
+};
+
+const handleTouchStart = (event) => {
+  const touch = event.touches?.[0];
+  if (!touch) {
+    return;
+  }
+
+  touchStartX = touch.clientX;
+  touchStartY = touch.clientY;
+};
+
+const handleTouchMove = (event) => {
+  if (event.touches.length !== 1) {
+    return;
+  }
+
+  const touch = event.touches[0];
+  const deltaX = touch.clientX - touchStartX;
+  const deltaY = touch.clientY - touchStartY;
+
+  if (Math.abs(deltaX) > Math.abs(deltaY)) {
+    return;
+  }
+
+  const scrollable = getScrollableParent(event.target);
+
+  if (!scrollable) {
+    event.preventDefault();
+    return;
+  }
+
+  const scrollTop = scrollable.scrollTop;
+  const maxScrollTop = scrollable.scrollHeight - scrollable.clientHeight;
+  const isAtTop = scrollTop <= 0;
+  const isAtBottom = scrollTop >= maxScrollTop - 1;
+
+  if ((isAtTop && deltaY > 0) || (isAtBottom && deltaY < 0)) {
+    event.preventDefault();
+  }
+};
+
+onMounted(() => {
+  document.documentElement.classList.add("mobile-no-bounce");
+  document.body.classList.add("mobile-no-bounce");
+  document.addEventListener("touchstart", handleTouchStart, { passive: true });
+  document.addEventListener("touchmove", handleTouchMove, { passive: false });
+});
+
+onBeforeUnmount(() => {
+  document.documentElement.classList.remove("mobile-no-bounce");
+  document.body.classList.remove("mobile-no-bounce");
+  document.removeEventListener("touchstart", handleTouchStart);
+  document.removeEventListener("touchmove", handleTouchMove);
+});
 </script>
 
 <template>
@@ -29,8 +105,10 @@ const store = useStore();
 <style scoped>
 .app-shell {
   width: 100%;
-  min-height: 100vh;
+  height: 100%;
   overflow-x: hidden;
+  overflow-y: hidden;
+  overscroll-behavior: none;
   background: url("@/assets/mobile/images/bg.png") no-repeat;
   background-position: center center;
   background-size: cover;
@@ -38,7 +116,11 @@ const store = useStore();
 
 .app-main-m {
   width: 100%;
+  height: 100%;
   overflow-x: hidden;
+  overflow-y: auto;
+  overscroll-behavior: contain;
+  -webkit-overflow-scrolling: touch;
   z-index: 10;
   position: relative;
 }

+ 15 - 0
src/style.css

@@ -37,6 +37,21 @@ button {
   height: 100vh;
 }
 
+html.mobile-no-bounce,
+body.mobile-no-bounce {
+  width: 100%;
+  height: 100%;
+  overflow: hidden;
+  overscroll-behavior: none;
+}
+
+body.mobile-no-bounce #app {
+  width: 100%;
+  height: 100dvh;
+  overflow: hidden;
+  overscroll-behavior: none;
+}
+
 .app-shell {
   width: 100%;
   height: 100%;

+ 7 - 5
src/views/mobile/Mmine.vue

@@ -494,12 +494,14 @@ const goReading = (item) => {
 };
 
 const handleCardClick = (item) => {
-  if (activeTab.value === "resource") {
-    goDetail(item);
-    return;
-  }
+  //   if (activeTab.value === "resource") {
+  //     goDetail(item);
+  //     return;
+  //   }
 
-  goReading(item);
+  //   goReading(item);
+
+  goDetail(item);
 };
 
 const toggleFavorite = async (item) => {

+ 7 - 2
src/views/pc/HomeView.vue

@@ -469,9 +469,10 @@ const normalizeMyCollectItem = (item, index) => ({
   isCollect: Boolean(getFirstValue(item, ["isCollect", "collect"], true)),
 });
 
-const filteredRecommendItems = computed(() => recommendList.value.slice(0, 6));
+// const filteredRecommendItems = computed(() => recommendList.value.slice(0, 6));
+const filteredRecommendItems = computed(() => recommendList.value);
 
-const filteredRankItems = computed(() => rankList.value.slice(0, 6));
+const filteredRankItems = computed(() => rankList.value);
 
 const openDetail = (item) => {
   const targetFormDefId = getFirstValue(
@@ -874,6 +875,8 @@ watch(
             font-size: 16px;
             color: #666666;
             line-height: 18px;
+            padding: 0 10px;
+            line-height: 24px;
           }
         }
 
@@ -1017,6 +1020,8 @@ watch(
     gap: 28px 46px;
     max-height: calc(100% - 10px);
     overflow-y: auto;
+    max-height: 500px;
+    overflow-y: auto;
   }
 
   .range-item {

+ 3 - 3
src/views/pc/ResourceDetailView.vue

@@ -318,9 +318,9 @@ onMounted(() => {
     justify-content: center;
 
     img {
-      width: 216px;
-      height: 250px;
-      object-fit: cover;
+      width: 100%;
+      height: 100%;
+      object-fit: contain;
       display: block;
     }
   }