From a15ce01ef62fa9018ce38dcf04f346e7415f73ec Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 3 Jun 2022 23:06:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/cache/CacheViewModel.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt index 4655c07c1..d08e0c956 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt @@ -49,7 +49,11 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { val bindings = SimpleBindings() bindings["name"] = book.name bindings["author"] = book.getRealAuthor() - return AppConst.SCRIPT_ENGINE.eval(jsStr, bindings).toString() + return kotlin.runCatching { + AppConst.SCRIPT_ENGINE.eval(jsStr, bindings).toString() + }.onFailure { + context.toastOnUi("书名规则错误\n${it.localizedMessage}") + }.getOrDefault("${book.name} 作者:${book.getRealAuthor()}") } fun export(path: String, book: Book) {