优化
This commit is contained in:
@@ -307,7 +307,7 @@ fun Book.getExportFileName(
|
|||||||
|
|
||||||
// 根据当前日期计算章节总数
|
// 根据当前日期计算章节总数
|
||||||
fun Book.simulatedTotalChapterNum(): Int {
|
fun Book.simulatedTotalChapterNum(): Int {
|
||||||
return if (config.readSimulating) {
|
return if (readSimulating()) {
|
||||||
val currentDate = LocalDate.now()
|
val currentDate = LocalDate.now()
|
||||||
val daysPassed = between(this.config.startDate, currentDate).days + 1
|
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 {
|
fun tryParesExportFileName(jsStr: String): Boolean {
|
||||||
val bindings = SimpleBindings()
|
val bindings = SimpleBindings()
|
||||||
bindings["name"] = "name"
|
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.BookHelp
|
||||||
import io.legado.app.help.book.ContentProcessor
|
import io.legado.app.help.book.ContentProcessor
|
||||||
import io.legado.app.help.book.isLocal
|
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.book.simulatedTotalChapterNum
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
import io.legado.app.help.config.ReadBookConfig
|
import io.legado.app.help.config.ReadBookConfig
|
||||||
@@ -94,7 +95,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
readRecord.bookName = book.name
|
readRecord.bookName = book.name
|
||||||
readRecord.readTime = appDb.readRecordDao.getReadTime(book.name) ?: 0
|
readRecord.readTime = appDb.readRecordDao.getReadTime(book.name) ?: 0
|
||||||
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
|
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
|
||||||
simulatedChapterSize = if (book.config.readSimulating) {
|
simulatedChapterSize = if (book.readSimulating()) {
|
||||||
book.simulatedTotalChapterNum()
|
book.simulatedTotalChapterNum()
|
||||||
} else {
|
} else {
|
||||||
chapterSize
|
chapterSize
|
||||||
@@ -119,7 +120,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
fun upData(book: Book) {
|
fun upData(book: Book) {
|
||||||
ReadBook.book = book
|
ReadBook.book = book
|
||||||
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
|
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
|
||||||
simulatedChapterSize = if (book.config.readSimulating) {
|
simulatedChapterSize = if (book.readSimulating()) {
|
||||||
book.simulatedTotalChapterNum()
|
book.simulatedTotalChapterNum()
|
||||||
} else {
|
} else {
|
||||||
chapterSize
|
chapterSize
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import io.legado.app.data.entities.rule.TocRule
|
|||||||
import io.legado.app.exception.NoStackTraceException
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.exception.TocEmptyException
|
import io.legado.app.exception.TocEmptyException
|
||||||
import io.legado.app.help.book.ContentProcessor
|
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.book.simulatedTotalChapterNum
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
import io.legado.app.model.Debug
|
import io.legado.app.model.Debug
|
||||||
@@ -145,9 +146,13 @@ object BookChapterList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val replaceRules = ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
|
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 =
|
book.latestChapterTitle =
|
||||||
list.getOrElse(book.simulatedTotalChapterNum() - 1) {
|
lastChapter.getDisplayTitle(replaceRules, book.getUseReplaceRule())
|
||||||
list.last() }.getDisplayTitle(replaceRules, book.getUseReplaceRule())
|
|
||||||
book.durChapterTitle = list.getOrElse(book.durChapterIndex) { list.last() }
|
book.durChapterTitle = list.getOrElse(book.durChapterIndex) { list.last() }
|
||||||
.getDisplayTitle(replaceRules, book.getUseReplaceRule())
|
.getDisplayTitle(replaceRules, book.getUseReplaceRule())
|
||||||
if (book.totalChapterNum < list.size) {
|
if (book.totalChapterNum < list.size) {
|
||||||
|
|||||||
Reference in New Issue
Block a user