From 2f04871e21bed7233b69fbe6c7d0254ab8fa8d17 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 13 Mar 2022 12:06:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/cache/CacheViewModel.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt index 997366b57..769402304 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt @@ -142,7 +142,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { book: Book, append: (text: String, srcList: ArrayList>?) -> Unit ) { - val useReplace = AppConfig.exportUseReplace + val useReplace = AppConfig.exportUseReplace && book.getUseReplaceRule() val contentProcessor = ContentProcessor.get(book.name, book.origin) val qy = "${book.name}\n${ context.getString(R.string.author_show, book.getRealAuthor()) @@ -278,7 +278,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { when { //正文模板 file.name.equals("chapter.html", true) - || file.name.equals("chapter.xhtml", true) -> { + || file.name.equals("chapter.xhtml", true) -> { contentModel = file.readText(context) } //封面等其他模板 @@ -411,7 +411,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { epubBook: EpubBook ) { //正文 - val useReplace = AppConfig.exportUseReplace + val useReplace = AppConfig.exportUseReplace && book.getUseReplaceRule() val contentProcessor = ContentProcessor.get(book.name, book.origin) appDb.bookChapterDao.getChapterList(book.bookUrl).forEachIndexed { index, chapter -> scope.ensureActive() @@ -430,10 +430,14 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { reSegment = false ) .joinToString("\n") + val title = chapter.getDisplayTitle( + contentProcessor.getTitleReplaceRules(), + useReplace = useReplace + ) epubBook.addSection( - chapter.title, + title, ResourceUtil.createChapterResource( - chapter.title.replace("\uD83D\uDD12", ""), + title.replace("\uD83D\uDD12", ""), content1, contentModel, "Text/chapter_${index}.html"