diff --git a/src/assets/locales/cn/translation.json b/src/assets/locales/cn/translation.json index f03038f2..3bf3354a 100644 --- a/src/assets/locales/cn/translation.json +++ b/src/assets/locales/cn/translation.json @@ -80,6 +80,7 @@ "This action won't delete the original book": "仅从此书架中删除本书,原图书不受影响", "From": "来自", "Duplicate Book": "图书重复", + "Duplicate Shelf": "书架重复", "Unknown": "未知", "Minute": "分钟", "Empty": "书签为空", @@ -114,7 +115,7 @@ "Empty Shelf": "您的书架为空", "Move your mouse on the top of any book": "将鼠标移动到任意书本上方,在弹出的菜单中点击加号添加到书架", "This is a free and open-source Epub reader": "这是一个免费开源的Epub阅读器", - "Koodo Reader works on multiple platforms with backup and restore support": "Koodo Reader同时支持桌面版和网页版,您所有的数据都可以导入导出和支持多端同步", + "Koodo Reader works on multiple platforms with backup and restore support": "Koodo Reader同时支持桌面版和网页版,您所有的数据都可以导入导出和多端同步", "For better reading experience": "只为最好的阅读体验", "Supports for theme changing, reading history, book managerment, shelf managerment and more": "主题切换,阅读历史,图书管理,书架管理,更多功能等你探索", "Fluent and easy operation": "简单流畅的操作方式", diff --git a/src/assets/locales/en/translation.json b/src/assets/locales/en/translation.json index 6d9e1490..b61d1f10 100644 --- a/src/assets/locales/en/translation.json +++ b/src/assets/locales/en/translation.json @@ -19,6 +19,7 @@ "Entertainment": "Entertainment", "Study": "Study", "Author": "Author", + "Duplicate Shelf": "Duplicate Shelf", "Reading Time": "Reading Time", "Content": "Content", "Bookmark": "Bookmark", @@ -89,7 +90,8 @@ "Minute": "Minute", "Empty": "Empty", "Less": "Less", - "More": "More", + "More Digests": "More Digests", + "More Notes": "More Notes", "Pick Up Color": "Pick Up Color", "Highlight Successfully": "Highlight Successfully", "Take Notes": "Take Notes", diff --git a/src/assets/locales/tw/translation.json b/src/assets/locales/tw/translation.json new file mode 100644 index 00000000..724477b1 --- /dev/null +++ b/src/assets/locales/tw/translation.json @@ -0,0 +1,128 @@ +{ + "Download Demo Book": "下載範例圖書", + "All Books": "全部圖書", + "Recent Books": "最近閱讀", + "My Bookmarks": "我的書籤", + "My Notes": "我的筆記", + "My Digests": "我的書摘", + "My Shelves": "我的書架", + "Sort": "排序", + "Authorizing": "授權中,請稍候", + "Downloading": "下載中,請稍候", + "Uploading": "上傳中,請稍候", + "Import from Local": "從本機導入", + "Backup and Restore": "備份和恢復", + "Search My Library": "搜索我的書庫", + "Card Mode": "卡片模式", + "List Mode": "列表模式", + "More Digests": "顯示書摘出處", + "More Notes": "顯示筆記出處", + "Work": "工作學習", + "Entertainment": "休閒娛樂", + "Study": "生活百科", + "Author": "作者", + "Reading Time": "已讀", + "Content": "目錄", + "Bookmark": "書籤", + "Single-Page Mode": "單頁模式", + "Double-Page Mode": "雙頁模式", + "Background Color": "背景顏色", + "Font Size": "字體大小", + "Font Family": "字體", + "Default": "預設", + "Small": "小", + "Medium": "中", + "Large": "大", + "Extra Large": "特大", + "Ultra Large": "超大", + "Reading Option": "閱讀選項", + "Current Progress": "當前進度", + "Exit": "結束閱讀", + "Empty Shelf Title": "書架名為空", + "Enter Fullscreen": "進入全螢幕", + "Exit Fullscreen": "退出全螢幕", + "Add Bookmark": "添加書籤", + "Add to Shelf": "添加到書架", + "New Shelf": "新建", + "New": "新建書架", + "Copy Successfully": "複製成功", + "Cancel": "取消", + "Confirm": "確認", + "Delete": "刪除", + "Delete This Book": "刪除這本書", + "Edit Book": "編輯圖書", + "Edit Successfully": "編輯成功", + "Book Name": "書名", + "Sort by Date": "按添加時間", + "Descending Order": "倒序", + "Ascending Order": "正序", + "Sort by Name": "按名稱", + "Copy Link Successfully": "鏈接複製成功", + "Add Successfully": "添加成功", + "Select": "選擇", + "Coming Soon": "敬請期待", + "Authorize Successfully": "授權成功", + "Authorize Failed": "授權失敗", + "You can turn off this tab now": "您可以關閉此標籤頁了", + "Do you want to backup or restore?": "您想要備份還是恢復?", + "Where is your data?": "您的資料保存在哪裡?", + "Where to keep your data?": "您想把資料存在哪裡?", + "I want to backup": "我要備份", + "I want to restore": "我要還原", + "Backup Successfully": "備份成功", + "Restore Successfully": "還原成功", + "Try refresh or restart": "重新整理後生效", + "Wrong bookmark": "書籤出問題了", + "Last Step": "上一步", + "Next Step": "下一步", + "Go To": "點擊前往", + "Delete from Shelf": "從書架刪除本書", + "Delete Successfully": "刪除成功", + "This action will delete all the notes, bookmarks and digests of this book": "同時刪除本書所有的書籤,筆記,書摘", + "This action won't delete the original book": "僅從此書架中刪除本書,原圖書不受影響", + "From": "來自", + "Duplicate Book": "圖書重複", + "Unknown": "未知", + "Minute": "分鐘", + "Empty": "書籤為空", + "Less": "收起", + "Pick Up Color": "選擇顏色", + "Highlight Successfully": "高亮成功", + "Take Notes": "記筆記", + "Collect": "摘錄", + "Highlight": "高亮", + "Copy": "複製", + "Bind": "綁定", + "Token": "憑證", + "Token Info": "請複製以下鏈接到瀏覽器打開,登錄授權後,您將獲得一串代碼,請將代碼填入以下輸入框即可完成綁定", + "Copy Link": "複製鏈接", + "Copy Token": "複製憑證", + "Copied": "已複製", + "Hi! Stranger": "你好啊!朋友", + "Skip": "不再提示", + "Local": "本機", + "Line Height": "行間距", + "Empty Library": "圖書庫為空", + "Click the top-right button to add books": "請點擊右上角的導入圖書按鈕添加圖書", + "Empty Reading Records": "您沒有閱讀記錄", + "Click on any book to read": "點擊任意一本書開始閱讀", + "Empty Bookmark": "您的書籤為空", + "Move your mouse on the top edge of the reader": "在閱讀器界面,將滑鼠游標移至上邊緣處,在彈出的選單欄中添加書籤", + "Empty Note": "您的筆記為空", + "Select any text and click the Add-Note button on the popup Menu": "在閱讀器界面,選中文字後,在彈出的對話框中添加筆記", + "Empty Digest": "您的書摘為空", + "Select any text and click the Collect button on the popup Menu": "在閱讀器界面,選中文字後,在彈出的對話框中點擊摘錄", + "Empty Shelf": "您的書架為空", + "Move your mouse on the top of any book": "將滑鼠游標移動到任意書本上方,在彈出的菜單中點擊加號添加到書架", + "This is a free and open-source Epub reader": "這是一個免費開源的Epub閱讀器", + "Koodo Reader works on multiple platforms with backup and restore support": "Koodo Reader同時支持桌面版和網頁版,您所有的資料都可以導入導出和支持多端同步", + "For better reading experience": "只為最好的閱讀體驗", + "Supports for theme changing, reading history, book managerment, shelf managerment and more": "主題切換,閱讀歷史,圖書管理,書架管理,更多功能等你探索", + "Fluent and easy operation": "簡單流暢的操作方式", + "Move your mouse to the edge of the reader to trigger menu,use mouse wheel and keyborad to switch pages": "鼠標移至邊緣彈出選單,使用滑鼠滾輪或鍵盤的上下左右按鍵控制翻頁", + "Go to Add your first book": "快去添加您的第一本書吧", + "That's all for the tutorial": "介紹完畢", + "Download failed,network problem or no backup": "下載失敗,網路出錯或者沒有找到備份", + "Upload failed, check your connection": "上傳失敗,請檢查網路連接", + "Duplicate Shelf": "書架重複" +} diff --git a/src/assets/styles/fonts/icomoon.eot b/src/assets/styles/fonts/icomoon.eot index b8ad62ac..aa28a62a 100644 Binary files a/src/assets/styles/fonts/icomoon.eot and b/src/assets/styles/fonts/icomoon.eot differ diff --git a/src/assets/styles/fonts/icomoon.svg b/src/assets/styles/fonts/icomoon.svg index bccb736b..834358f1 100644 --- a/src/assets/styles/fonts/icomoon.svg +++ b/src/assets/styles/fonts/icomoon.svg @@ -7,36 +7,33 @@ - - - - - - - - - - - + + + + + + + + + + + - - - + + - - - - - - + + + + - + @@ -51,7 +48,23 @@ - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/assets/styles/fonts/icomoon.ttf b/src/assets/styles/fonts/icomoon.ttf index 268d556e..9430229b 100644 Binary files a/src/assets/styles/fonts/icomoon.ttf and b/src/assets/styles/fonts/icomoon.ttf differ diff --git a/src/assets/styles/fonts/icomoon.woff b/src/assets/styles/fonts/icomoon.woff index 6e879dca..ac86854c 100644 Binary files a/src/assets/styles/fonts/icomoon.woff and b/src/assets/styles/fonts/icomoon.woff differ diff --git a/src/assets/styles/style.css b/src/assets/styles/style.css index 01e888cd..3bf29e9f 100644 --- a/src/assets/styles/style.css +++ b/src/assets/styles/style.css @@ -1,10 +1,10 @@ @font-face { font-family: 'icomoon'; - src: url('fonts/icomoon.eot?bat9kn'); - src: url('fonts/icomoon.eot?bat9kn#iefix') format('embedded-opentype'), - url('fonts/icomoon.ttf?bat9kn') format('truetype'), - url('fonts/icomoon.woff?bat9kn') format('woff'), - url('fonts/icomoon.svg?bat9kn#icomoon') format('svg'); + src: url('fonts/icomoon.eot?lwid43'); + src: url('fonts/icomoon.eot?lwid43#iefix') format('embedded-opentype'), + url('fonts/icomoon.ttf?lwid43') format('truetype'), + url('fonts/icomoon.woff?lwid43') format('woff'), + url('fonts/icomoon.svg?lwid43#icomoon') format('svg'); font-weight: normal; font-style: normal; font-display: block; @@ -13,7 +13,7 @@ [class^="icon-"], [class*=" icon-"] { /* use !important to prevent issues with browser extensions that change fonts */ font-family: 'icomoon' !important; - speak: none; + speak: never; font-style: normal; font-weight: normal; font-variant: normal; @@ -25,11 +25,49 @@ -moz-osx-font-smoothing: grayscale; } +.icon-copy:before { + content: "\e900"; +} +.icon-next:before { + content: "\e901"; +} +.icon-album:before { + content: "\e902"; +} +.icon-photo:before { + content: "\e903"; +} +.icon-account:before { + content: "\e904"; +} +.icon-upload:before { + content: "\e905"; +} +.icon-waiting:before { + content: "\e906"; +} +.icon-done:before { + content: "\e907"; +} +.icon-uploading:before { + content: "\e908"; +} +.icon-add:before { + content: "\e909"; +} +.icon-delete:before { + content: "\e90a"; +} .icon-english:before { content: "\e92d"; } -.icon-chinese:before { +.icon-simplified:before { content: "\e92e"; + color: #565656; +} +.icon-traditional:before { + content: "\e932"; + color: #565656; } .icon-local:before { content: "\e92a"; @@ -60,6 +98,16 @@ content: "\e928"; color: #4b4b4b; } +.icon-yandex .path1:before { + content: "\e914"; + color: rgb(75, 75, 75); + opacity: 0.71; +} +.icon-yandex .path2:before { + content: "\e944"; + margin-left: -1.517578125em; + color: rgb(75, 75, 75); +} .icon-two-page:before { content: "\e925"; } @@ -100,7 +148,7 @@ content: "\e91c"; color: #f16464; } -.icon-copy:before { +.icon-copy1:before { content: "\e91d"; color: #f90; } @@ -108,10 +156,10 @@ content: "\e91e"; color: #fff; } -.icon-add:before { +.icon-add1:before { content: "\e90d"; } -.icon-delete:before { +.icon-delete1:before { content: "\e90e"; } .icon-onedrive:before { @@ -126,65 +174,65 @@ content: "\e911"; color: #4b4b4b; } +.icon-yandex3:before { + content: "\e915"; +} .icon-webdav:before { - content: "\e914"; + content: "\e916"; color: #4b4b4b; } -.icon-noun_books_2156102:before { - content: "\e915"; - color: #fff; -} .icon-edit:before { - content: "\e916"; + content: "\e918"; } .icon-exit:before { - content: "\e917"; + content: "\e919"; color: #fff; } .icon-fullscreen:before { - content: "\e918"; + content: "\e933"; color: #fff; } .icon-googledrive:before { - content: "\e919"; + content: "\e934"; color: #4b4b4b; } .icon-koodo:before { - content: "\e90c"; + content: "\e935"; +} +.icon-home1:before { + content: "\e936"; + color: #515151; } .icon-list:before { - content: "\e900"; + content: "\e937"; } .icon-more:before { - content: "\e901"; + content: "\e938"; } .icon-bookmark:before { - content: "\e902"; + content: "\e939"; } .icon-shelf:before { - content: "\e903"; + content: "\e93a"; } .icon-idea:before { - content: "\e904"; + content: "\e93b"; } .icon-recent:before { - content: "\e905"; + content: "\e93c"; } .icon-sort:before { - content: "\e906"; + content: "\e93d"; } .icon-search:before { - content: "\e907"; + content: "\e93e"; } .icon-grid:before { - content: "\e908"; + content: "\e93f"; } .icon-dropdown:before { - content: "\e909"; + content: "\e940"; } .icon-digest:before { - content: "\e90a"; -} -.icon-return:before { - content: "\ea40"; + content: "\e941"; } diff --git a/src/components/book/component.tsx b/src/components/book/component.tsx index 226bac11..f0b829ae 100644 --- a/src/components/book/component.tsx +++ b/src/components/book/component.tsx @@ -53,7 +53,7 @@ class Book extends React.Component { { this.props.handleReadingBook(this.props.book); }; render() { - let date = - RecordRecent.getRecent()[this.props.book.key] !== null && - RecordRecent.getRecent()[this.props.book.key] !== undefined - ? RecordRecent.getRecent()[this.props.book.key].date - : { year: "0000", month: "00", day: "00" }; - let percentage = - RecordLocation.getCfi(this.props.book.key) !== null && - RecordLocation.getCfi(this.props.book.key) !== undefined - ? RecordLocation.getCfi(this.props.book.key).percentage - : 0; + let date = RecordRecent.getRecent()[this.props.book.key] + ? RecordRecent.getRecent()[this.props.book.key].date + : { year: "0000", month: "00", day: "00" }; + let percentage = RecordLocation.getCfi(this.props.book.key) + ? RecordLocation.getCfi(this.props.book.key).percentage + : 0; return (
{ {"" + date.year + "-" + date.month + "-" + date.day}

- {this.props.percentage !== null ? Math.round(percentage * 100) : 0}% + {this.props.percentage ? Math.round(percentage * 100) : 0}%

{ this.props.currentEpub.goto(href); } render() { - const renderContentList = () => { - return this.state.chapters.map((item: any, index: number) => { - let isSubContentList = item.subitems && item.subitems.length; - const renderSubContentList = () => { - return item.subitems.map((item: any, index: number) => { - return ( -
  • - - {item.label} - -
  • - ); - }); - }; + const renderContentList = (items: any) => { + return items.map((item: any, index: number) => { return ( -
  • +
  • { > {item.label} - {isSubContentList ?
      {renderSubContentList()}
    : null} + {item.subitems.length > 0 ? ( +
      {renderContentList(item.subitems)}
    + ) : null}
  • ); }); }; + // return ( + //
  • + // + // {item.label} + // + // {item.subitems.length > 0 ? ( + //
      {renderSubContentList(item.subitems)}
    + // ) : null} + //
  • + // ); return (
    -
      {renderContentList()}
    +
      + {renderContentList(this.state.chapters)} +
    ); } diff --git a/src/components/contentList/contentList.css b/src/components/contentList/contentList.css index c6a9cf26..c68c1bb7 100644 --- a/src/components/contentList/contentList.css +++ b/src/components/contentList/contentList.css @@ -1,16 +1,14 @@ .book-content-list { float: left; - - width: 220px; - + width: calc(100% - 20px); margin-left: 18px; } .book-content-name { display: block; - width: 282px; + padding: 10px 0px; + width: 100%; font-size: 14px; - - line-height: 48px; + line-height: 18px; color: rgba(75, 75, 75, 1); opacity: 1; float: left; @@ -22,7 +20,7 @@ width: 220px; float: left; font-size: 13px; - + line-height: 20px; color: rgba(75, 75, 75, 1); opacity: 0.64; diff --git a/src/components/importLocal/component.tsx b/src/components/importLocal/component.tsx index 20d19838..4c9b2307 100644 --- a/src/components/importLocal/component.tsx +++ b/src/components/importLocal/component.tsx @@ -7,7 +7,6 @@ import SparkMD5 from "spark-md5"; import { Trans } from "react-i18next"; import Dropzone from "react-dropzone"; import { ImportLocalProps, ImportLocalState } from "./interface"; -import OtherUtil from "../../utils/otherUtil"; import RecordRecent from "../../utils/recordRecent"; class ImportLocal extends React.Component { @@ -27,7 +26,6 @@ class ImportLocal extends React.Component { localforage.setItem("books", bookArr).then(() => { this.props.handleFetchBooks(); }); - OtherUtil.setReaderConfig("isBookImported", "yes"); this.props.handleMessage("Add Successfully"); this.props.handleMessageBox(true); }; @@ -70,7 +68,7 @@ class ImportLocal extends React.Component { }; handleBook = (file: any, md5: string) => { //md5重复不导入 - if (this.props.books !== null) { + if (this.props.books) { this.props.books.forEach((item) => { if (item.md5 === md5) { this.setState({ isRepeat: true }); diff --git a/src/components/popupNote/component.tsx b/src/components/popupNote/component.tsx index b3d75df2..b21e9430 100644 --- a/src/components/popupNote/component.tsx +++ b/src/components/popupNote/component.tsx @@ -33,6 +33,7 @@ class PopupNote extends React.Component { text = text && text.trim(); let cfiBase = epub.renderer.currentChapter.cfiBase; let cfi = new window.EPUBJS.EpubCFI().generateCfiFromRange(range, cfiBase); + let percentage = this.props.currentEpub.locations.percentageFromCfi(cfi); let bookKey = book.key; let charRange = window.rangy .getSelection(iframe) @@ -42,11 +43,10 @@ class PopupNote extends React.Component { let index = this.props.chapters.findIndex((item: any) => { return item.spinePos > epub.renderer.currentChapter.spinePos; }); - let chapter = - this.props.chapters[index] !== undefined - ? this.props.chapters[index].label.trim(" ") - : "Unknown"; - let note = new Note(bookKey, chapter, text, cfi, serial, notes); + let chapter = this.props.chapters[index] + ? this.props.chapters[index].label.trim(" ") + : "Unknown"; + let note = new Note(bookKey, chapter, text, cfi, serial, notes, percentage); let noteArr = this.props.notes ? this.props.notes : []; noteArr.push(note); localforage.setItem("notes", noteArr); diff --git a/src/components/popupOption/component.tsx b/src/components/popupOption/component.tsx index 2127d55c..19cfd88b 100644 --- a/src/components/popupOption/component.tsx +++ b/src/components/popupOption/component.tsx @@ -51,18 +51,17 @@ class PopupOption extends React.Component { cfiBase ); let bookKey = book.key; - + let percentage = this.props.currentEpub.locations.percentageFromCfi(cfi); //获取章节名 let index = this.props.chapters.findIndex((item: any) => { return item.spinePos > epub.renderer.currentChapter.spinePos; }); - let chapter = - this.props.chapters[index] !== undefined - ? this.props.chapters[index].label.trim(" ") - : "Unknown"; + let chapter = this.props.chapters[index] + ? this.props.chapters[index].label.trim(" ") + : "Unknown"; // let chapter = epub.renderer.currentChapter.spinePos; - let digest = new Digest(bookKey, chapter, text, cfi); + let digest = new Digest(bookKey, chapter, text, cfi, percentage); let digestArr = this.props.digests ? this.props.digests : []; digestArr.push(digest); localforage.setItem("digests", digestArr); @@ -122,7 +121,7 @@ class PopupOption extends React.Component { }} >
    - +

    Copy

    diff --git a/src/components/searchBox/component.tsx b/src/components/searchBox/component.tsx index c40bae02..359ae4f5 100644 --- a/src/components/searchBox/component.tsx +++ b/src/components/searchBox/component.tsx @@ -11,7 +11,7 @@ class SearchBox extends React.Component { }; handleKey = (event: any) => { let results = OtherUtil.KeySearch(event, this.props.books); - if (results !== undefined) { + if (results) { this.props.handleSearchBooks(results); this.props.handleSearch(true); } diff --git a/src/containers/addDialog/component.tsx b/src/containers/addDialog/component.tsx index fa3dc042..16a884f4 100644 --- a/src/containers/addDialog/component.tsx +++ b/src/containers/addDialog/component.tsx @@ -19,14 +19,31 @@ class AddDialog extends Component { ".add-dialog-new-shelf-box" ) as HTMLInputElement; let shelfTitle: string = this.state.shelfTitle; + let shelfList = ShelfUtil.getShelf(); + if (this.state.isNew) { shelfTitle = inputElement.value; + if (shelfList.hasOwnProperty(shelfTitle)) { + this.props.handleMessage("Duplicate Shelf"); + this.props.handleMessageBox(true); + return; + } } if (!shelfTitle) { this.props.handleMessage("Empty Shelf Title"); this.props.handleMessageBox(true); return; } + //判断书架中是否已有该图书 + if ( + shelfList[`${shelfTitle}`] && + shelfList[`${shelfTitle}`].indexOf(this.props.currentBook.key) > -1 + ) { + this.props.handleMessage("Duplicate Book"); + this.props.handleMessageBox(true); + return; + } + ShelfUtil.setShelf(shelfTitle, this.props.currentBook.key); this.props.handleAddDialog(false); this.props.handleMessage("Add Successfully"); diff --git a/src/containers/backupPage/component.tsx b/src/containers/backupPage/component.tsx index 91350b88..0fb5f484 100644 --- a/src/containers/backupPage/component.tsx +++ b/src/containers/backupPage/component.tsx @@ -230,7 +230,7 @@ class BackupPage extends React.Component { onClick={() => { this.setState({ currentStep: 1 }); }} - style={this.state.isBackup !== null ? {} : { display: "none" }} + style={this.state.isBackup ? {} : { display: "none" }} > Next Step
    diff --git a/src/containers/bookList/component.tsx b/src/containers/bookList/component.tsx index 3b152772..2908d583 100644 --- a/src/containers/bookList/component.tsx +++ b/src/containers/bookList/component.tsx @@ -57,13 +57,11 @@ class BookList extends React.Component { arr.forEach((item) => { itemArr.push(items[item]); }); - console.log(itemArr, "arr", this.props.isSort, this.props.isSearch); return itemArr; }; render() { OtherUtil.setReaderConfig("totalBooks", this.props.books.length.toString()); const renderBookList = () => { - console.log(this.props.isSort, "this.props.isSort"); //根据不同的场景获取不同的图书数据 let books = this.props.shelfIndex !== -1 diff --git a/src/containers/deleteDialog/component.tsx b/src/containers/deleteDialog/component.tsx index 5e60a0ae..f2270b79 100644 --- a/src/containers/deleteDialog/component.tsx +++ b/src/containers/deleteDialog/component.tsx @@ -12,7 +12,7 @@ class DeleteDialog extends React.Component { this.props.handleDeleteDialog(false); }; handleDeleteOther = () => { - if (this.props.bookmarks !== null) { + if (this.props.bookmarks) { let bookmarkArr = DeleteUtil.deleteBookmarks( this.props.bookmarks, this.props.currentBook.key @@ -27,7 +27,7 @@ class DeleteDialog extends React.Component { }); } } - if (this.props.notes !== null) { + if (this.props.notes) { let noteArr = DeleteUtil.deleteNotes( this.props.notes, this.props.currentBook.key @@ -42,7 +42,7 @@ class DeleteDialog extends React.Component { }); } } - if (this.props.digests !== null) { + if (this.props.digests) { let digestArr = DeleteUtil.deleteDigests( this.props.digests, this.props.currentBook.key @@ -57,7 +57,7 @@ class DeleteDialog extends React.Component { }); } } - if (this.props.highlighters !== null) { + if (this.props.highlighters) { let highlighterArr = DeleteUtil.deleteHighlighters( this.props.highlighters, this.props.currentBook.key @@ -79,7 +79,7 @@ class DeleteDialog extends React.Component { ShelfUtil.clearShelf(this.props.shelfIndex, this.props.currentBook.key); this.props.handleDeleteDialog(false); } else { - this.props.books !== null && + this.props.books && localforage .setItem( "books", diff --git a/src/containers/digestList/component.tsx b/src/containers/digestList/component.tsx index d954fde6..a635cfb2 100644 --- a/src/containers/digestList/component.tsx +++ b/src/containers/digestList/component.tsx @@ -5,6 +5,8 @@ import DigestModel from "../../model/Digest"; import { Trans } from "react-i18next"; import { DigestListProps, DigestListStates } from "./interface"; import DeleteIcon from "../../components/deleteIcon"; +import RecentBooks from "../../utils/recordRecent"; +import RecordLocation from "../../utils/recordLocation"; class DigestList extends React.Component { constructor(props: DigestListProps) { @@ -26,6 +28,24 @@ class DigestList extends React.Component { handleShowDelete = (deleteKey: string) => { this.setState({ deleteKey }); }; + handleJump = (cfi: string, bookKey: string, percentage: number) => { + let { books, epubs } = this.props; + let book = null; + let epub = null; + //根据bookKey获取指定的book和epub + for (let i = 0; i < books.length; i++) { + if (books[i].key === bookKey) { + book = books[i]; + epub = epubs[i]; + break; + } + } + this.props.handleReadingBook(book!); + this.props.handleReadingEpub(epub); + this.props.handleReadingState(true); + RecentBooks.setRecent(bookKey); + RecordLocation.recordCfi(bookKey, cfi, percentage); + }; render() { let { digests } = this.props; let digestArr = []; @@ -95,6 +115,19 @@ class DigestList extends React.Component {
    》{item.chapter}
    +
    { + this.handleJump(item.cfi, item.bookKey, item.percentage); + }} + > +
    + {"More Digests"} + +
    +
    ); diff --git a/src/containers/digestList/digestList.css b/src/containers/digestList/digestList.css index 5ba070d0..94600d94 100644 --- a/src/containers/digestList/digestList.css +++ b/src/containers/digestList/digestList.css @@ -54,7 +54,7 @@ cursor: pointer; font-size: 16px; width: calc(50vw - 140px); - height: 126px; + height: 146px; background: rgba(255, 255, 255, 1); box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.16); opacity: 1; @@ -78,18 +78,15 @@ max-width: 130px; } .digest-list-item-citation { + font-size: 16px; position: absolute; - bottom: 5px; + bottom: 30px; right: 5px; - /* text-align: right; */ margin: 5px; white-space: nowrap; white-space: normal; word-break: break-all; color: rgba(155, 155, 155, 1); - - /* width: 300px; */ - /* text-align: right; */ } .digest-list-item-text-parent { position: absolute; @@ -131,3 +128,6 @@ .digest-list-container-box { margin-top: 35px; } +.icon-digest-right { + margin: 5px; +} diff --git a/src/containers/digestList/interface.tsx b/src/containers/digestList/interface.tsx index 50fd11e6..5e983716 100644 --- a/src/containers/digestList/interface.tsx +++ b/src/containers/digestList/interface.tsx @@ -8,7 +8,11 @@ export interface DigestListProps { bookmarks: BookmarkModel[]; chapters: any; books: BookModel[]; + epubs: any; digests: DigestModel[]; + handleReadingState: (isReading: boolean) => void; + handleReadingBook: (currentBook: BookModel) => void; + handleReadingEpub: (currentEpub: any) => void; } export interface DigestListStates { deleteKey: string; diff --git a/src/containers/header/component.tsx b/src/containers/header/component.tsx index 5054b5b8..12ade0b6 100644 --- a/src/containers/header/component.tsx +++ b/src/containers/header/component.tsx @@ -14,8 +14,8 @@ class Header extends React.Component { this.state = { isOnlyLocal: false, isBookImported: - OtherUtil.getReaderConfig("isBookImported") === "yes" ? true : false, - isChinese: OtherUtil.getReaderConfig("lang") === "cn", + OtherUtil.getReaderConfig("totalBooks") !== "0" ? true : false, + language: OtherUtil.getReaderConfig("lang"), isNewVersion: false, }; } @@ -23,12 +23,12 @@ class Header extends React.Component { const lng = OtherUtil.getReaderConfig("lang"); if (lng) { i18n.changeLanguage(lng); - this.setState({ isChinese: !this.state.isChinese }); + this.setState({ language: lng }); } } changeLanguage = (lng: string) => { i18n.changeLanguage(lng); - this.setState({ isChinese: !this.state.isChinese }); + this.setState({ language: lng }); OtherUtil.setReaderConfig("lang", lng); }; handleSortBooks = () => { @@ -59,9 +59,14 @@ class Header extends React.Component {
    - {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[]) {