This commit is contained in:
Horis
2024-08-18 21:51:53 +08:00
parent 61fc6e2e24
commit 177b877963
3 changed files with 11 additions and 8 deletions

View File

@@ -53,6 +53,10 @@ object BookType {
@IntDef(text, updateError, audio, image, webFile, local, archive, notShelf)
annotation class Type
/**
* 所有可以从书源转换的书籍类型
*/
const val allBookType = text or image or audio or webFile
/**
* 本地书籍书源标志

View File

@@ -206,6 +206,10 @@ fun Book.removeType(@BookType.Type vararg types: Int) {
}
}
fun Book.removeAllBookType() {
removeType(BookType.allBookType)
}
fun Book.clearType() {
type = 0
}
@@ -235,10 +239,6 @@ fun BookSource.getBookType(): Int {
}
}
fun BookSource.getAllBookType(): Int {
return BookType.text or BookType.image or BookType.audio or BookType.webFile
}
fun Book.sync(oldBook: Book) {
val curBook = appDb.bookDao.getBook(oldBook.bookUrl)!!
durChapterTime = curBook.durChapterTime

View File

@@ -7,9 +7,8 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.SearchBook
import io.legado.app.exception.NoStackTraceException
import io.legado.app.help.book.addType
import io.legado.app.help.book.getAllBookType
import io.legado.app.help.book.getBookType
import io.legado.app.help.book.removeType
import io.legado.app.help.book.removeAllBookType
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.http.StrResponse
import io.legado.app.model.Debug
@@ -149,7 +148,7 @@ object WebBook {
book: Book,
canReName: Boolean = true,
): Book {
book.removeType(bookSource.getAllBookType())
book.removeAllBookType()
book.addType(bookSource.getBookType())
if (!book.infoHtml.isNullOrEmpty()) {
BookInfo.analyzeBookInfo(
@@ -227,7 +226,7 @@ object WebBook {
book: Book,
runPerJs: Boolean = false
): Result<List<BookChapter>> {
book.removeType(bookSource.getAllBookType())
book.removeAllBookType()
book.addType(bookSource.getBookType())
return kotlin.runCatching {
if (runPerJs) {