pull/2706/head
kunfei 2 years ago
parent 17e0544e07
commit a5f45e9e98
  1. 23
      app/src/main/java/io/legado/app/data/entities/BaseSource.kt
  2. 8
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -52,8 +52,8 @@ interface BaseSource : JsExtensions {
fun loginUi(): List<RowUi>? {
return GSON.fromJsonArray<RowUi>(loginUi).onFailure {
it.printOnDebug()
}.getOrNull()
it.printOnDebug()
}.getOrNull()
}
fun getLoginJs(): String? {
@ -66,7 +66,9 @@ interface BaseSource : JsExtensions {
}
}
// 调用login函数 实现登录请求
/**
* 调用login函数 实现登录请求
*/
fun login() {
val loginJs = getLoginJs()
if (!loginJs.isNullOrBlank()) {
@ -198,6 +200,21 @@ interface BaseSource : JsExtensions {
return CacheManager.get("sourceVariable_${getKey()}")
}
/**
* 保存数据
*/
fun put(key: String, value: String): String {
CacheManager.put("v_${getKey()}_${key}", value)
return value
}
/**
* 获取保存的数据
*/
fun get(key: String): String {
return CacheManager.get("v_${getKey()}_${key}") ?: ""
}
/**
* 执行JS
*/

@ -610,13 +610,20 @@ class AnalyzeRule(
XPath, Json, Default, Js, Regex
}
/**
* 保存数据
*/
fun put(key: String, value: String): String {
chapter?.putVariable(key, value)
?: book?.putVariable(key, value)
?: ruleData?.putVariable(key, value)
?: source?.put(key, value)
return value
}
/**
* 获取保存的数据
*/
fun get(key: String): String {
when (key) {
"bookName" -> book?.let {
@ -629,6 +636,7 @@ class AnalyzeRule(
return chapter?.getVariable(key)
?: book?.getVariable(key)
?: ruleData?.getVariable(key)
?: source?.get(key)
?: ""
}

Loading…
Cancel
Save