This commit is contained in:
kunfei
2023-04-17 09:33:40 +08:00
parent 74b7b8fe17
commit 4944488b7f
@@ -27,7 +27,8 @@ object SharedJsScope {
if (scope == null) {
val context = SCRIPT_ENGINE.getScriptContext(SimpleBindings())
scope = SCRIPT_ENGINE.getRuntimeScope(context)
Context.enter().use {
val rhino = Context.enter()
rhino.runCatching {
if (jsLib.isJsonObject()) {
val jsMap: Map<String, String> = GSON.fromJson(
jsLib,
@@ -42,13 +43,14 @@ object SharedJsScope {
val js = okHttpClient.newCallStrResponse {
url(value)
}.body
it.evaluateString(scope, js, "jsLib", 1, null)
evaluateString(scope, js, "jsLib", 1, null)
}
}
} else {
it.evaluateString(scope, jsLib, "jsLib", 1, null)
evaluateString(scope, jsLib, "jsLib", 1, null)
}
}
Context.exit()
scopeMap[key] = WeakReference(scope)
}
return scope