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

View File

@@ -146,36 +146,13 @@
-keep class **.data.entities.**{*;}
# hutool-core hutool-crypto
-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.ClassLoaderUtil,
!cn.hutool.core.util.ReflectUtil,
!cn.hutool.core.util.SerializeUtil,
!cn.hutool.core.util.ClassUtil,
cn.hutool.core.**{*;}
cn.hutool.core.codec.**,
cn.hutool.core.util.**{*;}
-keep class cn.hutool.crypto.**{*;}
-dontwarn cn.hutool.**
# 缓存 Cookie

View File

@@ -1,5 +1,6 @@
package io.legado.app.help
import androidx.annotation.Keep
import androidx.collection.LruCache
import io.legado.app.data.appDb
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.memorySize
@Keep
@Suppress("unused")
object CacheManager {

View File

@@ -13,6 +13,7 @@ import io.legado.app.utils.MD5Utils
* js加解密扩展类, 在js中通过java变量调用
* 添加方法,请更新文档/legado/app/src/main/assets/help/JsHelp.md
*/
@Suppress("unused")
interface JsEncodeUtils {
fun md5Encode(str: String): String {

View File

@@ -12,6 +12,7 @@ import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.BaseSource
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.CookieManager.cookieJarHeader
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.isUri
import io.legado.app.utils.longToastOnUi
import io.legado.app.utils.mapParallel
import io.legado.app.utils.readBytes
import io.legado.app.utils.readText
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.toastOnUi
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 okio.use
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) {
val asyncArray = Array(urlList.size) {
async(IO) {
val url = urlList[it]
val analyzeUrl = AnalyzeUrl(url, source = getSource())
analyzeUrl.getStrResponseAwait()
}
}
val resArray = Array<StrResponse?>(urlList.size) {
asyncArray[it].await()
}
resArray
urlList.asFlow().mapParallel(AppConfig.threadCount) { url ->
val analyzeUrl = AnalyzeUrl(url, source = getSource())
analyzeUrl.getStrResponseAwait()
}.flowOn(IO).toList().toTypedArray()
}
}

View File

@@ -3,6 +3,7 @@
package io.legado.app.help.http
import android.text.TextUtils
import androidx.annotation.Keep
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern.equalsRegex
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.removeCookie
@Keep
object CookieStore : CookieManagerInterface {
/**

View File

@@ -13,7 +13,6 @@ import okhttp3.Cookie
import okhttp3.CookieJar
import okhttp3.Credentials
import okhttp3.HttpUrl
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import java.net.InetSocketAddress
import java.net.Proxy
@@ -68,7 +67,7 @@ val okHttpClient: OkHttpClient by lazy {
.followRedirects(true)
.followSslRedirects(true)
.addInterceptor(OkHttpExceptionInterceptor)
.addInterceptor(Interceptor { chain ->
.addInterceptor { chain ->
val request = chain.request()
val builder = request.newBuilder()
if (request.header(AppConst.UA_NAME) == null) {
@@ -80,7 +79,7 @@ val okHttpClient: OkHttpClient by lazy {
builder.addHeader("Connection", "Keep-Alive")
builder.addHeader("Cache-Control", "no-cache")
chain.proceed(builder.build())
})
}
.addNetworkInterceptor { chain ->
var request = chain.request()
val enableCookieJar = request.header(cookieJarHeader) != null

View File

@@ -1,11 +1,17 @@
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.ResponseBody
/**
* An HTTP response.
*/
@Keep
@Suppress("unused", "MemberVisibilityCanBePrivate")
class StrResponse {
var raw: Response