This commit is contained in:
Horis
2025-04-21 16:30:25 +08:00
parent 3be4deaf20
commit 1fabd3c4d8
3 changed files with 15 additions and 1 deletions

View File

@@ -17,6 +17,8 @@
> 不同的书源规则中支持的调用的Java类和方法可能有所不同
> 注意使用 `const` 声明的变量不支持块级作用域,在循环里使用会出现值不变的问题,请改用 `var` 声明
|变量名|调用类|
|------|-----|
|java|当前类|

View File

@@ -56,7 +56,7 @@ object SharedJsScope {
url(value)
}.body
}
if (js !== null) {
if (js != null) {
aCache.put(fileName, js)
} else {
throw NoStackTraceException("下载jsLib-${value}失败")
@@ -76,4 +76,12 @@ object SharedJsScope {
return scope
}
fun remove(jsLib: String?) {
if (jsLib.isNullOrBlank()) {
return
}
val key = MD5Utils.md5Encode(jsLib)
scopeMap.remove(key)
}
}

View File

@@ -14,6 +14,7 @@ import io.legado.app.help.http.newCallStrResponse
import io.legado.app.help.http.okHttpClient
import io.legado.app.help.source.clearExploreKindsCache
import io.legado.app.help.storage.ImportOldData
import io.legado.app.model.SharedJsScope
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonArray
import io.legado.app.utils.fromJsonObject
@@ -57,6 +58,9 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
if (oldSource.exploreUrl != source.exploreUrl) {
oldSource.clearExploreKindsCache()
}
if (oldSource.jsLib != source.jsLib) {
SharedJsScope.remove(oldSource.jsLib)
}
}
bookSource?.let {
appDb.bookSourceDao.delete(it)