From a13ed0453bed7c91bead9d89aafc6f0b9ce9984c Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 4 Jan 2022 16:19:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B8=AE=E5=8A=A9=E6=96=87?= =?UTF-8?q?=E6=A1=A3;=E6=9B=B4=E6=96=B0cacheFile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/help/ruleHelp.md | 17 +++++++++++++++-- .../java/io/legado/app/help/JsExtensions.kt | 5 +++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/assets/help/ruleHelp.md b/app/src/main/assets/help/ruleHelp.md index 043677f4b..b2b1bb0b8 100644 --- a/app/src/main/assets/help/ruleHelp.md +++ b/app/src/main/assets/help/ruleHelp.md @@ -31,8 +31,21 @@ * 获取登录后的cookie ``` -java.getCookie("http://baidu.com", null) => userid=1234;pwd=adbcd -java.getCookie("http://baidu.com", "userid") => 1234 +获取全部 +cookie.getCookie(url) +获取某一键值 +cookie.getKey(url,key) +``` + +* 缓存网络文件 +``` +获取 +java.cacheFile(url) +java.cacheFile(url,saveTime) +执行内容 +eval(String(java.cacheFile(url))) +删除缓存文件 +cache.delete(java.md5Encode16(url)) ``` * 请求头,支持http代理,socks4 socks5代理设置 diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index b84ed8f7b..d420a32de 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -139,8 +139,9 @@ interface JsExtensions { fun cacheFile(url: String, saveTime: Int = 0): String? { val key = md5Encode16(url) val _cache = CacheManager.get(key) - val value = ajax(url) ?: "" - if(_cache.isNullOrBlank()) { + if(_cache.isNullOrBlank()) { + log("首次下载${url}...") + val value = ajax(url) ?: "" CacheManager.put(key, value as Any, saveTime) } return _cache