[修复] 某些情况下,发现没有数据的问题

This commit is contained in:
HapeLee committed 2025-11-29 14:55:44 +08:00
1 parent 573cc15817
commit 3720847ebb
1 file changed
+10 -5
@@ -5,8 +5,10 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.SearchBook import io.legado.app.data.entities.SearchBook
import io.legado.app.help.book.isNotShelf import io.legado.app.help.book.isNotShelf
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.withContext
interface ExploreRepository { interface ExploreRepository {
fun getBookshelfItems(): Flow<List<SearchBook>> fun getBookshelfItems(): Flow<List<SearchBook>>
@@ -31,11 +33,14 @@ class ExploreRepositoryImpl(
} }
override suspend fun exploreBook(source: BookSource, url: String, page: Int): Result<List<SearchBook>> { override suspend fun exploreBook(source: BookSource, url: String, page: Int): Result<List<SearchBook>> {
return try { return withContext(Dispatchers.IO) {
val books = WebBook.exploreBookSuspend(source, url, page) try {
Result.success(books) val books = WebBook.exploreBookSuspend(source, url, page)
} catch (e: Exception) { Result.success(books)
Result.failure(e) } catch (e: Exception) {
e.printStackTrace()
Result.failure(e)
}
} }
} }