pull/1705/head
kunfei 3 years ago
parent 9f47450767
commit 2f04871e21
  1. 14
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt

@ -142,7 +142,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
book: Book, book: Book,
append: (text: String, srcList: ArrayList<Triple<String, Int, String>>?) -> Unit append: (text: String, srcList: ArrayList<Triple<String, Int, String>>?) -> Unit
) { ) {
val useReplace = AppConfig.exportUseReplace val useReplace = AppConfig.exportUseReplace && book.getUseReplaceRule()
val contentProcessor = ContentProcessor.get(book.name, book.origin) val contentProcessor = ContentProcessor.get(book.name, book.origin)
val qy = "${book.name}\n${ val qy = "${book.name}\n${
context.getString(R.string.author_show, book.getRealAuthor()) context.getString(R.string.author_show, book.getRealAuthor())
@ -278,7 +278,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
when { when {
//正文模板 //正文模板
file.name.equals("chapter.html", true) file.name.equals("chapter.html", true)
|| file.name.equals("chapter.xhtml", true) -> { || file.name.equals("chapter.xhtml", true) -> {
contentModel = file.readText(context) contentModel = file.readText(context)
} }
//封面等其他模板 //封面等其他模板
@ -411,7 +411,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
epubBook: EpubBook epubBook: EpubBook
) { ) {
//正文 //正文
val useReplace = AppConfig.exportUseReplace val useReplace = AppConfig.exportUseReplace && book.getUseReplaceRule()
val contentProcessor = ContentProcessor.get(book.name, book.origin) val contentProcessor = ContentProcessor.get(book.name, book.origin)
appDb.bookChapterDao.getChapterList(book.bookUrl).forEachIndexed { index, chapter -> appDb.bookChapterDao.getChapterList(book.bookUrl).forEachIndexed { index, chapter ->
scope.ensureActive() scope.ensureActive()
@ -430,10 +430,14 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
reSegment = false reSegment = false
) )
.joinToString("\n") .joinToString("\n")
val title = chapter.getDisplayTitle(
contentProcessor.getTitleReplaceRules(),
useReplace = useReplace
)
epubBook.addSection( epubBook.addSection(
chapter.title, title,
ResourceUtil.createChapterResource( ResourceUtil.createChapterResource(
chapter.title.replace("\uD83D\uDD12", ""), title.replace("\uD83D\uDD12", ""),
content1, content1,
contentModel, contentModel,
"Text/chapter_${index}.html" "Text/chapter_${index}.html"

Loading…
Cancel
Save