Răsfoiți Sursa

bugfix:补全index

XieXing 4 luni în urmă
părinte
comite
d7873cd66f
1 a modificat fișierele cu 25 adăugiri și 6 ștergeri
  1. 25 6
      shudao-vue-frontend/src/views/mobile/m-PolicyDocument.vue

+ 25 - 6
shudao-vue-frontend/src/views/mobile/m-PolicyDocument.vue

@@ -406,17 +406,36 @@ onMounted(() => {
     fetchPolicyFiles();
 });
 
+// 滚动位置存储
+let savedScrollPosition = 0;
+
+const lockBodyScroll = () => {
+    savedScrollPosition = window.scrollY;
+    document.body.style.position = 'fixed';
+    document.body.style.top = `-${savedScrollPosition}px`;
+    document.body.style.width = '100%';
+    document.body.style.overflow = 'hidden';
+};
+
+const unlockBodyScroll = () => {
+    document.body.style.position = '';
+    document.body.style.top = '';
+    document.body.style.width = '';
+    document.body.style.overflow = '';
+    window.scrollTo(0, savedScrollPosition);
+};
+
 onUnmounted(() => {
-    document.body.style.overflow = "";
+    unlockBodyScroll();
     if (scrollTimer) clearTimeout(scrollTimer);
     if (searchTimer) clearTimeout(searchTimer);
 });
 
 watch(previewVisible, (val) => {
     if (val) {
-        document.body.style.overflow = "hidden";
+        lockBodyScroll();
     } else {
-        document.body.style.overflow = "";
+        unlockBodyScroll();
     }
 });
 </script>
@@ -809,15 +828,15 @@ watch(previewVisible, (val) => {
 .preview-body {
     flex: 1;
     background: #111827;
-    display: flex;
-    align-items: center;
-    justify-content: center;
+    position: relative;
+    overflow: hidden;
 }
 
 .preview-frame {
     width: 100%;
     height: 100%;
     border: none;
+    display: block;
 }
 
 .preview-placeholder {