From 6b8e92ea8abbdc4830657db35e507fcf5452f1b2 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 13 Sep 2020 16:53:32 +0800 Subject: [PATCH] =?UTF-8?q?@get:{bookName}=E5=8F=AF=E4=BB=A5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E4=B9=A6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/data/entities/BaseBook.kt | 2 ++ app/src/main/java/io/legado/app/data/entities/Book.kt | 4 ++-- .../java/io/legado/app/data/entities/SearchBook.kt | 4 ++-- .../io/legado/app/model/analyzeRule/AnalyzeRule.kt | 10 +++++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BaseBook.kt b/app/src/main/java/io/legado/app/data/entities/BaseBook.kt index 31346a50c..e52f9e185 100644 --- a/app/src/main/java/io/legado/app/data/entities/BaseBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/BaseBook.kt @@ -3,6 +3,8 @@ package io.legado.app.data.entities import io.legado.app.utils.splitNotBlank interface BaseBook { + var name: String + var author: String var bookUrl: String val variableMap: HashMap var kind: String? diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 7996e3ea9..62926b3b4 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -29,8 +29,8 @@ data class Book( var tocUrl: String = "", // 目录页Url (toc=table of Contents) var origin: String = BookType.local, // 书源URL(默认BookType.local) var originName: String = "", //书源名称 or 本地书籍文件名 - var name: String = "", // 书籍名称(书源获取) - var author: String = "", // 作者名称(书源获取) + override var name: String = "", // 书籍名称(书源获取) + override var author: String = "", // 作者名称(书源获取) override var kind: String? = null, // 分类信息(书源获取) var customTag: String? = null, // 分类信息(用户修改) var coverUrl: String? = null, // 封面Url(书源获取) diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt index 71bd9016f..62635219c 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt @@ -25,8 +25,8 @@ data class SearchBook( var origin: String = "", // 书源规则 var originName: String = "", var type: Int = 0, // @BookType - var name: String = "", - var author: String = "", + override var name: String = "", + override var author: String = "", override var kind: String? = null, var coverUrl: String? = null, var intro: String? = null, diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 84673215c..d196e18fa 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -580,9 +580,13 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { } fun get(key: String): String { - val chapter = chapter - if (chapter != null && key == "title") { - return chapter.title + when (key) { + "bookName" -> book?.let { + return it.name + } + "title" -> chapter?.let { + return it.title + } } return chapter?.variableMap?.get(key) ?: book?.variableMap?.get(key)