From d2be69a4ef2f9a844e02a740656cb628ea40b040 Mon Sep 17 00:00:00 2001 From: troyeguo <13820674+troyeguo@users.noreply.github.com> Date: Sat, 30 Oct 2021 15:55:41 +0800 Subject: [PATCH] fix bug Former-commit-id: 16b7a55b17466fd2ff43c8ea2ca8a039de3b941c --- README.md | 4 ++-- README_cn.md | 4 ++-- public/index.html | 2 +- public/lib/kookit/kookit.umd.js | 2 +- src/constants/driveList.tsx | 2 +- src/containers/htmlViewer/component.tsx | 8 ++++++++ src/containers/lists/contentList/component.tsx | 4 +++- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index dfa49596..d02f4b5c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@
-[Download](https://koodo.960960.xyz/en/download) | [Preview](https://koodo-reader.vercel.app/) | [Roadmap](https://troyeguo.notion.site/d1c19a132932465bae1d89dd963c92ea?v=ca8aa69cf25849c18c92b92ba868663b) | [Document](https://troyeguo.notion.site/Koodo-Reader-Document-9c767af3d66c459db996bdd08a34c34b) +[Download](https://koodo.960960.xyz/en/download) | [Preview](https://koodo-reader.vercel.app) | [Roadmap](https://troyeguo.notion.site/d1c19a132932465bae1d89dd963c92ea?v=ca8aa69cf25849c18c92b92ba868663b) | [Document](https://troyeguo.notion.site/Koodo-Reader-Document-9c767af3d66c459db996bdd08a34c34b)
@@ -58,7 +58,7 @@ - Desktop Version: - Stable Version (Recommended): [Download](https://koodo.960960.xyz/en/download) - Developer Version: [Download](https://github.com/troyeguo/koodo-reader/releases/latest) ( With new feature and bug fix, but may induce some unknown bugs) -- Web Version:[Preview](https://koodo-reader.vercel.app/) +- Web Version:[Preview](https://koodo-reader.vercel.app) - Install with Homebrew: ```shell diff --git a/README_cn.md b/README_cn.md index 6e64dd81..d86e9053 100644 --- a/README_cn.md +++ b/README_cn.md @@ -18,7 +18,7 @@
-[下载](https://koodo.960960.xyz/zh/download) | [预览](https://koodo-reader.vercel.app/) | [计划](https://troyeguo.notion.site/215baeda57804fd29dbb0e91d1e6a021?v=360c00183d944b598668f34c255edfd7) | [文档](https://troyeguo.notion.site/Koodo-Reader-0c9c7ccdc5104a54825dfc72f1c84bea) +[下载](https://koodo.960960.xyz/zh/download) | [预览](https://koodo-reader.vercel.app) | [计划](https://troyeguo.notion.site/215baeda57804fd29dbb0e91d1e6a021?v=360c00183d944b598668f34c255edfd7) | [文档](https://troyeguo.notion.site/Koodo-Reader-0c9c7ccdc5104a54825dfc72f1c84bea)
@@ -58,7 +58,7 @@ - 桌面端: - 稳定版 (推荐下载):[官网](https://koodo.960960.xyz/zh/download)(感谢 [GitHub Proxy](https://ghproxy.com/) 提供下载加速服务) - 开发版:[Github Release](https://github.com/troyeguo/koodo-reader/releases/latest) (包含新功能和 bug 修复,但也可能引入更多未知 bug) -- 网页版:[前往](https://koodo-reader.vercel.app/) +- 网页版:[前往](https://koodo-reader.vercel.app) - 使用 Homebrew 安装: ```shell diff --git a/public/index.html b/public/index.html index a739cd47..f0016543 100644 --- a/public/index.html +++ b/public/index.html @@ -3,7 +3,7 @@ - + s[0]&&e[1]":">",'"':""","'":"'","`":"`"},qt=Rt($t),Vt=Rt(Lt($t)),Xt=ot.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Jt=/(.)^/,Yt={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Zt=/\\|'|\r|\n|\u2028|\u2029/g;function Gt(t){return"\\"+Yt[t]}var Qt=/^\s*(\w|\$)+\s*$/;var te=0;function ee(t,e,n,r,i){if(!(r instanceof e))return t.apply(n,i);n=At(t.prototype),i=t.apply(n,i);return T(i)?i:n}var ne=D(function(i,o){function s(){for(var t=0,e=o.length,n=Array(e),r=0;ri.clientHeight+i.offsetTop?e:i),Pe.isElement(o)&&o.clientHeight+o.offsetTop>s.clientHeight+s.offsetTop&&(s=o);i=0;(n||s||r)&&(3!==r.nodeType||n||s)&&(3===r.nodeType&&document.createRange&&((o=document.createRange()).selectNodeContents(r),!o.getBoundingClientRect||(o=o.getBoundingClientRect())&&(i=o.bottom-o.top)),t.height=Math.max(Pe.isElement(n)?n.clientHeight+n.offsetTop:0,Pe.isElement(r)?r.clientHeight+r.offsetTop:0,Pe.isElement(s)?s.clientHeight+s.offsetTop:0)+600+(3===r.nodeType?i:0))},500)):r.height=t.offsetHeight}function Ge(t){var e=document.createElement("iframe");e.style.width=t.offsetWidth+"px",e.style.border="0",e.style.margin="0",e.style.padding="0",e.style.fontSize="100%",e.style.font="inherit",e.style.verticalAlign="baseline",t.appendChild(e)}function Qe(e,n,r,i){var t=document.getElementsByTagName("iframe")[0];!t||(t=t.contentDocument)&&(-1t.offsetHeight/((t.offsetWidth-88)/o)?i=(r=t.offsetHeight)*a.width/a.height:r=(i=(t.offsetWidth-88)/o)*a.height/a.width:(i=(t.offsetWidth-88)/o,r=t.offsetHeight),a.setAttribute("style","max-width: "+i+"px;max-height:"+r+"px")}}}function rn(t,e,n,r){void 0===r&&(r="0");var i,o,s=(n=void 0===n?"":n)||Je.getKookitConfig("text")||"";s?(n=(o=(i=Array.from(window.frames[0].document.body.getElementsByTagName("*"))).filter(function(t){return t.innerText===s}))[0],1=t.scrollTop&&i<=t.scrollTop+t.offsetHeight),r},cn=function(t,e,n,r){void 0===t&&(t=""),window.frames[0].document.body.innerHTML="",window.frames[0].document.body.innerHTML=e[-1===Pe.findIndex(e,{title:t})?0:Pe.findIndex(e,{title:t})].text,Je.setKookitConfig("chapterTitle",t),Ze(n,r),nn(n,r),rn(n,r)},hn=function(t,e,n,r){var i=Je.getKookitConfig("chapterTitle"),i=Pe.findIndex(e,{label:i});0!==i&&-1!==i&&(Je.setKookitConfig("chapterTitle",e[i-1].label),cn(e[i-1].label,n,t,r))},fn=(ln.prototype.getChapterDoc=function(){for(var t=-1")?this.bookStr.split(""):this.bookStr.split("
"),e=[],n=[],r="",i=0;i "),e=0;e=this.capacity)&&(this.buffer[this.size]=t,this.size+=1,!0)},wn.prototype.full=function(){return this.size===this.capacity},wn.prototype.get=function(t){return this.buffer[t]},wn);function wn(t){this.buffer=new Uint8Array(t),this.capacity=t,this.size=0}var Ln=(Dn.prototype.parse=function(){},Dn.prototype.getUint8=function(){var t=this.view.getUint8(this.offset);return this.offset+=1,t},Dn.prototype.getUint16=function(){var t=this.view.getUint16(this.offset);return this.offset+=2,t},Dn.prototype.getUint32=function(){var t=this.view.getUint32(this.offset);return this.offset+=4,t},Dn.prototype.getStr=function(t){var e=mn(this.buffer.slice(this.offset,this.offset+t));return this.offset+=t,e},Dn.prototype.skip=function(t){this.offset+=t},Dn.prototype.setoffset=function(t){this.offset=t},Dn.prototype.get_record_extrasize=function(t,e){for(var n,r,i,o=t.length-1,s=0,u=15;0>3&2047,a=3+(7&s),c=r.size(),h=0;hpagebreak"),e=[],n=0;n"+o+""):e+="

"+o+"

")}return e}(e),this.bookStr=e,this.element=r,e=new kn(this.bookStr),this.chapterList=e.getChapter(),this.chapterDocList=e.getChapterDoc(),e=Je.getKookitConfig("chapterTitle")||this.chapterDocList[0].title,e=-1===Pe.findIndex(this.chapterDocList,{title:e})?0:Pe.findIndex(this.chapterDocList,{title:e}),Ge(r),window.frames[0].document.body.innerHTML=this.chapterDocList[e].text,Je.setKookitConfig("chapterTitle",this.chapterDocList[e].title),on(r,this.mode),Ze(r,this.mode),rn(r,this.mode),Qe(r,this.chapterList,this.chapterDocList,this.mode),n(),[2]})})})},An.prototype.getChapter=function(){return this.chapterList},An.prototype.goToChapter=function(t){cn(t,this.chapterDocList,this.element,this.mode)},An.prototype.goToPosition=function(t,e,n){cn(e,this.chapterDocList,this.element,this.mode),rn(this.element,this.mode,t,n)},An.prototype.prevPage=function(){0===window.frames[0].document.body.scrollLeft?hn(this.element,this.chapterList,this.chapterDocList,this.mode):sn(this.element,this.chapterList,this.chapterDocList,this.mode,1)},An.prototype.nextPage=function(){Math.abs(window.frames[0].document.body.scrollWidth-window.frames[0].document.body.scrollLeft-window.frames[0].document.body.clientWidth)<10?tn(this.element,this.chapterList,this.chapterDocList,this.mode):sn(this.element,this.chapterList,this.chapterDocList,this.mode,-1)},An.prototype.getPosition=function(){return{text:Je.getKookitConfig("text"),chapterTitle:Je.getKookitConfig("chapterTitle"),count:Je.getKookitConfig("count")}},An.prototype.setStyle=function(t){window.frames[0].document.body.setAttribute("style",t+window.frames[0].document.body.getAttribute("style"))},$t=An;function An(t,e,n){void 0===n&&(n="utf-8"),this.txtBuffer=t,this.encoding=n,this.mode=e,this.chapterList=[],this.chapterDocList=[],this.bookStr="",this.element=""}t.Azw3Render=P,t.MobiRender=mt,t.StrRender=dt,t.TxtRender=$t,Object.defineProperty(t,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Kookit={})}(this,function(t){"use strict";function o(t,s,u,a){return new(u=u||Promise)(function(n,e){function r(t){try{o(a.next(t))}catch(t){e(t)}}function i(t){try{o(a.throw(t))}catch(t){e(t)}}function o(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(r,i)}o((a=a.apply(t,s||[])).next())})}function s(n,r){var i,o,s,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,(e=s?[2&e[0],s.value]:e)[0]){case 0:case 1:s=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,o=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]":">",'"':""","'":"'","`":"`"},qt=Rt($t),Vt=Rt(Lt($t)),Xt=ot.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Jt=/(.)^/,Yt={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Zt=/\\|'|\r|\n|\u2028|\u2029/g;function Gt(t){return"\\"+Yt[t]}var Qt=/^\s*(\w|\$)+\s*$/;var te=0;function ee(t,e,n,r,i){if(!(r instanceof e))return t.apply(n,i);n=At(t.prototype),i=t.apply(n,i);return D(i)?i:n}var ne=T(function(i,o){function s(){for(var t=0,e=o.length,n=Array(e),r=0;ri.clientHeight+i.offsetTop?e:i),Pe.isElement(o)&&o.clientHeight+o.offsetTop>s.clientHeight+s.offsetTop&&(s=o);i=0;(n||s||r)&&(3!==r.nodeType||n||s)&&(3===r.nodeType&&document.createRange&&((o=document.createRange()).selectNodeContents(r),!o.getBoundingClientRect||(o=o.getBoundingClientRect())&&(i=o.bottom-o.top)),t.height=Math.max(Pe.isElement(n)?n.clientHeight+n.offsetTop:0,Pe.isElement(r)?r.clientHeight+r.offsetTop:0,Pe.isElement(s)?s.clientHeight+s.offsetTop:0)+600+(3===r.nodeType?i:0))},500)):r.height=t.offsetHeight}function Ge(t){var e=document.createElement("iframe");e.style.width=t.offsetWidth+"px",e.style.border="0",e.style.margin="0",e.style.padding="0",e.style.fontSize="100%",e.style.font="inherit",e.style.verticalAlign="baseline",t.innerHTML="",t.appendChild(e)}function Qe(e,n,r,i){var t=document.getElementsByTagName("iframe")[0];!t||(t=t.contentDocument)&&(-1t.offsetHeight/((t.offsetWidth-88)/o)?i=(r=t.offsetHeight)*a.width/a.height:r=(i=(t.offsetWidth-88)/o)*a.height/a.width:(i=(t.offsetWidth-88)/o,r=t.offsetHeight),a.setAttribute("style","max-width: "+i+"px;max-height:"+r+"px")}}}function rn(t,e,n,r){void 0===r&&(r="0");var i,o,s=(n=void 0===n?"":n)||Je.getKookitConfig("text")||"";s?(n=(o=(i=Array.from(window.frames[0].document.body.getElementsByTagName("*"))).filter(function(t){return t.innerText===s}))[0],1=t.scrollTop&&i<=t.scrollTop+t.offsetHeight),r},cn=function(t,e,n,r){void 0===t&&(t=""),window.frames[0].document.body.innerHTML="",window.frames[0].document.body.innerHTML=e[-1===Pe.findIndex(e,{title:t})?0:Pe.findIndex(e,{title:t})].text,Je.setKookitConfig("chapterTitle",t),Ze(n,r),nn(n,r),rn(n,r)},hn=function(t,e,n,r){var i=Je.getKookitConfig("chapterTitle"),i=Pe.findIndex(e,{label:i});0!==i&&-1!==i&&(Je.setKookitConfig("chapterTitle",e[i-1].label),cn(e[i-1].label,n,t,r))},fn=(ln.prototype.getChapterDoc=function(){for(var t=-1")?this.bookStr.split(""):this.bookStr.split("
"),e=[],n=[],r="",i=0;i "),e=0;e=this.capacity)&&(this.buffer[this.size]=t,this.size+=1,!0)},wn.prototype.full=function(){return this.size===this.capacity},wn.prototype.get=function(t){return this.buffer[t]},wn);function wn(t){this.buffer=new Uint8Array(t),this.capacity=t,this.size=0}var Ln=(Tn.prototype.parse=function(){},Tn.prototype.getUint8=function(){var t=this.view.getUint8(this.offset);return this.offset+=1,t},Tn.prototype.getUint16=function(){var t=this.view.getUint16(this.offset);return this.offset+=2,t},Tn.prototype.getUint32=function(){var t=this.view.getUint32(this.offset);return this.offset+=4,t},Tn.prototype.getStr=function(t){var e=mn(this.buffer.slice(this.offset,this.offset+t));return this.offset+=t,e},Tn.prototype.skip=function(t){this.offset+=t},Tn.prototype.setoffset=function(t){this.offset=t},Tn.prototype.get_record_extrasize=function(t,e){for(var n,r,i,o=t.length-1,s=0,u=15;0>3&2047,a=3+(7&s),c=r.size(),h=0;hpagebreak"),e=[],n=0;n"+o+""):e+="

"+o+"

")}return e}(e),this.bookStr=e,this.element=r,e=new kn(this.bookStr),this.chapterList=e.getChapter(),this.chapterDocList=e.getChapterDoc(),e=Je.getKookitConfig("chapterTitle")||this.chapterDocList[0].title,e=-1===Pe.findIndex(this.chapterDocList,{title:e})?0:Pe.findIndex(this.chapterDocList,{title:e}),Ge(r),window.frames[0].document.body.innerHTML=this.chapterDocList[e].text,Je.setKookitConfig("chapterTitle",this.chapterDocList[e].title),on(r,this.mode),Ze(r,this.mode),rn(r,this.mode),Qe(r,this.chapterList,this.chapterDocList,this.mode),n(),[2]})})})},An.prototype.getChapter=function(){return this.chapterList},An.prototype.goToChapter=function(t){cn(t,this.chapterDocList,this.element,this.mode)},An.prototype.goToPosition=function(t,e,n){cn(e,this.chapterDocList,this.element,this.mode),rn(this.element,this.mode,t,n)},An.prototype.prevPage=function(){0===window.frames[0].document.body.scrollLeft?hn(this.element,this.chapterList,this.chapterDocList,this.mode):sn(this.element,this.chapterList,this.chapterDocList,this.mode,1)},An.prototype.nextPage=function(){Math.abs(window.frames[0].document.body.scrollWidth-window.frames[0].document.body.scrollLeft-window.frames[0].document.body.clientWidth)<10?tn(this.element,this.chapterList,this.chapterDocList,this.mode):sn(this.element,this.chapterList,this.chapterDocList,this.mode,-1)},An.prototype.getPosition=function(){return{text:Je.getKookitConfig("text"),chapterTitle:Je.getKookitConfig("chapterTitle"),count:Je.getKookitConfig("count")}},An.prototype.setStyle=function(t){window.frames[0].document.body.setAttribute("style",t+window.frames[0].document.body.getAttribute("style"))},$t=An;function An(t,e,n){void 0===n&&(n="utf-8"),this.txtBuffer=t,this.encoding=n,this.mode=e,this.chapterList=[],this.chapterDocList=[],this.bookStr="",this.element=""}t.Azw3Render=P,t.MobiRender=mt,t.StrRender=dt,t.TxtRender=$t,Object.defineProperty(t,"__esModule",{value:!0})}); diff --git a/src/constants/driveList.tsx b/src/constants/driveList.tsx index 50c7ca80..eb9ab338 100644 --- a/src/constants/driveList.tsx +++ b/src/constants/driveList.tsx @@ -1,7 +1,7 @@ export const config = { callback_url: process.env.NODE_ENV === "production" - ? "https://koodo-reader.vercel.app/" + ? "https://koodo-reader.vercel.app" : "http://localhost:3000", token_url: process.env.NODE_ENV === "production" diff --git a/src/containers/htmlViewer/component.tsx b/src/containers/htmlViewer/component.tsx index a3e5aeef..c955ec47 100644 --- a/src/containers/htmlViewer/component.tsx +++ b/src/containers/htmlViewer/component.tsx @@ -42,6 +42,14 @@ class Viewer extends React.Component { this.handleRenderBook(); this.props.handleRenderFunc(this.handleRenderBook); + var doit; + window.addEventListener("resize", () => { + if (StorageUtil.getReaderConfig("readerMode") === "single") { + return; + } + clearTimeout(doit); + doit = setTimeout(this.handleRenderBook, 100); + }); } handleRenderBook = () => { let { key, path, format, name } = this.props.currentBook; diff --git a/src/containers/lists/contentList/component.tsx b/src/containers/lists/contentList/component.tsx index 030dfa08..e961e73a 100644 --- a/src/containers/lists/contentList/component.tsx +++ b/src/containers/lists/contentList/component.tsx @@ -82,7 +82,9 @@ class ContentList extends React.Component { onClick={this.handleJump} className="book-content-name" > - {item.label} + {item.label.indexOf("#") > -1 + ? item.label.split("#")[0] + : item.label} {item.subitems.length > 0 && (this.state.currentIndex === index ||