Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Apr 15, 2023
1 parent a7ee072 commit 8453625
Show file tree
Hide file tree
Showing 30 changed files with 1,277 additions and 156 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ brew install --cask koodo-reader
docker-compose up -d
```

- Install with Flathub:

```shell
flatpak install io.github.troyeguo.koodo-reader
```

<a href="https://flathub.org/apps/details/io.github.troyeguo.koodo-reader"><img height="50" alt="Download on Flathub" src="https://flathub.org/assets/badges/flathub-badge-en.png"/></a>

## Screenshot
Expand Down
8 changes: 6 additions & 2 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ scoop install dorado/koodo-reader

- 使用 Winget 安装:

-

```shell
winget install -e AppbyTroye.KoodoReader
```
Expand All @@ -82,6 +80,12 @@ brew install --cask koodo-reader
docker-compose up -d
```

- 使用 Flathub 安装:

```shell
flatpak install io.github.troyeguo.koodo-reader
```

<a href="https://flathub.org/apps/details/io.github.troyeguo.koodo-reader"><img height="50" alt="Download on Flathub" src="https://flathub.org/assets/badges/flathub-badge-en.png"/></a>

## 截图
Expand Down
6 changes: 6 additions & 0 deletions README_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ brew install --cask koodo-reader
docker-compose up -d
```

- Instalar Flathub:

```shell
flatpak install io.github.troyeguo.koodo-reader
```

<a href="https://flathub.org/apps/details/io.github.troyeguo.koodo-reader"><img height="50" alt="Download on Flathub" src="https://flathub.org/assets/badges/flathub-badge-en.png"/></a>

## Capturas de tela
Expand Down
11 changes: 5 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
width: 100%;
}
</style>
<script
type="text/javascript"
src="%PUBLIC_URL%/lib/kookit/kookit.min.js"
></script>
<script>
var script = document.createElement("script");
if (document.location.href.indexOf("localhost:3000") > -1) {
script.src = "http://127.0.0.1:5500/dist/kookit.umd.js";
} else {
script.src = "%PUBLIC_URL%/lib/kookit/kookit.min.js";
}
document.head.appendChild(script);
</script>
Expand All @@ -37,10 +39,7 @@

<div id="root"></div>
<canvas id="the-canvas"></canvas>
<!-- <script
type="text/javascript"
src="%PUBLIC_URL%/lib/kookit/kookit.min.js"
></script> -->

<script
type="text/javascript"
src="%PUBLIC_URL%/lib/JSZip/jszip.min.js"
Expand Down
12 changes: 6 additions & 6 deletions public/lib/kookit/kookit.min.js

Large diffs are not rendered by default.

354 changes: 354 additions & 0 deletions src/assets/locales/bn/translation.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/assets/locales/cn/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,6 @@
"Hide books already added to the shelf": "隐藏添加到书架的图书",
"Hide books which have been added to the shelf, so they won't show up in home page": "当把图书添加到书架后,该图书就不会展示在主页书架中",
"Delete book from shelf also deleting book itself": "直接删除从书架中移除的图书",
"When deleting book from shelf, the book will be deleted as well": "在书架中执行删除操作时,不仅会从书架删除,还会直接将其删除到回收站"
"When deleting book from shelf, the book will be deleted as well": "在书架中执行删除操作时,不仅会从书架删除,还会直接将其删除到回收站",
"This action will permanently delete the selected books, together with their notes, bookmarks and digests": "此操作会彻底删除所有选中的图书,以及它们的书签,笔记和高亮"
}
3 changes: 2 additions & 1 deletion src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,6 @@
"Hide books already added to the shelf": "Hide books already added to the shelf",
"Hide books which have been added to the shelf, so they won't show up in home page": "Hide books which have been added to the shelf, so they won't show up in home page",
"Delete book from shelf also deleting book itself": "Delete book from shelf also deleting book itself",
"When deleting book from shelf, the book will be deleted as well": "When deleting book from shelf, the book will be deleted as well"
"When deleting book from shelf, the book will be deleted as well": "When deleting book from shelf, the book will be deleted as well",
"This action will permanently delete the selected books, together with their notes, bookmarks and digests": "此操作会彻底删除所有选中的图书,以及它们的书签,笔记和高亮"
}
354 changes: 354 additions & 0 deletions src/assets/locales/it/translation.json

Large diffs are not rendered by default.

354 changes: 354 additions & 0 deletions src/assets/locales/nl/translation.json

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions src/components/bookCardItem/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ class BookCardItem extends React.Component<BookCardProps, BookCardState> {
!filePath
) {
this.props.handleReadingBook(this.props.book);
if (StorageUtil.getReaderConfig("isOpenInMain") === "yes") {
this.props.history.push(BookUtil.getBookUrl(this.props.book));
} else {
BookUtil.RedirectBook(this.props.book, this.props.t);
}

BookUtil.RedirectBook(this.props.book, this.props.t, this.props.history);
}
}
UNSAFE_componentWillReceiveProps(nextProps: BookCardProps) {
Expand Down Expand Up @@ -115,11 +112,7 @@ class BookCardItem extends React.Component<BookCardProps, BookCardState> {
}
RecentBooks.setRecent(this.props.book.key);
this.props.handleReadingBook(this.props.book);
if (StorageUtil.getReaderConfig("isOpenInMain") === "yes") {
this.props.history.push(BookUtil.getBookUrl(this.props.book));
} else {
BookUtil.RedirectBook(this.props.book, this.props.t);
}
BookUtil.RedirectBook(this.props.book, this.props.t, this.props.history);
};
render() {
let percentage = RecordLocation.getHtmlLocation(this.props.book.key)
Expand Down
12 changes: 2 additions & 10 deletions src/components/bookCoverItem/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ class BookCoverItem extends React.Component<BookCoverProps, BookCoverState> {
!filePath
) {
this.props.handleReadingBook(this.props.book);
if (StorageUtil.getReaderConfig("isOpenInMain") === "yes") {
this.props.history.push(BookUtil.getBookUrl(this.props.book));
} else {
BookUtil.RedirectBook(this.props.book, this.props.t);
}
BookUtil.RedirectBook(this.props.book, this.props.t, this.props.history);
}
}
UNSAFE_componentWillReceiveProps(nextProps: BookCoverProps) {
Expand Down Expand Up @@ -113,11 +109,7 @@ class BookCoverItem extends React.Component<BookCoverProps, BookCoverState> {
}
RecentBooks.setRecent(this.props.book.key);
this.props.handleReadingBook(this.props.book);
if (StorageUtil.getReaderConfig("isOpenInMain") === "yes") {
this.props.history.push(BookUtil.getBookUrl(this.props.book));
} else {
BookUtil.RedirectBook(this.props.book, this.props.t);
}
BookUtil.RedirectBook(this.props.book, this.props.t, this.props.history);
};
render() {
let percentage = RecordLocation.getHtmlLocation(this.props.book.key)
Expand Down
12 changes: 2 additions & 10 deletions src/components/bookListItem/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ class BookListItem extends React.Component<BookItemProps, BookItemState> {
!filePath
) {
this.props.handleReadingBook(this.props.book);
if (StorageUtil.getReaderConfig("isOpenInMain") === "yes") {
this.props.history.push(BookUtil.getBookUrl(this.props.book));
} else {
BookUtil.RedirectBook(this.props.book, this.props.t);
}
BookUtil.RedirectBook(this.props.book, this.props.t, this.props.history);
}
}
UNSAFE_componentWillReceiveProps(nextProps: BookItemProps) {
Expand Down Expand Up @@ -92,11 +88,7 @@ class BookListItem extends React.Component<BookItemProps, BookItemState> {
}
RecentBooks.setRecent(this.props.book.key);
this.props.handleReadingBook(this.props.book);
if (StorageUtil.getReaderConfig("isOpenInMain") === "yes") {
this.props.history.push(BookUtil.getBookUrl(this.props.book));
} else {
BookUtil.RedirectBook(this.props.book, this.props.t);
}
BookUtil.RedirectBook(this.props.book, this.props.t, this.props.history);
};
handleExportBook() {
BookUtil.fetchBook(this.props.book.key, true, this.props.book.path).then(
Expand Down
127 changes: 65 additions & 62 deletions src/components/dialogs/deleteDialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,74 +54,71 @@ class DeleteDialog extends React.Component<
});
};
handleComfirm = async () => {
console.log(this.state.isDisableTrashBin);
//从列表删除和从图书库删除判断
if (this.props.mode === "shelf" && !this.state.isDeleteShelfBook) {
if (this.props.isSelectBook) {
this.props.selectedBooks.forEach((item) => {
ShelfUtil.clearShelf(this.props.shelfIndex, item);
});
this.props.handleSelectedBooks([]);
this.props.handleFetchBooks(false);
this.props.handleSelectBook(!this.props.isSelectBook);
this.props.handleDeleteDialog(false);
toast.success(this.props.t("Delete Successfully"));
return;
}
ShelfUtil.clearShelf(this.props.shelfIndex, this.props.currentBook.key);
this.deleteBookFromShelf();
} else if (this.props.mode === "trash") {
let keyArr = AddTrash.getAllTrash();
for (let i = 0; i < keyArr.length; i++) {
await this.deleteBook(keyArr[i]);
}

if (this.props.books.length === 1) {
this.props.history.push("/manager/empty");
}
this.props.handleFetchBooks(false);
this.props.handleFetchBooks(true);
this.props.handleFetchBookmarks();
this.props.handleFetchNotes();
await this.deleteAllBookInTrash();
} else if (this.state.isDisableTrashBin) {
if (this.props.isSelectBook) {
for (let i = 0; i < this.props.selectedBooks.length; i++) {
await this.deleteBook(this.props.selectedBooks[i]);
AddTrash.setTrash(this.props.selectedBooks[i]);
//从喜爱的图书中删除
AddFavorite.clear(this.props.selectedBooks[i]);
}
this.props.handleSelectedBooks([]);
this.props.handleFetchBooks(false);
this.props.handleSelectBook(!this.props.isSelectBook);
} else {
await this.deleteBook(this.props.currentBook.key);
AddTrash.setTrash(this.props.currentBook.key);
//从喜爱的图书中删除
AddFavorite.clear(this.props.currentBook.key);
}
this.deleteBooks();
await this.deleteAllBookInTrash();
} else {
this.deleteBooks();
}

this.props.handleFetchBooks(false);
this.props.handleFetchBooks(true);
this.props.handleFetchBookmarks();
this.props.handleFetchNotes();
} else if (this.props.isSelectBook) {
this.props.handleDeleteDialog(false);
toast.success(this.props.t("Delete Successfully"));
};
deleteBookFromShelf = () => {
if (this.props.isSelectBook) {
this.props.selectedBooks.forEach((item) => {
AddTrash.setTrash(item);
//从喜爱的图书中删除
AddFavorite.clear(item);
ShelfUtil.clearShelf(this.props.shelfIndex, item);
});
this.props.handleSelectedBooks([]);
this.props.handleFetchBooks(false);
this.props.handleSelectBook(!this.props.isSelectBook);
} else {
AddTrash.setTrash(this.props.currentBook.key);
//从喜爱的图书中删除
AddFavorite.clear(this.props.currentBook.key);
this.props.handleFetchBooks(false);
this.props.handleDeleteDialog(false);
toast.success(this.props.t("Delete Successfully"));
return;
}
ShelfUtil.clearShelf(this.props.shelfIndex, this.props.currentBook.key);
};
deleteAllBookInTrash = async () => {
let keyArr = AddTrash.getAllTrash();
for (let i = 0; i < keyArr.length; i++) {
await this.deleteBook(keyArr[i]);
}

this.props.handleDeleteDialog(false);
toast.success(this.props.t("Delete Successfully"));
if (this.props.books.length === 1) {
this.props.history.push("/manager/empty");
}
this.props.handleFetchBooks(false);
this.props.handleFetchBooks(true);
this.props.handleFetchBookmarks();
this.props.handleFetchNotes();
};
deleteBooks = () => {
if (this.props.isSelectBook) {
this.deleteSelectedBook();
} else {
this.deleteCurrentBook();
}
};
deleteSelectedBook = () => {
this.props.selectedBooks.forEach((item) => {
AddTrash.setTrash(item);
//从喜爱的图书中删除
AddFavorite.clear(item);
});
this.props.handleSelectedBooks([]);
this.props.handleFetchBooks(false);
this.props.handleSelectBook(!this.props.isSelectBook);
};
deleteCurrentBook = () => {
AddTrash.setTrash(this.props.currentBook.key);
//从喜爱的图书中删除
AddFavorite.clear(this.props.currentBook.key);
this.props.handleFetchBooks(false);
};
deleteBook = (key: string) => {
return new Promise<void>((resolve, reject) => {
Expand Down Expand Up @@ -183,22 +180,28 @@ class DeleteDialog extends React.Component<
)}

{this.props.mode === "shelf" && !this.state.isDeleteShelfBook ? (
<div className="delete-dialog-other-option">
<div className="delete-dialog-other-option" style={{ top: "100px" }}>
<Trans>This action won't delete the original book</Trans>
</div>
) : this.props.mode === "trash" || this.state.isDisableTrashBin ? (
) : this.props.mode === "trash" ? (
<div className="delete-dialog-other-option" style={{ top: "80px" }}>
<Trans>
This action will remove all the books in recycle bin,together with
their notes, bookmarks and digests
</Trans>
</div>
) : this.state.isDisableTrashBin ? (
<div className="delete-dialog-other-option" style={{ top: "100px" }}>
<Trans>
This action will permanently delete the selected books, together
with their notes, bookmarks and digests
</Trans>
</div>
) : (
<div className="delete-dialog-other-option">
<div className="delete-dialog-other-option" style={{ top: "100px" }}>
<Trans>
{
"This action will move this book and its the notes, bookmarks and highlights of this book to the recycle bin"
}
This action will move this book and its the notes, bookmarks and
highlights of this book to the recycle bin
</Trans>
</div>
)}
Expand Down
8 changes: 2 additions & 6 deletions src/components/importLocal/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ class ImportLocal extends React.Component<ImportLocalProps, ImportLocalState> {
};
handleJump = (book: BookModel) => {
if (StorageUtil.getReaderConfig("isOpenInMain") === "yes") {
this.props.history.push(BookUtil.getBookUrl(book));
BookUtil.RedirectBook(book, this.props.t, this.props.history);
this.props.handleReadingBook(book);
} else {
localStorage.setItem("tempBook", JSON.stringify(book));
BookUtil.RedirectBook(book, this.props.t);
BookUtil.RedirectBook(book, this.props.t, this.props.history);
this.props.history.push("/manager/home");
}
};
Expand Down Expand Up @@ -173,10 +173,6 @@ class ImportLocal extends React.Component<ImportLocalProps, ImportLocalState> {
if (
[...(this.props.books || []), ...this.props.deletedBooks].length > 0
) {
console.log(
[...(this.props.books || []), ...this.props.deletedBooks],
md5
);
[...(this.props.books || []), ...this.props.deletedBooks].forEach(
(item) => {
if (item.md5 === md5 && item.size === file.size) {
Expand Down
3 changes: 1 addition & 2 deletions src/components/popups/popupMenu/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ class PopupMenu extends React.Component<PopupMenuProps, PopupMenuStates> {
if (!highlighters) return;
let highlightersByChapter = highlighters.filter((item: any) => {
return (
(item.chapterDocIndex === this.props.chapterDocIndex ||
item.chapter === this.props.chapter) &&
item.chapterIndex === this.props.chapterDocIndex &&
item.bookKey === this.props.currentBook.key
);
});
Expand Down
4 changes: 4 additions & 0 deletions src/constants/settingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export const langList = [
{ label: "한국어", value: "ko" },
{ label: "Polski", value: "pl" },
{ label: "Română", value: "ro" },
{ label: "แบบไทย", value: "th" },
{ label: "italiano", value: "it" },
{ label: "Nederlands", value: "nl" },
{ label: "বাংলা", value: "bn" },
];

export const searchList = [
Expand Down
Loading

0 comments on commit 8453625

Please sign in to comment.