From 1f9b8d0d8b2a8b253ab92e316ccf72f0f9521c85 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sat, 7 May 2022 13:53:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E6=A0=A1=E9=AA=8Cbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/service/CheckSourceService.kt | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 9e145b62e..a7a81b924 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -135,17 +135,19 @@ class CheckSourceService : BaseService() { ?.filterNot { it.startsWith("Error: ") }?.joinToString("\n") - //校验搜索书籍 用户设置校验搜索 并且 搜索链接不为空 - if (CheckSource.checkSearch && !source.searchUrl.isNullOrBlank()) { - val searchBooks = WebBook.searchBookAwait(this, source, searchWord) - if (searchBooks.isEmpty()) { - source.addGroup("搜索失效") - if (!CheckSource.checkDiscovery) { - throw NoStackTraceException("搜索书籍为空") + //校验搜索书籍 + if (CheckSource.checkSearch) { + if (!source.searchUrl.isNullOrBlank()) { + source.removeGroup("搜索链接规则为空") + val searchBooks = WebBook.searchBookAwait(this, source, searchWord) + if (searchBooks.isEmpty()) { + source.addGroup("搜索失效") + } else { + source.removeGroup("搜索失效") + checkBook(searchBooks.first().toBook(), source) } } else { - source.removeGroup("搜索失效") - checkBook(searchBooks.first().toBook(), source) + source.addGroup("搜索链接规则为空") } } //校验发现书籍 @@ -159,18 +161,12 @@ class CheckSourceService : BaseService() { } } if (url.isNullOrBlank()) { - when { - !CheckSource.checkSearch -> throw NoStackTraceException("没有发现") - source.hasGroup("搜索失效") -> throw NoStackTraceException("搜索内容为空并且没有发现") - } + source.addGroup("发现规则为空") } else { + source.removeGroup("发现规则为空") val exploreBooks = WebBook.exploreBookAwait(this, source, url) if (exploreBooks.isEmpty()) { source.addGroup("发现失效") - when { - !CheckSource.checkSearch -> throw NoStackTraceException("发现书籍为空") - source.hasGroup("搜索失效") -> throw NoStackTraceException("搜索内容和发现书籍为空") - } } else { source.removeGroup("发现失效") checkBook(exploreBooks.first().toBook(), source, false) From 17f4be037a292dc9c7004529ecc37303bf8f8989 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sat, 7 May 2022 15:49:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E5=8F=96=E6=B6=88=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=81=9C=E6=AD=A2=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/SourceVerificationHelp.kt | 8 +++++--- .../legado/app/ui/association/VerificationCodeDialog.kt | 5 ++--- .../main/java/io/legado/app/ui/browser/WebViewActivity.kt | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt b/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt index 8efbf914b..39aac0747 100644 --- a/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt @@ -12,6 +12,7 @@ import splitties.init.appCtx object SourceVerificationHelp { + private var key: String = "" /** * 获取书源验证结果 * 图片验证码 防爬 滑动验证码 点击字符 等等 @@ -19,7 +20,7 @@ object SourceVerificationHelp { fun getVerificationResult(source: BaseSource?, url: String, title: String, useBrowser: Boolean): String { source ?: throw NoStackTraceException("getVerificationResult parameter source cannot be null") return runBlocking { - val key = "${source.getKey()}_verificationResult" + key = "${source.getKey()}_verificationResult" CacheManager.delete(key) if (!useBrowser) { @@ -52,6 +53,7 @@ object SourceVerificationHelp { */ fun startBrowser(source: BaseSource?, url: String, title: String, saveResult: Boolean? = false) { source ?: throw NoStackTraceException("startBrowser parameter source cannot be null") + key = "${source.getKey()}_verificationResult" appCtx.startActivity { putExtra("title", title) putExtra("url", url) @@ -61,7 +63,7 @@ object SourceVerificationHelp { } } - private fun checkActivityStatus(): Boolean { - return true + fun checkResult() { + CacheManager.get(key) ?: CacheManager.putMemory(key, "") } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt b/app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt index 57460eb09..a3b7dd656 100644 --- a/app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt @@ -12,6 +12,7 @@ import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.databinding.DialogVerificationCodeViewBinding import io.legado.app.help.CacheManager +import io.legado.app.help.SourceVerificationHelp import io.legado.app.help.glide.ImageLoader import io.legado.app.help.glide.OkHttpModelLoader import io.legado.app.lib.theme.primaryColor @@ -91,9 +92,7 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification } override fun onDestroy() { - val sourceOrigin = arguments?.getString("sourceOrigin") - val key = "${sourceOrigin}_verificationResult" - CacheManager.get(key) ?: CacheManager.putMemory(key, "") + SourceVerificationHelp.checkResult() super.onDestroy() activity?.finish() } diff --git a/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt b/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt index 055d3509c..2f5de2a23 100644 --- a/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt +++ b/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt @@ -17,6 +17,7 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst import io.legado.app.databinding.ActivityWebViewBinding +import io.legado.app.help.SourceVerificationHelp import io.legado.app.help.config.AppConfig import io.legado.app.help.http.CookieStore import io.legado.app.lib.dialogs.SelectItem @@ -182,6 +183,7 @@ class WebViewActivity : VMBaseActivity() { } override fun onDestroy() { + SourceVerificationHelp.checkResult() super.onDestroy() binding.webView.destroy() }