chenlei 3 dagen geleden
bovenliggende
commit
9e020dd3c9

+ 5 - 6
packages/base/src/stores/epub.js

@@ -127,7 +127,6 @@ export const useEpubStore = defineStore("epub", () => {
   };
 
   const clear = () => {
-    console.log(rendition.value);
     rendition.value?.clear();
     rendition.value = null;
     book.value = null;
@@ -168,10 +167,10 @@ export const useEpubStore = defineStore("epub", () => {
 
   const refreshLocation = async () => {
     const curLocation = rendition.value.currentLocation();
-    const startCfi = curLocation.start.cfi;
+    const startCfi = curLocation.end.cfi;
     const scrollLeft =
       document.getElementsByClassName("epub-container")[0]?.scrollLeft;
-    const page = Math.round(scrollLeft / rendition.value._layout.pageWidth);
+    const page = Math.floor(scrollLeft / rendition.value._layout.pageWidth);
 
     localStorage.setItem(
       `${EPUB_LOCATION}-${fileName.value}`,
@@ -231,9 +230,9 @@ export const useEpubStore = defineStore("epub", () => {
 
     if (page) {
       nextTick(() => {
-        document.getElementsByClassName("epub-container")[0]?.scrollTo({
-          left: Number(page) * rendition.value._layout.pageWidth,
-        });
+        // document.getElementsByClassName("epub-container")[0]?.scrollTo({
+        //   left: Number(page) * rendition.value._layout.pageWidth,
+        // });
         !ghost && refreshLocation();
       });
     } else {

File diff suppressed because it is too large
+ 19295 - 1
packages/pc/public/epub.min.js


+ 1 - 1
packages/pc/src/components/TopNav/components/LoginDialog.vue

@@ -40,7 +40,7 @@ const login = () => {
   new WxLogin({
     self_redirect: false, //true:手机点击确认登录后可以在 iframe 内跳转到 redirect_uri
     id: "login-dialog__scan", //显示二维码容器设置
-    appid: "wx3d4f2e0cfc3b8e54", //应用位置标识appid
+    appid: "wxf8c9a88a83c5e9b8", //应用位置标识appid
     scope: "snsapi_login", //当前微信扫码登录页面已经授权了
     redirect_uri: encodeURIComponent(location.href), //填写授权回调域路径,就是用户授权成功以后,微信服务器向公司后台推送code地址
     state: "", //state就是后台服务器重定向的地址携带用户信息

+ 7 - 7
packages/pc/src/components/TopNav/index.vue

@@ -128,7 +128,7 @@
 </template>
 
 <script setup>
-import { watch, ref, onMounted } from "vue";
+import { watch, ref } from "vue";
 import { useRoute, useRouter } from "vue-router";
 import { useDark } from "@vueuse/core";
 import { storeToRefs } from "pinia";
@@ -210,9 +210,9 @@ const handleLike = async () => {
 };
 
 const handleLogin = async () => {
-  // loginVisible.value = true
-  const data = await fakeLoginApi(1);
-  baseStore.login(data);
+  loginVisible.value = true;
+  // const data = await fakeLoginApi(1);
+  // baseStore.login(data);
 };
 
 watch(route, (v) => {
@@ -224,9 +224,9 @@ watch(route, (v) => {
 });
 
 // 目前没有公众号,先默认登录
-onMounted(() => {
-  handleLogin();
-});
+// onMounted(() => {
+//   handleLogin();
+// });
 </script>
 
 <style lang="scss" scoped>

+ 6 - 0
packages/pc/src/views/Detail/components/Reader/index.scss

@@ -6,8 +6,14 @@
   overflow: hidden;
 
   #reader {
+    margin: 0 -40px;
     flex: 1;
     width: 100%;
+    height: 0;
+
+    :deep(.epub-view) {
+      flex: 1;
+    }
   }
 
   .select-menu {

+ 7 - 1
packages/pc/src/views/Detail/components/Reader/index.vue

@@ -2,7 +2,7 @@
   <div class="detail-text" v-loading="bookLoading">
     <div id="reader" />
 
-    <Teleport v-if="selectMenuStyle.visibility === 'visible'" to=".epub-view">
+    <Teleport v-if="selectMenuStyle.visibility === 'visible'" to="#reader">
       <div class="select-menu" :style="selectMenuStyle">
         <div class="select-menu-colors">
           <div
@@ -105,6 +105,12 @@ const bookLoading = ref(true);
 onMounted(async () => {
   await epubStore.init({
     url: baseUrl + props.detail.filePath,
+    renderOptions: {
+      flow: "paginated",
+      manager: "continuous",
+      snap: true,
+      method: "inline",
+    },
     error() {
       ElMessage.error("图书加载失败");
       bookLoading.value = false;