diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 2de034c99..e10b8d9be 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,7 +2,7 @@ * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 * 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 -**2020/01/01** +**2020/03/01** * 修复书源解析的一个bug * 添加底部操作栏颜色配置 * 修复滚动点击翻页,修复滚动最后一页显示加载中 diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index f1c92e798..9ac402267 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -8,10 +8,7 @@ import io.legado.app.constant.Pattern.EXP_PATTERN import io.legado.app.constant.Pattern.JS_PATTERN import io.legado.app.data.entities.BaseBook import io.legado.app.help.JsExtensions -import io.legado.app.help.http.AjaxWebView -import io.legado.app.help.http.HttpHelper -import io.legado.app.help.http.RequestMethod -import io.legado.app.help.http.Res +import io.legado.app.help.http.* import io.legado.app.help.http.api.HttpGetApi import io.legado.app.help.http.api.HttpPostApi import io.legado.app.utils.* @@ -243,7 +240,11 @@ class AnalyzeUrl( } @Throws(Exception::class) - fun getResponse(): Call { + fun getResponse(tag: String): Call { + val cookie = CookieStore.getCookie(tag) + if (cookie.isNotEmpty()) { + headerMap["Cookie"] = cookie + } return when { method == RequestMethod.POST -> { if (fieldMap.isNotEmpty()) { @@ -267,7 +268,7 @@ class AnalyzeUrl( @Throws(Exception::class) suspend fun getResponseAwait( - tag: String? = null, + tag: String, jsStr: String? = null, sourceRegex: String? = null ): Res { @@ -278,8 +279,13 @@ class AnalyzeUrl( params.javaScript = jsStr params.sourceRegex = sourceRegex params.postData = bodyTxt?.toByteArray() + params.tag = tag return HttpHelper.ajax(params) } + val cookie = CookieStore.getCookie(tag) + if (cookie.isNotEmpty()) { + headerMap["Cookie"] = cookie + } val res = when { method == RequestMethod.POST -> { if (fieldMap.isNotEmpty()) { diff --git a/app/src/main/java/io/legado/app/ui/login/SourceLogin.kt b/app/src/main/java/io/legado/app/ui/login/SourceLogin.kt index 05be53788..a0703aef3 100644 --- a/app/src/main/java/io/legado/app/ui/login/SourceLogin.kt +++ b/app/src/main/java/io/legado/app/ui/login/SourceLogin.kt @@ -14,6 +14,8 @@ import io.legado.app.base.BaseActivity import io.legado.app.data.entities.Cookie import io.legado.app.utils.snackbar import kotlinx.android.synthetic.main.activity_source_login.* +import kotlinx.coroutines.Dispatchers.IO +import kotlinx.coroutines.launch class SourceLogin : BaseActivity(R.layout.activity_source_login) { @@ -74,8 +76,10 @@ class SourceLogin : BaseActivity(R.layout.activity_source_login) { } private fun saveCookie(cookie: String) { - sourceUrl?.let { - App.db.cookieDao().insert(Cookie(it, cookie)) + launch(IO) { + sourceUrl?.let { + App.db.cookieDao().insert(Cookie(it, cookie)) + } } } } \ No newline at end of file