mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
df8e902df4
commit
bbbc8e9f48
@ -215,19 +215,22 @@ object BookController {
|
||||
*/
|
||||
fun saveBookProgress(postData: String?): ReturnData {
|
||||
val returnData = ReturnData()
|
||||
GSON.fromJsonObject<BookProgress>(postData).getOrNull()?.let { bookProgress ->
|
||||
appDb.bookDao.getBook(bookProgress.name, bookProgress.author)?.let { book ->
|
||||
book.durChapterIndex = bookProgress.durChapterIndex
|
||||
book.durChapterPos = bookProgress.durChapterPos
|
||||
appDb.bookDao.update(book)
|
||||
AppWebDav.uploadBookProgress(bookProgress)
|
||||
if (ReadBook.book?.bookUrl == book.bookUrl) {
|
||||
ReadBook.book = book
|
||||
ReadBook.durChapterIndex = book.durChapterIndex
|
||||
GSON.fromJsonObject<BookProgress>(postData)
|
||||
.onFailure { it.printOnDebug() }
|
||||
.getOrNull()?.let { bookProgress ->
|
||||
appDb.bookDao.getBook(bookProgress.name, bookProgress.author)?.let { book ->
|
||||
book.durChapterIndex = bookProgress.durChapterIndex
|
||||
book.durChapterPos = bookProgress.durChapterPos
|
||||
book.durChapterTitle = bookProgress.durChapterTitle
|
||||
appDb.bookDao.update(book)
|
||||
AppWebDav.uploadBookProgress(bookProgress)
|
||||
if (ReadBook.book?.bookUrl == book.bookUrl) {
|
||||
ReadBook.book = book
|
||||
ReadBook.durChapterIndex = book.durChapterIndex
|
||||
}
|
||||
return returnData.setData("")
|
||||
}
|
||||
return returnData.setData("")
|
||||
}
|
||||
}
|
||||
return returnData.setErrorMsg("格式不对")
|
||||
}
|
||||
|
||||
@ -241,7 +244,7 @@ object BookController {
|
||||
val fileData = parameters["fileData"]?.firstOrNull()
|
||||
?: return returnData.setErrorMsg("fileData 不能为空")
|
||||
kotlin.runCatching {
|
||||
LocalBook.importFileOnLine(fileData, fileName)
|
||||
LocalBook.importFileOnLine(fileData, fileName)
|
||||
}.onFailure {
|
||||
return when (it) {
|
||||
is SecurityException -> returnData.setErrorMsg("需重新设置书籍保存位置!")
|
||||
|
Loading…
Reference in New Issue
Block a user