From 7e469d144b1e3336f59ef52189c29b137b5e60ea Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 26 Aug 2021 13:46:27 +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 --- .../java/io/legado/app/data/entities/BaseSource.kt | 14 +++++++++++++- .../java/io/legado/app/data/entities/BookSource.kt | 2 +- .../java/io/legado/app/data/entities/RssSource.kt | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BaseSource.kt b/app/src/main/java/io/legado/app/data/entities/BaseSource.kt index cab31e55d..01fdec156 100644 --- a/app/src/main/java/io/legado/app/data/entities/BaseSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BaseSource.kt @@ -17,9 +17,21 @@ import javax.script.SimpleBindings @Suppress("unused") interface BaseSource : JsExtensions { + var loginUrl: String? + var header: String? + fun getStoreUrl(): String - var header: String? + fun getLoginJs(): String? { + val loginJs = loginUrl + return when { + loginJs == null -> null + loginJs.startsWith("@js:") -> loginJs.substring(4) + loginJs.startsWith("") -> + loginJs.substring(4, loginJs.lastIndexOf("<")) + else -> loginJs + } + } /** * 解析header规则 diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index a6e4a4bff..4339e0875 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -28,7 +28,7 @@ data class BookSource( var enabled: Boolean = true, // 是否启用 var enabledExplore: Boolean = true, // 启用发现 override var header: String? = null, // 请求头 - var loginUrl: String? = null, // 登录地址 + override var loginUrl: String? = null, // 登录地址 var loginUi: List? = null, //登录UI var loginCheckJs: String? = null, //登录检测js var bookSourceComment: String? = null, // 注释 diff --git a/app/src/main/java/io/legado/app/data/entities/RssSource.kt b/app/src/main/java/io/legado/app/data/entities/RssSource.kt index 162e1f1d9..0a933883b 100644 --- a/app/src/main/java/io/legado/app/data/entities/RssSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/RssSource.kt @@ -21,7 +21,7 @@ data class RssSource( var sourceComment: String? = null, var enabled: Boolean = true, override var header: String? = null, // 请求头 - var loginUrl: String? = null, // 登录地址 + override var loginUrl: String? = null, // 登录地址 var loginUi: List? = null, //登录UI var loginCheckJs: String? = null, //登录检测js var sortUrl: String? = null,