- {this.state.isChinese ? (
+ {this.state.language === "cn" ? (
this.changeLanguage("tw")}
+ >
+ ) : this.state.language === "en" ? (
+
this.changeLanguage("cn")}
>
) : (
diff --git a/src/containers/header/header.css b/src/containers/header/header.css
index 0193fbaf..55467223 100644
--- a/src/containers/header/header.css
+++ b/src/containers/header/header.css
@@ -108,3 +108,9 @@
color: rgba(75, 75, 75, 1);
cursor: pointer;
}
+.icon-traditional,
+.icon-simplified,
+.icon-english {
+ font-size: 25px;
+ color: rgba(75, 75, 75, 1);
+}
diff --git a/src/containers/header/interface.tsx b/src/containers/header/interface.tsx
index a06c7a15..1f1a38d1 100644
--- a/src/containers/header/interface.tsx
+++ b/src/containers/header/interface.tsx
@@ -13,6 +13,6 @@ export interface HeaderProps {
export interface HeaderState {
isOnlyLocal: boolean;
isBookImported: boolean;
- isChinese: boolean;
+ language:string;
isNewVersion: boolean;
}
diff --git a/src/containers/navigationPanel/component.tsx b/src/containers/navigationPanel/component.tsx
index dc23dacf..22527de1 100644
--- a/src/containers/navigationPanel/component.tsx
+++ b/src/containers/navigationPanel/component.tsx
@@ -103,7 +103,7 @@ class NavigationPanel extends React.Component<
{this.state.isContentShow ? (
- ) : this.props.bookmarks !== null ? (
+ ) : this.props.bookmarks ? (
) : (
diff --git a/src/containers/noteList/component.tsx b/src/containers/noteList/component.tsx
index 94a9d6fc..40ced5cc 100644
--- a/src/containers/noteList/component.tsx
+++ b/src/containers/noteList/component.tsx
@@ -52,7 +52,7 @@ class NoteList extends React.Component {
//获取笔记日期列表
for (let i = 1; i < noteArr.length; i++) {
if (
- noteArr[i].date !== undefined &&
+ noteArr[i].date &&
(noteArr[i].date.year !== temp.year ||
noteArr[i].date.month !== temp.month ||
noteArr[i].date.day !== temp.day)
@@ -89,7 +89,7 @@ class NoteList extends React.Component {
{
this.handleShowDelete(item.key);
}}
@@ -117,7 +117,7 @@ class NoteList extends React.Component {
: {}
}
>
- {isCurrent ? "Less" : "More"}
+ {isCurrent ? "Less" : "More Notes"}
{isCurrent ? null : (
diff --git a/src/containers/noteList/noteList.css b/src/containers/noteList/noteList.css
index a01e7c4e..8ba1852a 100644
--- a/src/containers/noteList/noteList.css
+++ b/src/containers/noteList/noteList.css
@@ -132,12 +132,11 @@
white-space: nowrap;
white-space: normal;
word-break: break-all;
- color: rgba(191, 191, 191, 1);
+ color: rgba(75, 75, 75, 1);
margin-right: 20px !important;
margin-top: 5px;
float: right;
font-size: 15px;
- color: rgba(155, 155, 155, 1);
}
.note-list-item-text {
/* text-align: right; */
diff --git a/src/containers/operationPanel/component.tsx b/src/containers/operationPanel/component.tsx
index fe669bf9..803e14df 100644
--- a/src/containers/operationPanel/component.tsx
+++ b/src/containers/operationPanel/component.tsx
@@ -86,7 +86,7 @@ class OperationPanel extends React.Component<
return item.spinePos > this.props.currentEpub.spinePos;
});
let chapter = "未知章节";
- if (this.props.chapters[index] !== undefined) {
+ if (this.props.chapters[index]) {
chapter = this.props.chapters[index].label.trim(" ");
}
let bookmark = new Bookmark(bookKey, cfi, label, percentage, chapter);
diff --git a/src/containers/popupMenu/component.tsx b/src/containers/popupMenu/component.tsx
index 70a21378..b86ebc11 100644
--- a/src/containers/popupMenu/component.tsx
+++ b/src/containers/popupMenu/component.tsx
@@ -110,7 +110,7 @@ class PopupMenu extends React.Component
{
this.highlighter && this.highlighter.removeAllHighlights(); // 为了避免下次反序列化失败,必须先清除已有的高亮
let classes = ["color-0", "color-1", "color-2", "color-3"];
- highlightersByChapter !== null &&
+ highlightersByChapter &&
highlightersByChapter.forEach((item) => {
this.key = item.key;
//控制渲染指定图书的指定高亮
diff --git a/src/containers/progressPanel/component.tsx b/src/containers/progressPanel/component.tsx
index cf012bf1..33c863ab 100644
--- a/src/containers/progressPanel/component.tsx
+++ b/src/containers/progressPanel/component.tsx
@@ -11,8 +11,7 @@ class ProgressPanel extends React.Component<
constructor(props: ProgressPanelProps) {
super(props);
this.state = {
- displayPercentage:
- this.props.percentage !== undefined ? this.props.percentage : 0,
+ displayPercentage: this.props.percentage ? this.props.percentage : 0,
};
}
//WARNING! To be deprecated in React v17. Use componentDidMount instead.
diff --git a/src/containers/sidebar/sidebar.css b/src/containers/sidebar/sidebar.css
index 56829569..e564f99b 100644
--- a/src/containers/sidebar/sidebar.css
+++ b/src/containers/sidebar/sidebar.css
@@ -63,16 +63,13 @@
}
.shelf-list-container-parent {
margin-top: 20px;
- height: 120px;
- width: 100%;
- overflow: hidden;
+ height: 140px;
+ width: 80%;
}
.shelf-list-container {
width: 100%;
height: 100%;
overflow-y: scroll;
- padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
- box-sizing: content-box;
list-style-type: none;
cursor: pointer;
text-overflow: ellipsis;
diff --git a/src/i18n.tsx b/src/i18n.tsx
index 718f0a58..f5833a4f 100644
--- a/src/i18n.tsx
+++ b/src/i18n.tsx
@@ -3,6 +3,7 @@ import { reactI18nextModule } from "react-i18next";
import detector from "i18next-browser-languagedetector";
import translationEN from "./assets/locales/en/translation.json";
import translationCN from "./assets/locales/cn/translation.json";
+import translationTW from "./assets/locales/tw/translation.json";
// the translations
const resources = {
@@ -12,6 +13,9 @@ const resources = {
cn: {
translation: translationCN,
},
+ tw: {
+ translation: translationTW,
+ },
};
i18n
@@ -22,7 +26,6 @@ i18n
lng: "cn",
fallbackLng: "en",
keySeparator: false, // we do not use keys in form messages.welcome
-
interpolation: {
escapeValue: false, // react already safes from xss
},
diff --git a/src/model/Digest.ts b/src/model/Digest.ts
index 76e71334..69303788 100644
--- a/src/model/Digest.ts
+++ b/src/model/Digest.ts
@@ -5,7 +5,14 @@ class Digest {
chapter: string;
text: string;
cfi: string;
- constructor(bookKey: string, chapter: string, text: string, cfi: string) {
+ percentage: number;
+ constructor(
+ bookKey: string,
+ chapter: string,
+ text: string,
+ cfi: string,
+ percentage: number
+ ) {
this.key = new Date().getTime() + ""; //书摘的键值
this.date = {
year: new Date().getFullYear(),
@@ -16,6 +23,7 @@ class Digest {
this.chapter = chapter; //书摘的所在章节
this.text = text; //书摘的内容
this.cfi = cfi; //书摘的所在位置
+ this.percentage = percentage; //书摘的所在位置
}
}
diff --git a/src/model/Note.ts b/src/model/Note.ts
index 2fc4b7e5..a965ef0f 100644
--- a/src/model/Note.ts
+++ b/src/model/Note.ts
@@ -7,13 +7,15 @@ class Note {
cfi: string;
range: string;
notes: string;
+ percentage: number;
constructor(
bookKey: string,
chapter: string,
text: string,
cfi: string,
range: string,
- notes: string
+ notes: string,
+ percentage: number
) {
this.key = new Date().getTime() + ""; //笔记的键值
this.bookKey = bookKey; //笔记的所在书的键值
@@ -27,6 +29,7 @@ class Note {
this.cfi = cfi; //添加笔记的位置
this.range = range; // Rangy.js产生的将Range对象序列化后的字符串
this.notes = notes || ""; //笔记的内容
+ this.percentage = percentage; //笔记的内容
}
}
diff --git a/src/pages/manager/component.tsx b/src/pages/manager/component.tsx
index 6b038ae8..0b8c4868 100644
--- a/src/pages/manager/component.tsx
+++ b/src/pages/manager/component.tsx
@@ -147,11 +147,11 @@ class Manager extends React.Component {
(mode === "recent" && recentBooks !== 0) ||
mode === "shelf") ? (
- ) : bookmarks !== null && mode === "bookmark" ? (
+ ) : bookmarks && mode === "bookmark" ? (
- ) : notes !== null && notes !== undefined && mode === "note" ? (
+ ) : notes && mode === "note" ? (
- ) : digests !== null && mode === "digest" ? (
+ ) : digests && mode === "digest" ? (
) : (
diff --git a/src/redux/actions/progressPanel.tsx b/src/redux/actions/progressPanel.tsx
index 55098a39..e15c76d8 100644
--- a/src/redux/actions/progressPanel.tsx
+++ b/src/redux/actions/progressPanel.tsx
@@ -13,16 +13,16 @@ export function handleFetchPercentage(book: { key: string }) {
}
export function handleFetchLocations(epub: any) {
return (dispatch: (arg0: { type: string; payload: any }) => void) => {
- if (epub.locations !== undefined) {
+ epub.locations &&
epub.locations
.generate()
.then((result: any) => {
let locations = epub.locations;
+ console.log(locations, "locations");
dispatch(handleLocations(locations));
})
.catch(() => {
console.log("Error occurs");
});
- }
};
}
diff --git a/src/utils/deleteUtil.tsx b/src/utils/deleteUtil.tsx
index 2aa8bbb5..e4ff654d 100644
--- a/src/utils/deleteUtil.tsx
+++ b/src/utils/deleteUtil.tsx
@@ -5,7 +5,7 @@ import HighligherModel from "../model/Highlighter";
import BookmarkModel from "../model/Bookmark";
class DeleteUtil {
static deleteBook(books: BookModel[], bookKey: string) {
- let deleteIndex=-1;
+ let deleteIndex = -1;
for (let i = 0; i < books.length; i++) {
if (books[i].key === bookKey) {
deleteIndex = i;
@@ -41,7 +41,7 @@ class DeleteUtil {
}
static deleteDigests(digests: DigestModel[], bookKey: string) {
let deleteIndex = [];
- if (digests !== undefined) {
+ if (digests) {
for (let i = 0; i < digests.length; i++) {
if (digests[i].bookKey === bookKey) {
deleteIndex.push(i);
diff --git a/src/utils/recordRecent.tsx b/src/utils/recordRecent.tsx
index 34a614cc..a8ac9951 100644
--- a/src/utils/recordRecent.tsx
+++ b/src/utils/recordRecent.tsx
@@ -15,7 +15,6 @@ class RecordRecent {
bookArr.unshift(bookKey);
}
- console.log(bookArr);
localStorage.setItem("recentBooks", JSON.stringify(bookArr));
}
static setAllRecent(books: BookModel[]) {