From dd08dd2e14d3dc9479937ba799a64cbe4af154e8 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Tue, 15 Jun 2021 13:28:47 +0800 Subject: [PATCH] Update LocalBook.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 简化 --- .../main/java/io/legado/app/model/localBook/LocalBook.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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