diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 18222d870..d99977101 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -318,23 +318,24 @@ object BookHelp { } suspend fun disposeContent( + book: Book, title: String, - name: String, - origin: String?, content: String, - enableReplace: Boolean, ): List { var title1 = title var content1 = content - if (enableReplace) { + if (book.getReSegment()) { + content1 = ContentHelp.reSegment(content1, title1) + } + if (book.getUseReplaceRule()) { synchronized(this) { - if (bookName != name || bookOrigin != origin) { - bookName = name - bookOrigin = origin - replaceRules = if (origin.isNullOrEmpty()) { - App.db.replaceRuleDao().findEnabledByScope(name) + if (bookName != book.name || bookOrigin != book.origin) { + bookName = book.name + bookOrigin = book.origin + replaceRules = if (bookOrigin.isNullOrEmpty()) { + App.db.replaceRuleDao().findEnabledByScope(bookName!!) } else { - App.db.replaceRuleDao().findEnabledByScope(name, origin) + App.db.replaceRuleDao().findEnabledByScope(bookName!!, bookOrigin!!) } } } diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 54e772a46..3ed6c7809 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -378,13 +378,7 @@ object ReadBook { 2 -> HanLP.convertToTraditionalChinese(chapter.title) else -> chapter.title } - val contents = BookHelp.disposeContent( - chapter.title, - book.name, - webBook?.bookSource?.bookSourceUrl, - content, - book.getUseReplaceRule() - ) + val contents = BookHelp.disposeContent(book, chapter.title, content) when (chapter.index) { durChapterIndex -> { curTextChapter = diff --git a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt index 270c99f12..fe28e2373 100644 --- a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt @@ -177,13 +177,7 @@ class SearchContentActivity : 2 -> HanLP.convertToTraditionalChinese(chapter.title) else -> chapter.title } - replaceContents = BookHelp.disposeContent( - chapter.title, - book.name, - book.bookUrl, - bookContent, - book.getUseReplaceRule() - ) + replaceContents = BookHelp.disposeContent(book, chapter.title, bookContent) } job.await() while (replaceContents == null) {