This commit is contained in:
kunfei 2023-01-16 11:59:53 +08:00
parent 17e0544e07
commit a5f45e9e98
2 changed files with 28 additions and 3 deletions

View File

@ -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
*/

View File

@ -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)
?: ""
}