优化
This commit is contained in:
1 parent
dfd02f1dfb
commit
79fa3f912a
9 files changed
+95
-60
No files matched your search
@@ -2,6 +2,7 @@ package io.legado.app.data.entities
|
|||||||
|
|
||||||
import cn.hutool.crypto.symmetric.AES
|
import cn.hutool.crypto.symmetric.AES
|
||||||
import com.script.ScriptBindings
|
import com.script.ScriptBindings
|
||||||
|
import com.script.buildScriptBindings
|
||||||
import com.script.rhino.RhinoScriptEngine
|
import com.script.rhino.RhinoScriptEngine
|
||||||
import io.legado.app.constant.AppConst
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
@@ -232,13 +233,14 @@ interface BaseSource : JsExtensions {
|
|||||||
*/
|
*/
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun evalJS(jsStr: String, bindingsConfig: ScriptBindings.() -> Unit = {}): Any? {
|
fun evalJS(jsStr: String, bindingsConfig: ScriptBindings.() -> Unit = {}): Any? {
|
||||||
val bindings = ScriptBindings()
|
val bindings = buildScriptBindings { bindings ->
|
||||||
bindings.apply(bindingsConfig)
|
bindings.apply(bindingsConfig)
|
||||||
bindings["java"] = this
|
bindings["java"] = this
|
||||||
bindings["source"] = this
|
bindings["source"] = this
|
||||||
bindings["baseUrl"] = getKey()
|
bindings["baseUrl"] = getKey()
|
||||||
bindings["cookie"] = CookieStore
|
bindings["cookie"] = CookieStore
|
||||||
bindings["cache"] = CacheManager
|
bindings["cache"] = CacheManager
|
||||||
|
}
|
||||||
val scope = RhinoScriptEngine.getRuntimeScope(bindings)
|
val scope = RhinoScriptEngine.getRuntimeScope(bindings)
|
||||||
getShareScope()?.let {
|
getShareScope()?.let {
|
||||||
scope.prototype = it
|
scope.prototype = it
|
||||||
|
|||||||