chenlei 9 months ago
parent
commit
bafd0ce079

+ 11 - 7
packages/base/src/stores/epub.js

@@ -7,7 +7,7 @@ export const EPUB_THEME_KEY = "epub-theme";
 export const EPUB_FONT_KEY = "epub-font";
 export const EPUB_FONTSIZE_KEY = "epub-fontsize";
 export const EPUB_SIMPLIFIED = "epub-simplified";
-export const EPUB_LOCATION = "epub-location";
+export const EPUB_LOCATION = "epub-loc";
 
 const getFileName = (path) => {
   const regex = /([^/]+)\.[^.]+$/;
@@ -19,6 +19,7 @@ const getFileName = (path) => {
 
 export const useEpubStore = defineStore("epub", () => {
   let bodyNode = null;
+  let ghost = false;
   const fileName = ref("");
   const book = ref(null);
   /**
@@ -62,17 +63,20 @@ export const useEpubStore = defineStore("epub", () => {
          manager: "continuous",
          snap: false,
    *   }
+       // 无痕模式
+       ghost: true
    * })
    */
   const init = async (options = {}) => {
     fileName.value = getFileName(options.url);
+    ghost = options.ghost ?? false;
 
     await initEpub(options);
     initTheme(options.themes);
     const locationStorage = localStorage.getItem(
       `${EPUB_LOCATION}-${fileName.value}`
     );
-    if (locationStorage) {
+    if (locationStorage && !ghost) {
       const match = locationStorage.match(/^(.*?)-(\d+)$/);
 
       goToChapter(match[1], match[2]);
@@ -167,7 +171,7 @@ export const useEpubStore = defineStore("epub", () => {
     const startCfi = curLocation.start.cfi;
     const scrollLeft =
       document.getElementsByClassName("epub-container")[0]?.scrollLeft;
-    const page = scrollLeft / rendition.value._layout.pageWidth;
+    const page = Math.round(scrollLeft / rendition.value._layout.pageWidth);
 
     localStorage.setItem(
       `${EPUB_LOCATION}-${fileName.value}`,
@@ -230,10 +234,10 @@ export const useEpubStore = defineStore("epub", () => {
         document.getElementsByClassName("epub-container")[0]?.scrollTo({
           left: Number(page) * rendition.value._layout.pageWidth,
         });
-        refreshLocation();
+        !ghost && refreshLocation();
       });
     } else {
-      refreshLocation();
+      !ghost && refreshLocation();
     }
   };
 
@@ -257,12 +261,12 @@ export const useEpubStore = defineStore("epub", () => {
 
   const prePage = () => {
     rendition.value.prev().then(() => {
-      refreshLocation();
+      !ghost && refreshLocation();
     });
   };
   const nextPage = () => {
     rendition.value.next().then(() => {
-      refreshLocation();
+      !ghost && refreshLocation();
     });
   };
 

+ 4 - 3
packages/pc/public/three/index.js

@@ -122,7 +122,6 @@ var Viewer = function (index, dom) {
     this.cardGroup.name = "cardGroup";
     this.autoMove = true
 
-
     this.bindEvents()
     this.preLoadCards()
     this.animate()
@@ -156,7 +155,7 @@ Viewer.prototype.preLoadCards = function () {
                 this.addCard()
             }
         }
-        setTimeout(add,  1000/* 40000 * Math.random() * this.getDensity() */)  //当前视野中密度越小 添加越频繁
+        setTimeout(add,  100/* 40000 * Math.random() * this.getDensity() */)  //当前视野中密度越小 添加越频繁
     }
     add()
 
@@ -239,7 +238,7 @@ Viewer.prototype.addCard = function (around) {
 
 
         let h = (Math.random() * 2 - 1) * setting.cards.highest * 0.8 // *0.8是因为靠近后就会飞出视线
-        card.position.copy(this.camera.position).add(direction.add(new THREE.Vector3(0, h, 0)).multiplyScalar(far))
+        card.position.copy(this.camera.position).add(direction.add(new THREE.Vector3(0, h, 0)).multiplyScalar(8))
 
         card.scale.set(map.image.width / 500, map.image.height / 500, 1)
         this.cardGroup.add(card)
@@ -322,6 +321,8 @@ Viewer.prototype.setRenderer = function () {
             this.renderer.setPixelRatio(window.devicePixelRatio ? window.devicePixelRatio : 1),
             this.renderer.autoClear = false
         this.renderer.setClearColor(0xffffff, 1)
+        this.renderer.shadowMap.enabled = true
+        this.renderer.shadowMap.type = THREE.PCFSoftShadowMap
         console.log("ContextCreated")
         //this.emit(Events.ContextCreated) 
     } catch (e) {

BIN
packages/pc/src/assets/images/logo_01-min.png


+ 11 - 0
packages/pc/src/views/Detail/components/Photocopy/index.scss

@@ -16,9 +16,20 @@
     border-radius: 10px;
     box-shadow: 0px 0px 21px 0px rgba(0, 0, 0, 0.1);
     box-sizing: border-box;
+
+    #reader::before {
+      content: "";
+      position: absolute;
+      top: 0;
+      left: 0;
+      right: 0;
+      bottom: 0;
+      z-index: 9;
+    }
   }
 
   &-left {
+    flex-shrink: 0;
     display: flex;
     align-items: center;
     justify-content: center;

+ 28 - 3
packages/pc/src/views/Detail/components/Photocopy/index.vue

@@ -14,7 +14,14 @@
         </div>
       </div>
 
-      <div class="photocopy-right" v-html="list[curIndex]?.description" />
+      <el-scrollbar class="photocopy-right">
+        <div
+          v-if="list[curIndex]?.description"
+          v-html="list[curIndex].description"
+        />
+
+        <div v-else id="reader" />
+      </el-scrollbar>
     </template>
 
     <el-empty v-else description="暂无数据" style="width: 100%" />
@@ -29,8 +36,9 @@
 </template>
 
 <script setup>
-import { watch, ref } from "vue";
+import { watch, ref, nextTick, onUnmounted } from "vue";
 import { usePagination } from "@lsq/base";
+import { useEpubStore } from "@/stores";
 import { getMediaListApi } from "@/api";
 import { getBaseUrl } from "@/utils";
 
@@ -38,6 +46,7 @@ const props = defineProps(["detail", "isLogin"]);
 const curIndex = ref(0);
 const viewerVisible = ref(false);
 const baseUrl = getBaseUrl();
+const epubStore = useEpubStore(window.pinia);
 
 const { total, loading, list, noData, getList } = usePagination(
   async (params) => {
@@ -52,21 +61,37 @@ const { total, loading, list, noData, getList } = usePagination(
 
 const handlePrev = () => {
   curIndex.value = Math.max(curIndex.value - 1, 0);
+  epubStore.prePage();
 };
 
 const handleNext = () => {
   curIndex.value = Math.min(curIndex.value + 1, list.value.length - 1);
+  epubStore.nextPage();
+};
+
+const handleInit = async () => {
+  await getList();
+  nextTick(() => {
+    epubStore.init({
+      ghost: true,
+      url: baseUrl + props.detail.filePath,
+    });
+  });
 };
 
 watch(
   () => props.detail,
   () => {
-    props.detail && getList();
+    props.detail && handleInit();
   },
   {
     immediate: true,
   }
 );
+
+onUnmounted(() => {
+  epubStore.clear();
+});
 </script>
 
 <style lang="scss" scoped>

+ 3 - 2
packages/pc/src/views/Home2/index.scss

@@ -8,7 +8,7 @@
 
     .w1100 {
       display: flex;
-      gap: 220px;
+      justify-content: space-between;
       padding: 38px 0;
       height: 100%;
       box-sizing: border-box;
@@ -45,7 +45,8 @@
     &-main {
       display: flex;
       align-items: center;
-      gap: 85px;
+      gap: 70px;
+      width: 810px;
     }
 
     &__pick {