|
|
|
@ -57,7 +57,7 @@ interface JsExtensions { |
|
|
|
|
* 实现文件下载,返回路径 |
|
|
|
|
*/ |
|
|
|
|
fun downloadFile(content: String, url: String): String { |
|
|
|
|
val type = AnalyzeUrl(url).type ?: return "type为空,未下载" |
|
|
|
|
val type = AnalyzeUrl(url).type ?: return "" |
|
|
|
|
val zipPath = FileUtils.getPath( |
|
|
|
|
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), |
|
|
|
|
"${MD5Utils.md5Encode16(url)}.${type}" |
|
|
|
@ -76,6 +76,7 @@ interface JsExtensions { |
|
|
|
|
* js实现压缩文件解压 |
|
|
|
|
*/ |
|
|
|
|
fun unzipFile(zipPath: String): String { |
|
|
|
|
if (zipPath.isEmpty()) return "" |
|
|
|
|
val unzipPath = FileUtils.getPath( |
|
|
|
|
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), |
|
|
|
|
FileUtils.getNameExcludeExtension(zipPath) |
|
|
|
@ -92,6 +93,7 @@ interface JsExtensions { |
|
|
|
|
* js实现文件夹内所有文件读取 |
|
|
|
|
*/ |
|
|
|
|
fun getTxtInFolder(unzipPath: String): String { |
|
|
|
|
if (unzipPath.isEmpty()) return "" |
|
|
|
|
val unzipFolder = FileUtils.createFolderIfNotExist(unzipPath) |
|
|
|
|
val contents = StringBuilder() |
|
|
|
|
unzipFolder.listFiles().let { |
|
|
|
@ -109,7 +111,7 @@ interface JsExtensions { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* js实现重定向拦截,不能删 |
|
|
|
|
* js实现重定向拦截,网络访问get |
|
|
|
|
*/ |
|
|
|
|
fun get(urlStr: String, headers: Map<String, String>): Connection.Response { |
|
|
|
|
return Jsoup.connect(urlStr) |
|
|
|
@ -279,7 +281,7 @@ interface JsExtensions { |
|
|
|
|
val oldCode = s.toInt() |
|
|
|
|
if (font1.InLimit(s)) { |
|
|
|
|
val code = font2.GetCodeByGlyf(font1.GetGlyfByCode(oldCode)) |
|
|
|
|
if(code != 0) contentArray[index] = code.toChar() |
|
|
|
|
if (code != 0) contentArray[index] = code.toChar() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return contentArray.joinToString("") |
|
|
|
|