mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
添加通用封面规则
This commit is contained in:
parent
36941ecb3f
commit
1fef8cb9ca
@ -1,4 +1,5 @@
|
||||
{
|
||||
"enable": true,
|
||||
"searchUrl": "https://api.yousuu.com/api/search?type=title&value={{key}}&page=1&highlight=0&from=search",
|
||||
"coverRule": "@js:java.getString(\"$..books[?(@.author == '\" + book.author + \"')].cover\")"
|
||||
}
|
@ -68,7 +68,7 @@ object BookCover {
|
||||
|
||||
suspend fun searchCover(book: Book): String? {
|
||||
val config = coverRuleConfig
|
||||
if (config.searchUrl.isBlank() || config.coverRule.isBlank()) {
|
||||
if (!config.enable || config.searchUrl.isBlank() || config.coverRule.isBlank()) {
|
||||
return null
|
||||
}
|
||||
val analyzeUrl =
|
||||
@ -97,6 +97,7 @@ object BookCover {
|
||||
}
|
||||
|
||||
data class CoverRuleConfig(
|
||||
var enable: Boolean = true,
|
||||
var searchUrl: String,
|
||||
var coverRule: String,
|
||||
override var concurrentRate: String? = null,
|
||||
|
@ -28,12 +28,13 @@ class CoverRuleConfigDialog : BaseDialogFragment(R.layout.dialog_cover_rule_conf
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.tvOk.onClick {
|
||||
val enable = binding.cbEnable.isChecked
|
||||
val searchUrl = binding.editSearchUrl.text?.toString()
|
||||
val coverRule = binding.editCoverUrlRule.text?.toString()
|
||||
if (searchUrl.isNullOrBlank() || coverRule.isNullOrBlank()) {
|
||||
toastOnUi("搜索url和cover规则不能为空")
|
||||
} else {
|
||||
BookCover.CoverRuleConfig(searchUrl, coverRule).let { config ->
|
||||
BookCover.CoverRuleConfig(enable, searchUrl, coverRule).let { config ->
|
||||
BookCover.saveCoverRuleConfig(config)
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
|
@ -26,6 +26,12 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<io.legado.app.lib.theme.view.ThemeCheckBox
|
||||
android:id="@+id/cb_enable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/enable" />
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
Loading…
Reference in New Issue
Block a user