|
|
@ -8,7 +8,6 @@ import io.legado.app.constant.AppConst |
|
|
|
import io.legado.app.constant.AppConst.dateFormat |
|
|
|
import io.legado.app.constant.AppConst.dateFormat |
|
|
|
import io.legado.app.data.entities.BaseSource |
|
|
|
import io.legado.app.data.entities.BaseSource |
|
|
|
import io.legado.app.help.http.* |
|
|
|
import io.legado.app.help.http.* |
|
|
|
import io.legado.app.help.CacheManager |
|
|
|
|
|
|
|
import io.legado.app.model.Debug |
|
|
|
import io.legado.app.model.Debug |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.model.analyzeRule.QueryTTF |
|
|
|
import io.legado.app.model.analyzeRule.QueryTTF |
|
|
@ -126,25 +125,41 @@ interface JsExtensions { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 缓存网络文件 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun cacheFile(urlStr: String): String? { |
|
|
|
|
|
|
|
return cacheFile(urlStr, 0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 缓存网络文件 |
|
|
|
* 缓存网络文件 |
|
|
|
* @param url 网络文件的链接 |
|
|
|
* @param url 网络文件的链接 |
|
|
|
* @param saveTime 缓存时间,单位:秒 |
|
|
|
* @param saveTime 缓存时间,单位:秒 |
|
|
|
* @return 返回缓存后的文件内容 |
|
|
|
* @return 返回缓存后的文件内容 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun cacheFile(url: String): String? { |
|
|
|
|
|
|
|
return cacheFile(url, 0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun cacheFile(url: String, saveTime: Int = 0): String? { |
|
|
|
fun cacheFile(url: String, saveTime: Int = 0): String? { |
|
|
|
val key = md5Encode16(url) |
|
|
|
val key = md5Encode16(url) |
|
|
|
val _cache = CacheManager.get(key) |
|
|
|
val cache = CacheManager.get(key) |
|
|
|
if(_cache.isNullOrBlank()) { |
|
|
|
if (cache.isNullOrBlank()) { |
|
|
|
log("首次下载${url}...") |
|
|
|
log("首次下载${url}...") |
|
|
|
val value = ajax(url) ?: "" |
|
|
|
val value = ajax(url) ?: "" |
|
|
|
CacheManager.put(key, value as Any, saveTime) |
|
|
|
CacheManager.put(key, value as Any, saveTime) |
|
|
|
} |
|
|
|
} |
|
|
|
return _cache |
|
|
|
return cache |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
*js实现读取cookie |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun getCookie(tag: String, key: String? = null): String { |
|
|
|
|
|
|
|
val cookie = CookieStore.getCookie(tag) |
|
|
|
|
|
|
|
val cookieMap = CookieStore.cookieToMap(cookie) |
|
|
|
|
|
|
|
return if (key != null) { |
|
|
|
|
|
|
|
cookieMap[key] ?: "" |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
cookie |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -284,7 +299,7 @@ interface JsExtensions { |
|
|
|
return HtmlFormatter.formatKeepImg(str) |
|
|
|
return HtmlFormatter.formatKeepImg(str) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//****************文件操作******************// |
|
|
|
//****************文件操作******************// |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取本地文件 |
|
|
|
* 获取本地文件 |
|
|
@ -419,7 +434,7 @@ interface JsExtensions { |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//******************文件操作************************// |
|
|
|
//******************文件操作************************// |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 解析字体,返回字体解析类 |
|
|
|
* 解析字体,返回字体解析类 |
|
|
|