mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2026-06-19 13:20:50 -04:00
fix bug
Former-commit-id: 078ce19e042b9ac368de0f112d2ec2842f17e84b
This commit is contained in:
@@ -8,11 +8,7 @@ import iconv from "iconv-lite";
|
||||
import chardet from "chardet";
|
||||
import rtfToHTML from "@iarna/rtf-to-html";
|
||||
import PopupMenu from "../../components/popups/popupMenu";
|
||||
import {
|
||||
xmlBookTagFilter,
|
||||
xmlBookToObj,
|
||||
xmlImageHandler,
|
||||
} from "../../utils/fileUtils/xmlUtil";
|
||||
import { xmlBookParser } from "../../utils/fileUtils/xmlUtil";
|
||||
import StorageUtil from "../../utils/storageUtil";
|
||||
import RecordLocation from "../../utils/readUtils/recordLocation";
|
||||
import { mimetype } from "../../constants/mimetype";
|
||||
@@ -162,9 +158,9 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
|
||||
if (this.props.currentBook.format.startsWith("CB")) {
|
||||
this.setState({
|
||||
chapter:
|
||||
this.props.htmlBook.chapters[parseInt(bookLocation.count || "0")]
|
||||
this.props.htmlBook.chapters[parseInt(bookLocation.count) || 0]
|
||||
.label,
|
||||
chapterIndex: parseInt(bookLocation.count || "0"),
|
||||
chapterIndex: parseInt(bookLocation.count) || 0,
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
@@ -217,7 +213,7 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
|
||||
);
|
||||
await rendition.renderTo(
|
||||
document.getElementsByClassName("html-viewer-page")[0],
|
||||
parseInt(bookLocation.count || "0")
|
||||
parseInt(bookLocation.count) || 0
|
||||
);
|
||||
this.handleRest(rendition);
|
||||
};
|
||||
@@ -236,7 +232,7 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
|
||||
);
|
||||
await rendition.renderTo(
|
||||
document.getElementsByClassName("html-viewer-page")[0],
|
||||
parseInt(bookLocation.count || "0")
|
||||
parseInt(bookLocation.count) || 0
|
||||
);
|
||||
this.handleRest(rendition);
|
||||
});
|
||||
@@ -256,7 +252,7 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
|
||||
);
|
||||
await rendition.renderTo(
|
||||
document.getElementsByClassName("html-viewer-page")[0],
|
||||
parseInt(bookLocation.count || "0")
|
||||
parseInt(bookLocation.count) || 0
|
||||
);
|
||||
this.handleRest(rendition);
|
||||
},
|
||||
@@ -394,9 +390,8 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
|
||||
Buffer.from(result),
|
||||
this.props.currentBook.charset || charset || "utf8"
|
||||
);
|
||||
let bookObj = "";
|
||||
bookObj += xmlBookTagFilter(Buffer.from(result), fb2Str);
|
||||
|
||||
let bookObj = xmlBookParser(Buffer.from(result), fb2Str);
|
||||
console.log(bookObj);
|
||||
let rendition = new StrRender(
|
||||
bookObj,
|
||||
this.state.readerMode,
|
||||
|
||||
@@ -12,7 +12,7 @@ class LoadingPage extends React.Component<LoadingPageProps> {
|
||||
let arr: number[] = [];
|
||||
for (
|
||||
let i = 0;
|
||||
i < parseInt(StorageUtil.getReaderConfig("totalBooks") || "0");
|
||||
i < parseInt(StorageUtil.getReaderConfig("totalBooks")) || 0;
|
||||
i++
|
||||
) {
|
||||
arr.push(i);
|
||||
|
||||
@@ -31,8 +31,7 @@ class Manager extends React.Component<ManagerProps, ManagerState> {
|
||||
constructor(props: ManagerProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
totalBooks:
|
||||
parseInt(StorageUtil.getReaderConfig("totalBooks") || "0") || 0,
|
||||
totalBooks: parseInt(StorageUtil.getReaderConfig("totalBooks")) || 0,
|
||||
favoriteBooks: Object.keys(AddFavorite.getAllFavorite()).length,
|
||||
isAuthed: false,
|
||||
isError: false,
|
||||
|
||||
@@ -34,7 +34,7 @@ export const xmlBookToObj = (xml) => {
|
||||
return informBook;
|
||||
};
|
||||
|
||||
export const xmlBookTagFilter = (xml: any, bookString: string) => {
|
||||
export const xmlBookParser = (xml: any, bookString: string) => {
|
||||
var regExpTagDelete = /<epigraph>|<\/epigraph>|<empty-line\/>|/gi;
|
||||
var regExpTitleOpen = /<title>/gi;
|
||||
var regExpTitleClose = /<\/title>/gi;
|
||||
@@ -67,7 +67,7 @@ export const xmlImageHandler = (xml: any, bookString: string) => {
|
||||
for (let j = 0; j < fictionBook.binary.length; j++) {
|
||||
if (strArr[i].startsWith(fictionBook.binary[j]["$"].id)) {
|
||||
strArr[i] =
|
||||
'<img alt="poster" src="' +
|
||||
'<img alt="poster" width="100%" src="' +
|
||||
"data:image/jpeg;base64," +
|
||||
fictionBook.binary[j]["_"] +
|
||||
strArr[i].slice(fictionBook.binary[j]["$"].id.length);
|
||||
|
||||
Reference in New Issue
Block a user