diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index 343a54087..47d97b360 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -17,12 +17,12 @@ object OldRule { fun jsonToBookSource(json: String): BookSource? { var source: BookSource? = null runCatching { - source = GSON.fromJsonObject(json) + source = GSON.fromJsonObject(json.trim()) } runCatching { if (source == null || source?.searchUrl.isNullOrBlank()) { source = BookSource().apply { - val jsonItem = jsonPath.parse(json) + val jsonItem = jsonPath.parse(json.trim()) bookSourceUrl = jsonItem.readString("bookSourceUrl") ?: "" bookSourceName = jsonItem.readString("bookSourceName") ?: "" bookSourceGroup = jsonItem.readString("bookSourceGroup") ?: "" diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt index d50601117..5368c9650 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt @@ -61,6 +61,8 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat } ?: toast("格式不对") } } + }.onError { + toast(it.localizedMessage) } } } \ No newline at end of file