diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt index aa0875e48..980b39395 100644 --- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt +++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt @@ -85,13 +85,13 @@ object LocalBook { } else if (!AppConfig.bookImportFileName.isNullOrBlank()) { //在脚本中定义如何分解文件名成书名、作者名 - val bindings = SimpleBindings() - bindings["src"] = fileName val jsonStr = AppConst.SCRIPT_ENGINE.eval( - //在用户脚本后添加捕获author、name的代码,只要脚本中author、name有值就会被捕获,未定义则赋值为空字符串 + //在用户脚本后添加捕获author、name的代码,只要脚本中author、name有值就会被捕获 AppConfig.bookImportFileName + "\nJSON.stringify({author:author,name:name})", - bindings + + //将文件名注入到脚步的src变量中 + SimpleBindings().also{ it["src"] = fileName } ).toString() val bookMess = GSON.fromJsonObject>(jsonStr) ?: HashMap() name = bookMess["name"] ?: fileName