@@ -26,6 +26,7 @@ import kotlinx.coroutines.runBlocking
|
|||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
import java.net.URLDecoder
|
||||||
|
|
||||||
object BookController {
|
object BookController {
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ object BookController {
|
|||||||
*/
|
*/
|
||||||
fun getCover(parameters: Map<String, List<String>>): ReturnData {
|
fun getCover(parameters: Map<String, List<String>>): ReturnData {
|
||||||
val returnData = ReturnData()
|
val returnData = ReturnData()
|
||||||
val coverPath = parameters["path"]?.firstOrNull()
|
val coverPath = URLDecoder.decode(parameters["path"]?.firstOrNull(), "UTF-8")
|
||||||
val ftBitmap = ImageLoader.loadBitmap(appCtx, coverPath).submit()
|
val ftBitmap = ImageLoader.loadBitmap(appCtx, coverPath).submit()
|
||||||
return try {
|
return try {
|
||||||
returnData.setData(ftBitmap.get())
|
returnData.setData(ftBitmap.get())
|
||||||
@@ -65,6 +66,28 @@ object BookController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取正文图片
|
||||||
|
*/
|
||||||
|
fun getImg(parameters: Map<String, List<String>>): ReturnData {
|
||||||
|
val returnData = ReturnData()
|
||||||
|
val bookUrl = parameters["url"]?.firstOrNull()
|
||||||
|
?: return returnData.setErrorMsg("bookUrl为空")
|
||||||
|
val book = appDb.bookDao.getBook(URLDecoder.decode(bookUrl, "UTF-8"))
|
||||||
|
?: return returnData.setErrorMsg("bookUrl不对")
|
||||||
|
val src = URLDecoder.decode(parameters["path"]?.firstOrNull(), "UTF-8")
|
||||||
|
val vFile = BookHelp.getImage(book, src)
|
||||||
|
if (!vFile.exists()) {
|
||||||
|
val bookSource = appDb.bookSourceDao.getBookSource(book.origin)
|
||||||
|
runBlocking {
|
||||||
|
BookHelp.saveImage(bookSource, book, src)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnData.setData(
|
||||||
|
BitmapUtils.decodeBitmap(vFile.absolutePath)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新目录
|
* 更新目录
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class HttpServer(port: Int) : NanoHTTPD(port) {
|
|||||||
"/refreshToc" -> BookController.refreshToc(parameters)
|
"/refreshToc" -> BookController.refreshToc(parameters)
|
||||||
"/getBookContent" -> BookController.getBookContent(parameters)
|
"/getBookContent" -> BookController.getBookContent(parameters)
|
||||||
"/cover" -> BookController.getCover(parameters)
|
"/cover" -> BookController.getCover(parameters)
|
||||||
|
"/image" -> BookController.getImg(parameters)
|
||||||
"/getReadConfig" -> BookController.getWebReadConfig()
|
"/getReadConfig" -> BookController.getWebReadConfig()
|
||||||
"/getRssSource" -> RssSourceController.getSource(parameters)
|
"/getRssSource" -> RssSourceController.getSource(parameters)
|
||||||
"/getRssSources" -> RssSourceController.sources
|
"/getRssSources" -> RssSourceController.sources
|
||||||
|
|||||||
Reference in New Issue
Block a user