优化
This commit is contained in:
@@ -27,7 +27,8 @@ object SharedJsScope {
|
|||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
val context = SCRIPT_ENGINE.getScriptContext(SimpleBindings())
|
val context = SCRIPT_ENGINE.getScriptContext(SimpleBindings())
|
||||||
scope = SCRIPT_ENGINE.getRuntimeScope(context)
|
scope = SCRIPT_ENGINE.getRuntimeScope(context)
|
||||||
Context.enter().use {
|
val rhino = Context.enter()
|
||||||
|
rhino.runCatching {
|
||||||
if (jsLib.isJsonObject()) {
|
if (jsLib.isJsonObject()) {
|
||||||
val jsMap: Map<String, String> = GSON.fromJson(
|
val jsMap: Map<String, String> = GSON.fromJson(
|
||||||
jsLib,
|
jsLib,
|
||||||
@@ -42,13 +43,14 @@ object SharedJsScope {
|
|||||||
val js = okHttpClient.newCallStrResponse {
|
val js = okHttpClient.newCallStrResponse {
|
||||||
url(value)
|
url(value)
|
||||||
}.body
|
}.body
|
||||||
it.evaluateString(scope, js, "jsLib", 1, null)
|
evaluateString(scope, js, "jsLib", 1, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
it.evaluateString(scope, jsLib, "jsLib", 1, null)
|
evaluateString(scope, jsLib, "jsLib", 1, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Context.exit()
|
||||||
scopeMap[key] = WeakReference(scope)
|
scopeMap[key] = WeakReference(scope)
|
||||||
}
|
}
|
||||||
return scope
|
return scope
|
||||||
|
|||||||
Reference in New Issue
Block a user