This commit is contained in:
Horis
2025-04-06 15:46:48 +08:00
parent cab4d4759c
commit 4513739009
7 changed files with 26 additions and 42 deletions
+2 -25
View File
@@ -146,36 +146,13 @@
-keep class **.data.entities.**{*;} -keep class **.data.entities.**{*;}
# hutool-core hutool-crypto # hutool-core hutool-crypto
-keep class -keep class
!cn.hutool.core.io.**,
!cn.hutool.core.img.**,
!cn.hutool.core.map.**,
!cn.hutool.core.date.**,
!cn.hutool.core.bean.**,
!cn.hutool.core.text.**,
!cn.hutool.core.swing.**,
!cn.hutool.core.clone.**,
!cn.hutool.core.thread.**,
!cn.hutool.core.stream.**,
!cn.hutool.core.builder.**,
!cn.hutool.core.convert.**,
!cn.hutool.core.compiler.**,
!cn.hutool.core.annotation.**,
!cn.hutool.core.comparator.**,
!cn.hutool.core.lang.ansi.**,
!cn.hutool.core.lang.reflect.**,
!cn.hutool.core.lang.intern.**,
!cn.hutool.core.lang.loader.**,
!cn.hutool.core.lang.mutable.**,
!cn.hutool.core.lang.tree.**,
!cn.hutool.core.lang.JarClassLoader,
!cn.hutool.core.lang.ResourceClassLoader,
!cn.hutool.core.lang.Singleton,
!cn.hutool.core.util.RuntimeUtil, !cn.hutool.core.util.RuntimeUtil,
!cn.hutool.core.util.ClassLoaderUtil, !cn.hutool.core.util.ClassLoaderUtil,
!cn.hutool.core.util.ReflectUtil, !cn.hutool.core.util.ReflectUtil,
!cn.hutool.core.util.SerializeUtil, !cn.hutool.core.util.SerializeUtil,
!cn.hutool.core.util.ClassUtil, !cn.hutool.core.util.ClassUtil,
cn.hutool.core.**{*;} cn.hutool.core.codec.**,
cn.hutool.core.util.**{*;}
-keep class cn.hutool.crypto.**{*;} -keep class cn.hutool.crypto.**{*;}
-dontwarn cn.hutool.** -dontwarn cn.hutool.**
# 缓存 Cookie # 缓存 Cookie
@@ -1,5 +1,6 @@
package io.legado.app.help package io.legado.app.help
import androidx.annotation.Keep
import androidx.collection.LruCache import androidx.collection.LruCache
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.Cache import io.legado.app.data.entities.Cache
@@ -7,6 +8,7 @@ import io.legado.app.model.analyzeRule.QueryTTF
import io.legado.app.utils.ACache import io.legado.app.utils.ACache
import io.legado.app.utils.memorySize import io.legado.app.utils.memorySize
@Keep
@Suppress("unused") @Suppress("unused")
object CacheManager { object CacheManager {
@@ -13,6 +13,7 @@ import io.legado.app.utils.MD5Utils
* js加解密扩展类, 在js中通过java变量调用 * js加解密扩展类, 在js中通过java变量调用
* 添加方法,请更新文档/legado/app/src/main/assets/help/JsHelp.md * 添加方法,请更新文档/legado/app/src/main/assets/help/JsHelp.md
*/ */
@Suppress("unused")
interface JsEncodeUtils { interface JsEncodeUtils {
fun md5Encode(str: String): String { fun md5Encode(str: String): String {
@@ -12,6 +12,7 @@ import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.BaseSource import io.legado.app.data.entities.BaseSource
import io.legado.app.exception.NoStackTraceException import io.legado.app.exception.NoStackTraceException
import io.legado.app.help.config.AppConfig
import io.legado.app.help.http.BackstageWebView import io.legado.app.help.http.BackstageWebView
import io.legado.app.help.http.CookieManager.cookieJarHeader import io.legado.app.help.http.CookieManager.cookieJarHeader
import io.legado.app.help.http.CookieStore import io.legado.app.help.http.CookieStore
@@ -41,6 +42,7 @@ import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.isContentScheme import io.legado.app.utils.isContentScheme
import io.legado.app.utils.isUri import io.legado.app.utils.isUri
import io.legado.app.utils.longToastOnUi import io.legado.app.utils.longToastOnUi
import io.legado.app.utils.mapParallel
import io.legado.app.utils.readBytes import io.legado.app.utils.readBytes
import io.legado.app.utils.readText import io.legado.app.utils.readText
import io.legado.app.utils.stackTraceStr import io.legado.app.utils.stackTraceStr
@@ -48,7 +50,9 @@ import io.legado.app.utils.startActivity
import io.legado.app.utils.toStringArray import io.legado.app.utils.toStringArray
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.async import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import okio.use import okio.use
import org.jsoup.Connection import org.jsoup.Connection
@@ -114,19 +118,12 @@ interface JsExtensions : JsEncodeUtils {
/** /**
* 并发访问网络 * 并发访问网络
*/ */
fun ajaxAll(urlList: Array<String>): Array<StrResponse?> { fun ajaxAll(urlList: Array<String>): Array<StrResponse> {
return runBlocking(context) { return runBlocking(context) {
val asyncArray = Array(urlList.size) { urlList.asFlow().mapParallel(AppConfig.threadCount) { url ->
async(IO) { val analyzeUrl = AnalyzeUrl(url, source = getSource())
val url = urlList[it] analyzeUrl.getStrResponseAwait()
val analyzeUrl = AnalyzeUrl(url, source = getSource()) }.flowOn(IO).toList().toTypedArray()
analyzeUrl.getStrResponseAwait()
}
}
val resArray = Array<StrResponse?>(urlList.size) {
asyncArray[it].await()
}
resArray
} }
} }
@@ -3,6 +3,7 @@
package io.legado.app.help.http package io.legado.app.help.http
import android.text.TextUtils import android.text.TextUtils
import androidx.annotation.Keep
import io.legado.app.constant.AppLog import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern.equalsRegex import io.legado.app.constant.AppPattern.equalsRegex
import io.legado.app.constant.AppPattern.semicolonRegex import io.legado.app.constant.AppPattern.semicolonRegex
@@ -15,6 +16,7 @@ import io.legado.app.help.http.api.CookieManagerInterface
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.removeCookie import io.legado.app.utils.removeCookie
@Keep
object CookieStore : CookieManagerInterface { object CookieStore : CookieManagerInterface {
/** /**
@@ -13,7 +13,6 @@ import okhttp3.Cookie
import okhttp3.CookieJar import okhttp3.CookieJar
import okhttp3.Credentials import okhttp3.Credentials
import okhttp3.HttpUrl import okhttp3.HttpUrl
import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import java.net.InetSocketAddress import java.net.InetSocketAddress
import java.net.Proxy import java.net.Proxy
@@ -68,7 +67,7 @@ val okHttpClient: OkHttpClient by lazy {
.followRedirects(true) .followRedirects(true)
.followSslRedirects(true) .followSslRedirects(true)
.addInterceptor(OkHttpExceptionInterceptor) .addInterceptor(OkHttpExceptionInterceptor)
.addInterceptor(Interceptor { chain -> .addInterceptor { chain ->
val request = chain.request() val request = chain.request()
val builder = request.newBuilder() val builder = request.newBuilder()
if (request.header(AppConst.UA_NAME) == null) { if (request.header(AppConst.UA_NAME) == null) {
@@ -80,7 +79,7 @@ val okHttpClient: OkHttpClient by lazy {
builder.addHeader("Connection", "Keep-Alive") builder.addHeader("Connection", "Keep-Alive")
builder.addHeader("Cache-Control", "no-cache") builder.addHeader("Cache-Control", "no-cache")
chain.proceed(builder.build()) chain.proceed(builder.build())
}) }
.addNetworkInterceptor { chain -> .addNetworkInterceptor { chain ->
var request = chain.request() var request = chain.request()
val enableCookieJar = request.header(cookieJarHeader) != null val enableCookieJar = request.header(cookieJarHeader) != null
@@ -1,11 +1,17 @@
package io.legado.app.help.http package io.legado.app.help.http
import okhttp3.* import androidx.annotation.Keep
import okhttp3.Headers
import okhttp3.Protocol
import okhttp3.Request
import okhttp3.Response
import okhttp3.Response.Builder import okhttp3.Response.Builder
import okhttp3.ResponseBody
/** /**
* An HTTP response. * An HTTP response.
*/ */
@Keep
@Suppress("unused", "MemberVisibilityCanBePrivate") @Suppress("unused", "MemberVisibilityCanBePrivate")
class StrResponse { class StrResponse {
var raw: Response var raw: Response