fix(书源导入):no path $.sourceUrls find
json.read找不到会抛出异常
This commit is contained in:
@@ -90,13 +90,14 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
|
|||||||
val mText = text.trim()
|
val mText = text.trim()
|
||||||
when {
|
when {
|
||||||
mText.isJsonObject() -> {
|
mText.isJsonObject() -> {
|
||||||
val json = JsonPath.parse(mText)
|
kotlin.runCatching {
|
||||||
val urls = json.read<List<String>>("$.sourceUrls")
|
val json = JsonPath.parse(mText)
|
||||||
if (!urls.isNullOrEmpty()) {
|
json.read<List<String>>("$.sourceUrls")
|
||||||
urls.forEach {
|
}.onSuccess {
|
||||||
|
it.forEach {
|
||||||
importSourceUrl(it)
|
importSourceUrl(it)
|
||||||
}
|
}
|
||||||
} else {
|
}.onFailure {
|
||||||
BookSource.fromJson(mText).getOrThrow().let {
|
BookSource.fromJson(mText).getOrThrow().let {
|
||||||
allSources.add(it)
|
allSources.add(it)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user