fix:web端epub图片未代理

pull/1778/head
Xwite 3 years ago
parent cc48698454
commit a7a62d752f
  1. 18
      app/src/main/java/io/legado/app/api/controller/BookController.kt

@ -22,6 +22,7 @@ import io.legado.app.model.localBook.LocalBook
import io.legado.app.model.localBook.UmdFile import io.legado.app.model.localBook.UmdFile
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.* import io.legado.app.utils.*
import io.legado.app.ui.book.read.page.provider.ImageProvider
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import splitties.init.appCtx import splitties.init.appCtx
@ -79,23 +80,16 @@ object BookController {
?: return returnData.setErrorMsg("bookUrl为空") ?: return returnData.setErrorMsg("bookUrl为空")
val src = parameters["path"]?.firstOrNull() val src = parameters["path"]?.firstOrNull()
?: return returnData.setErrorMsg("图片链接为空") ?: return returnData.setErrorMsg("图片链接为空")
val width = parameters["width"]?.firstOrNull()?.toInt() ?: 640
if (this.bookUrl != bookUrl) { if (this.bookUrl != bookUrl) {
this.book = appDb.bookDao.getBook(bookUrl) this.book = appDb.bookDao.getBook(bookUrl)
?: return returnData.setErrorMsg("bookUrl不对") ?: return returnData.setErrorMsg("bookUrl不对")
} this.bookSource = appDb.bookSourceDao.getBookSource(book.origin)
val vFile = BookHelp.getImage(book, src)
if (!vFile.exists()) {
if (this.bookUrl != bookUrl) {
this.bookSource = appDb.bookSourceDao.getBookSource(book.origin)
}
runBlocking {
BookHelp.saveImage(bookSource, book, src)
}
} }
this.bookUrl = bookUrl this.bookUrl = bookUrl
return returnData.setData( return ImageProvider.getImage(book, src, bookSource, width, width)?.let {
ImageLoader.loadBitmap(appCtx, vFile.absolutePath).submit().get() returnData.setData(it)
) }
} }
/** /**

Loading…
Cancel
Save