修复书本读取

master
宇天 2021-01-06 20:20:48 +08:00
parent e855b5cd26
commit 5435bc6482
5 changed files with 6 additions and 4 deletions

View File

@ -28,7 +28,7 @@
<div class="detail" :class="{blur: !curr.code}"> <div class="detail" :class="{blur: !curr.code}">
<book :for="it in books"> <book :for="it in books">
<img :src="'book://' + it.title + '/' + it.cover"> <img :src="'book://cache/' + it.title + '/' + it.cover">
{{it.title}} {{it.title}}
</book> </book>

View File

@ -77,7 +77,7 @@ Anot({
while (this.load.curr < this.load.num) { while (this.load.curr < this.load.num) {
this.load.curr++ this.load.curr++
let book = files.pop() let book = files.pop()
let res = app.dispatch('parse-book', { book, cate: this.burr }) let res = app.dispatch('parse-book', { book, cate: this.curr })
console.log(res) console.log(res)
if (res) { if (res) {
this.books.push(res) this.books.push(res)

View File

@ -65,11 +65,11 @@ app.once('ready', () => {
}) })
protocol.registerStreamProtocol('book', function(req, cb) { protocol.registerStreamProtocol('book', function(req, cb) {
var file = decodeURIComponent(req.url.replace(/^book:[\/]+/, '/')) var file = decodeURIComponent(req.url.replace(/^book:[\/]+cache/, './'))
var ext = path.extname(file) var ext = path.extname(file)
file = path.resolve(CACHE_DIR, file) file = path.resolve(CACHE_DIR, file)
console.log(file)
cb({ cb({
data: fs.origin.createReadStream(file), data: fs.origin.createReadStream(file),
mimeType: MIME_TYPES[ext] || MIME_TYPES.all, mimeType: MIME_TYPES[ext] || MIME_TYPES.all,

View File

@ -113,6 +113,7 @@ module.exports = function(app) {
} else { } else {
cache[cate] = [info] cache[cate] = [info]
} }
fs.echo(JSON.stringify(cache), DB_FILE)
ev.returnValue = info ev.returnValue = info
}) })

View File

@ -0,0 +1 @@
/Users/yutent/Library/Application Support/org.bytedo.epub/app.cache