Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from caleywoods/windows-add-book
Browse files Browse the repository at this point in the history
Fix Adding Books for Win32
  • Loading branch information
Janglee123 authored Oct 19, 2019
2 parents 6da5e3b + b5695ab commit 7f4bfc4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {
else{
this.isReady = true;
}
this.$bus.on('theme-change',(theme)=>{
this.$refs.app.className = "";
this.$refs.app.classList.add(theme);
Expand Down Expand Up @@ -65,7 +65,7 @@ html,
body {
margin: 0px;
width: 100%;
height: 100%;
height: 100%;
-webkit-font-smoothing: antialiased;
overflow: hidden;
}
Expand Down
22 changes: 13 additions & 9 deletions src/renderer/views/Reader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
</el-button-group>

<toc-menu :toc="toc" :theme="theme" @node-click="onNodeClick"></toc-menu>
<bookmark-menu
:bookmarks="info.bookmarks"
:theme="theme"

<bookmark-menu
:bookmarks="info.bookmarks"
:theme="theme"
@node-click="onNodeClick"
@add-bookmark="addBookmark"
@remove-bookmark="removeBookmark"
/>

<search-menu
:search-result="searchResult"
:theme="theme"
@node-click="onNodeClick"
@search="search"
/>

<theme-menu
@theme-change="applytheme"
@flow-change="applyflow"
Expand Down Expand Up @@ -89,7 +89,11 @@ export default {
},
mounted() {
const { id } = this.$route.params;
let { id } = this.$route.params;
if (process.platform === 'win32') {
id = id.split('\\').pop();
}
this.info = this.$db.get(id);
this.toc = this.info.toc;
this.info.lastOpen = new Date().getTime();
Expand Down Expand Up @@ -305,9 +309,9 @@ export default {
},
tocFromPercentage(percent){
if(!this._flattenedToc) return {};
percent /= 100;
for(let i = 0 ; i < this._flattenedToc.length ; i+=1 ){
Expand Down
17 changes: 11 additions & 6 deletions src/shared/dbUtilis.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import toBuffer from 'blob-to-buffer';
import { Book } from 'epubjs';
import fileUrl from 'file-url';
import path from 'path';
import process from 'process';
import * as Vibrant from 'node-vibrant';

/**
Expand Down Expand Up @@ -43,7 +44,7 @@ function storeCover(book, path, cb) {
* @returns {String} which will be used as a id to store file info in db
*/

function genrateKey(filePath) {
function generateKey(filePath) {
if (!filePath || typeof filePath !== 'string') {
return '';
}
Expand Down Expand Up @@ -161,7 +162,7 @@ function getInfo(filePath, callback) {
}

// create a key from path
const key = genrateKey(filePath);
const key = generateKey(filePath);

// file load on file protocol
const uri = fileUrl(filePath);
Expand Down Expand Up @@ -203,7 +204,7 @@ function getInfo(filePath, callback) {

function addToDB(file, db, cb) {
getInfo(file, (info, book) => {
const key = info.id;
let key = info.id;
info.lastOpen = new Date().getTime();

// return if book is allready registered
Expand All @@ -214,15 +215,19 @@ function addToDB(file, db, cb) {
return;
}

if (process.platform === 'win32') {
key = key.split('\\').pop();
}

const coverPath = path.join(
remote.app.getPath('appData'),
'eplee',
'cover',
key
);

storeCover(book, coverPath, isSucces => {
if (isSucces) {
storeCover(book, coverPath, isSuccess => {
if (isSuccess) {
info.coverPath = fileUrl(coverPath);
Vibrant.from(coverPath)
.getPalette((err, palette) => {
Expand All @@ -249,4 +254,4 @@ function addToDB(file, db, cb) {
});
}

export { addToDB, storeCover, genrateKey, getInfo, parshToc };
export { addToDB, storeCover, generateKey, getInfo, parshToc };

0 comments on commit 7f4bfc4

Please sign in to comment.