优化
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
{
|
{
|
||||||
"name": "海词英文",
|
"name": "海词英文",
|
||||||
"urlRule": "https://apii.dict.cn/mini.php?q={{key}}",
|
"urlRule": "https://apii.dict.cn/mini.php?q={{key}}",
|
||||||
"showRule": "all",
|
"showRule": "tag.body@all",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"sortNumber": 1
|
"sortNumber": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.legado.app.ui.dict
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import io.legado.app.base.BaseViewModel
|
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.get
|
||||||
import io.legado.app.help.http.newCallStrResponse
|
import io.legado.app.help.http.newCallStrResponse
|
||||||
import io.legado.app.help.http.okHttpClient
|
import io.legado.app.help.http.okHttpClient
|
||||||
@@ -30,13 +31,9 @@ class DictViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
*/
|
*/
|
||||||
private fun haiciDict(word: String) {
|
private fun haiciDict(word: String) {
|
||||||
execute {
|
execute {
|
||||||
val body = okHttpClient.newCallStrResponse {
|
DefaultData.dictRules[1].search(word)
|
||||||
get("https://apii.dict.cn/mini.php", mapOf(Pair("q", word)))
|
|
||||||
}.body
|
|
||||||
val jsoup = Jsoup.parse(body!!)
|
|
||||||
jsoup.body()
|
|
||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
dictHtmlData.postValue(it.html())
|
dictHtmlData.postValue(it)
|
||||||
}.onError {
|
}.onError {
|
||||||
context.toastOnUi(it.localizedMessage)
|
context.toastOnUi(it.localizedMessage)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user