mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
17e0544e07
commit
a5f45e9e98
@ -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…
Reference in New Issue
Block a user