This commit is contained in:
kunfei 2023-02-19 23:31:18 +08:00
parent 69492b1faf
commit 814fcaffdc
2 changed files with 4 additions and 7 deletions

View File

@ -9,7 +9,7 @@
{
"name": "海词英文",
"urlRule": "https://apii.dict.cn/mini.php?q={{key}}",
"showRule": "all",
"showRule": "tag.body@all",
"enabled": true,
"sortNumber": 1
}

View File

@ -3,6 +3,7 @@ package io.legado.app.ui.dict
import android.app.Application
import androidx.lifecycle.MutableLiveData
import io.legado.app.base.BaseViewModel
import io.legado.app.help.DefaultData
import io.legado.app.help.http.get
import io.legado.app.help.http.newCallStrResponse
import io.legado.app.help.http.okHttpClient
@ -30,13 +31,9 @@ class DictViewModel(application: Application) : BaseViewModel(application) {
*/
private fun haiciDict(word: String) {
execute {
val body = okHttpClient.newCallStrResponse {
get("https://apii.dict.cn/mini.php", mapOf(Pair("q", word)))
}.body
val jsoup = Jsoup.parse(body!!)
jsoup.body()
DefaultData.dictRules[1].search(word)
}.onSuccess {
dictHtmlData.postValue(it.html())
dictHtmlData.postValue(it)
}.onError {
context.toastOnUi(it.localizedMessage)
}