Merge pull request #1527 from Xwite/master

fix:一级标题相同目录缺失;阅读界面显示优化
This commit is contained in:
kunfei 2022-01-13 18:55:39 +08:00 committed by GitHub
commit 715902d61a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 deletions

View File

@ -109,6 +109,8 @@ data class BookChapter(
}
fun getAbsoluteURL(): String {
//二级目录解析的卷链接为空 返回目录页的链接
if (url.startsWith(title) && isVolume) return baseUrl
val urlMatcher = AnalyzeUrl.paramPattern.matcher(url)
val urlBefore = if (urlMatcher.find()) url.substring(0, urlMatcher.start()) else url
val urlAbsoluteBefore = NetworkUtils.getAbsoluteURL(baseUrl, urlBefore)

View File

@ -193,8 +193,8 @@ object BookChapterList {
}
if (bookChapter.url.isEmpty()) {
if (bookChapter.isVolume) {
bookChapter.url = bookChapter.title
Debug.log(bookSource.bookSourceUrl, "一级目录${index}未获取到url,使用章节标题替代")
bookChapter.url = bookChapter.title + index
Debug.log(bookSource.bookSourceUrl, "一级目录${index}未获取到url,使用${bookChapter.title}${index}替代")
} else {
bookChapter.url = baseUrl
Debug.log(bookSource.bookSourceUrl, "目录${index}未获取到url,使用baseUrl替代")

View File

@ -261,8 +261,8 @@ object WebBook {
Debug.log(bookSource.bookSourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}")
return bookChapter.url
}
if(bookChapter.isVolume && bookChapter.url == bookChapter.title) {
Debug.log(bookSource.bookSourceUrl, "⇒一级目录获取链接为空,使用${bookChapter.tag}")
if(bookChapter.isVolume && bookChapter.url.startsWith(bookChapter.title)) {
Debug.log(bookSource.bookSourceUrl, "⇒一级目录正文不解析规则")
return bookChapter.tag ?: ""
}
return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {

View File

@ -129,7 +129,7 @@ object ChapterProvider {
matcher.appendTail(sb)
text = sb.toString()
val isTitle = index == 0
val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank()
val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1
val textPaint = if (isTitle) titlePaint else contentPaint
if (!(isTitle && ReadBookConfig.titleMode == 2)) {
setTypeText(
@ -147,7 +147,7 @@ object ChapterProvider {
val text = content.substring(start, matcher.start())
if (text.isNotBlank()) {
val isTitle = index == 0
val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank()
val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1
val textPaint = if (isTitle) titlePaint else contentPaint
if (!(isTitle && ReadBookConfig.titleMode == 2)) {
setTypeText(
@ -169,7 +169,7 @@ object ChapterProvider {
val text = content.substring(start, content.length)
if (text.isNotBlank()) {
val isTitle = index == 0
val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank()
val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1
val textPaint = if (isTitle) titlePaint else contentPaint
if (!(isTitle && ReadBookConfig.titleMode == 2)) {
setTypeText(