【发布时间】:2020-08-26 09:24:07
【问题描述】:
我尝试使用 epubjs-rn 包通过以下代码显示我的 epub,调试构建中的一切都正常,当我获得发布构建和测试时,epub 书不显示并修复加载开始显现, 我在 android studio 控制台中调试,发现同样的错误:
I/ReactNativeJS: readBookEpub id: 4868
I/ReactNativeJS: source: http://localhost:8899/4868/
E/ReactNativeJS: Empty Response
我的代码:
_showEpub(bookName) {
console.log("_showEpub");
const targetPath = 'http://127.0.0.1:8899/' + bookName + '.epub';
//------------------------------------------------------show Epub
try {
this.streamer.start()
.then((origin) => {
console.log("Served from:", origin);
// this.streamer.check('http://127.0.0.1:8899/moby-dick.epub').then((t) => console.log("hiii"+t));
return this.streamer.get(targetPath);
})
.then((src) => {
console.log("Loading from:", src);
return this.setState({ urlBook: src });
});
}
catch (err) {
console.log("Error: " + err);
}
//---------------------------------------------------
}
对于show book,我通过RNBackgroundDownloader从我的服务器下载书并保存,然后将其解压缩到asset文件夹中以在本地阅读,
我的解压功能:
_unZipBook(bookName) {
console.log("_unZipBook")
const sourcePath = Dirs.DocumentDir + '/FaraSource/e/' + bookName + '.zip';
const targetPath = `${Dirs.DocumentDir}/assets/${bookName}`;
unzip(sourcePath, targetPath)
.then((path) => {
console.log("unZip " + bookName + "in" + targetPath);
this._showEpub(bookName);
// return url;
})
}
谁能帮我解决这个问题?
【问题讨论】: