Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Oct 28, 2023
1 parent 7d8c272 commit 767e37d
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 48 deletions.
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if (process.platform != "darwin" && process.argv.length >= 2) {
let options = {
width: 1050,
height: 660,
backgroundColor: "#fff",
webPreferences: {
webSecurity: false,
nodeIntegration: true,
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koodo-reader",
"main": "main.js",
"version": "1.5.9",
"version": "1.6.0",
"description": "A cross-platform ebook reader",
"author": {
"name": "App by Troye",
Expand All @@ -22,15 +22,16 @@
"adm-zip": "^0.5.2",
"axios": "^0.19.2",
"bing-translate-api": "^2.7.0",
"buffer": "^6.0.3",
"copy-text-to-clipboard": "^2.2.0",
"dompurify": "^3.0.1",
"electron-is-dev": "^1.1.0",
"electron-store": "^8.0.1",
"epub-cfi-resolver": "^1.0.2",
"fast-average-color": "^9.4.0",
"font-list": "^1.4.5",
"fs-extra": "^9.1.0",
"howler": "^2.2.3",
"iconv-lite": "^0.6.3",
"react-hot-toast": "^2.1.1",
"request": "^2.88.2",
"webdav": "^3.6.2",
Expand All @@ -41,6 +42,7 @@
},
"devDependencies": {
"@types/i18next": "^13.0.0",
"@types/iconv-lite": "^0.0.1",
"@types/md5": "^2.2.0",
"@types/node": "^13.13.2",
"@types/react": "17.0.2",
Expand Down
10 changes: 5 additions & 5 deletions public/lib/kookit/kookit.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/bookCardItem/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class BookCardItem extends React.Component<BookCardProps, BookCardState> {
: "00"}
{Math.floor(parseFloat(percentage) * 100) > 0 &&
Math.floor(parseFloat(percentage) * 100) < 100 && (
<span className="reading-percentage-char">%</span>
<span>%</span>
)}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/bookCoverItem/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class BookCoverItem extends React.Component<BookCoverProps, BookCoverState> {
: "00"}
{Math.floor(parseFloat(percentage) * 100) > 0 &&
Math.floor(parseFloat(percentage) * 100) < 100 && (
<span className="reading-percentage-char">%</span>
<span>%</span>
)}
</div>
</div>
Expand Down
28 changes: 2 additions & 26 deletions src/components/dialogs/detailDialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { DetailDialogProps, DetailDialogState } from "./interface";
import { Trans } from "react-i18next";
import Parser from "html-react-parser";
import * as DOMPurify from "dompurify";
import { FastAverageColor } from "fast-average-color";
import EmptyCover from "../../emptyCover";
class DetailDialog extends React.Component<
DetailDialogProps,
Expand All @@ -13,23 +12,10 @@ class DetailDialog extends React.Component<
constructor(props: DetailDialogProps) {
super(props);
this.state = {
backgroundColor: "",
textColor: "",
backgroundColor: "#333",
textColor: "#333",
};
}
componentDidMount() {
const fac = new FastAverageColor();

// From not loaded image (HTMLImageElement)
fac
.getColorAsync(this.props.currentBook.cover, { algorithm: "dominant" })
.then((color) => {
this.setState({ textColor: color.isDark ? "#fff" : "#333" });
})
.catch((e) => {
console.error(e);
});
}
handleClose = () => {
this.props.handleDetailDialog(false);
};
Expand All @@ -39,16 +25,6 @@ class DetailDialog extends React.Component<
className="download-desk-container"
style={{ color: this.state.textColor }}
>
<div className="detail-cover-background-container">
<div
className="detail-cover-background"
style={{
// background: this.state.backgroundColor,

backgroundImage: 'url("' + this.props.currentBook.cover + '")',
}}
></div>
</div>
<div
className="detail-dialog-book-info"
style={{
Expand Down
6 changes: 4 additions & 2 deletions src/containers/htmlViewer/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,17 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
}px)`,
paddingLeft: "20px",
paddingRight: "15px",
left: 0,
right: 0,
}
: this.state.readerMode === "single"
? {
left: `calc(50vw - ${
270 * parseFloat(this.state.scale)
}px + 15px)`,
}px + 30px)`,
right: `calc(50vw - ${
270 * parseFloat(this.state.scale)
}px + 15px)`,
}px + 30px)`,
}
: this.state.readerMode === "double"
? {
Expand Down
2 changes: 1 addition & 1 deletion src/containers/lists/navList/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class NavList extends React.Component<NavListProps, NavListState> {
cfi: cfi,
};
}
//compatile wiht lower version(1.5.1)
//compatile with lower version(1.5.1)
if (bookLocation.cfi) {
await this.props.htmlBook.rendition.goToChapter(
bookLocation.chapterDocIndex,
Expand Down
14 changes: 10 additions & 4 deletions src/utils/fileUtils/bookUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import BookModel from "../../model/Book";
import toast from "react-hot-toast";
import { getPDFMetadata } from "./pdfUtil";
import { copyArrayBuffer } from "../commonUtil";
import iconv from "iconv-lite";
import { Buffer } from "buffer";
declare var window: any;

class BookUtil {
Expand Down Expand Up @@ -246,9 +248,10 @@ class BookUtil {
} else if (format === "EPUB") {
rendition = new window.Kookit.EpubRender(result, readerMode);
} else if (format === "TXT") {
rendition = new window.Kookit.TxtRender(result, readerMode, charset);
let text = iconv.decode(Buffer.from(result), "gb2312" || "utf8");
rendition = new window.Kookit.TxtRender(text, readerMode);
} else if (format === "MD") {
rendition = new window.Kookit.EpubRender(result, readerMode);
rendition = new window.Kookit.MdRender(result, readerMode);
} else if (format === "FB2") {
rendition = new window.Kookit.Fb2Render(result, readerMode);
} else if (format === "DOCX") {
Expand Down Expand Up @@ -372,15 +375,18 @@ class BookUtil {
cover = metadata.cover;
break;
case "txt":
metadata = await rendition.getMetadata();
metadata = await rendition.getMetadata(file_content);
charset = metadata.charset;
break;
default:
break;
}
let format = extension.toUpperCase();
key = new Date().getTime() + "";
if (StorageUtil.getReaderConfig("isPrecacheBook") === "yes") {
if (
StorageUtil.getReaderConfig("isPrecacheBook") === "yes" &&
extension !== "pdf"
) {
let cache = await rendition.preCache(file_content);
if (cache !== "err") {
BookUtil.addBook("cache-" + key, cache);
Expand Down
22 changes: 16 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2970,6 +2970,13 @@
dependencies:
i18next "*"

"@types/iconv-lite@^0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@types/iconv-lite/-/iconv-lite-0.0.1.tgz#aa3b8bda2be512b1ae0a057b942e869c370a5569"
integrity sha512-SsRBQxGw7/2/NxYJfBdiUx5a7Ms/voaUhOO9u2y9FTeTNBO1PXohzE4i3JfD8q2Te42HLTn5pyZtDf8j1bPKgQ==
dependencies:
"@types/node" "*"

"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44"
Expand Down Expand Up @@ -4446,6 +4453,14 @@ buffer@^5.1.0, buffer@^5.5.0:
base64-js "^1.3.1"
ieee754 "^1.1.13"

buffer@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"

builder-util-runtime@9.1.1:
version "9.1.1"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-9.1.1.tgz#2da7b34e78a64ad14ccd070d6eed4662d893bd60"
Expand Down Expand Up @@ -6544,11 +6559,6 @@ extsprintf@^1.2.0:
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.1.tgz#8d172c064867f235c0c84a596806d279bf4bcc07"
integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA==

fast-average-color@^9.4.0:
version "9.4.0"
resolved "https://registry.yarnpkg.com/fast-average-color/-/fast-average-color-9.4.0.tgz#eea0182fa8818ea0c70dcc7a85b945f3c716b11b"
integrity sha512-bvM8vV6YwK07dPbzFz77zJaBcfF6ABVfgNwaxVgXc2G+o0e/tzLCF9WU8Ryp1r0Nkk6JuJNsWCzbb4cLOMlB+Q==

fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
Expand Down Expand Up @@ -7622,7 +7632,7 @@ identity-obj-proxy@^3.0.0:
dependencies:
harmony-reflect "^1.4.6"

ieee754@^1.1.13:
ieee754@^1.1.13, ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
Expand Down

0 comments on commit 767e37d

Please sign in to comment.