This commit is contained in:
Horis
2024-07-14 10:09:42 +08:00
parent 079bcf7b40
commit b4f6ee0dab
3 changed files with 15 additions and 5 deletions
@@ -307,7 +307,7 @@ fun Book.getExportFileName(
// 根据当前日期计算章节总数
fun Book.simulatedTotalChapterNum(): Int {
return if (config.readSimulating) {
return if (readSimulating()) {
val currentDate = LocalDate.now()
val daysPassed = between(this.config.startDate, currentDate).days + 1
// 计算当前应该解锁到哪一章
@@ -319,6 +319,10 @@ fun Book.simulatedTotalChapterNum(): Int {
}
}
fun Book.readSimulating(): Boolean {
return config.readSimulating
}
fun tryParesExportFileName(jsStr: String): Boolean {
val bindings = SimpleBindings()
bindings["name"] = "name"
@@ -12,6 +12,7 @@ import io.legado.app.help.AppWebDav
import io.legado.app.help.book.BookHelp
import io.legado.app.help.book.ContentProcessor
import io.legado.app.help.book.isLocal
import io.legado.app.help.book.readSimulating
import io.legado.app.help.book.simulatedTotalChapterNum
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ReadBookConfig
@@ -94,7 +95,7 @@ object ReadBook : CoroutineScope by MainScope() {
readRecord.bookName = book.name
readRecord.readTime = appDb.readRecordDao.getReadTime(book.name) ?: 0
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
simulatedChapterSize = if (book.config.readSimulating) {
simulatedChapterSize = if (book.readSimulating()) {
book.simulatedTotalChapterNum()
} else {
chapterSize
@@ -119,7 +120,7 @@ object ReadBook : CoroutineScope by MainScope() {
fun upData(book: Book) {
ReadBook.book = book
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
simulatedChapterSize = if (book.config.readSimulating) {
simulatedChapterSize = if (book.readSimulating()) {
book.simulatedTotalChapterNum()
} else {
chapterSize
@@ -11,6 +11,7 @@ import io.legado.app.data.entities.rule.TocRule
import io.legado.app.exception.NoStackTraceException
import io.legado.app.exception.TocEmptyException
import io.legado.app.help.book.ContentProcessor
import io.legado.app.help.book.readSimulating
import io.legado.app.help.book.simulatedTotalChapterNum
import io.legado.app.help.config.AppConfig
import io.legado.app.model.Debug
@@ -145,9 +146,13 @@ object BookChapterList {
}
}
val replaceRules = ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
val lastChapter = if (book.readSimulating()) {
list.getOrElse(book.simulatedTotalChapterNum() - 1) { list.last() }
} else {
list.last()
}
book.latestChapterTitle =
list.getOrElse(book.simulatedTotalChapterNum() - 1) {
list.last() }.getDisplayTitle(replaceRules, book.getUseReplaceRule())
lastChapter.getDisplayTitle(replaceRules, book.getUseReplaceRule())
book.durChapterTitle = list.getOrElse(book.durChapterIndex) { list.last() }
.getDisplayTitle(replaceRules, book.getUseReplaceRule())
if (book.totalChapterNum < list.size) {