This commit is contained in:
kunfei
2022-03-10 19:30:32 +08:00
parent da61e62220
commit 71a37a4057
8 changed files with 13 additions and 62 deletions

View File

@@ -2,7 +2,6 @@ package io.legado.app.data.entities
import android.os.Parcelable
import androidx.room.*
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
import io.legado.app.constant.BookType
import io.legado.app.data.appDb
@@ -144,15 +143,7 @@ data class Book(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("${name}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

View File

@@ -7,7 +7,6 @@ import androidx.room.Ignore
import androidx.room.Index
import com.github.liuyueyi.quick.transfer.ChineseUtils
import io.legado.app.R
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
import io.legado.app.help.config.AppConfig
import io.legado.app.model.analyzeRule.AnalyzeUrl
@@ -56,15 +55,7 @@ data class BookChapter(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

View File

@@ -2,7 +2,6 @@ package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.Ignore
import io.legado.app.constant.AppLog
import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject
@@ -42,15 +41,7 @@ data class RssArticle(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

View File

@@ -2,7 +2,6 @@ package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.Ignore
import io.legado.app.constant.AppLog
import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject
@@ -34,15 +33,7 @@ data class RssStar(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

View File

@@ -64,11 +64,7 @@ data class SearchBook(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

View File

@@ -3,7 +3,6 @@ package io.legado.app.help
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.model.analyzeRule.RuleData
import io.legado.app.utils.jsonPath
import io.legado.app.utils.readString
import splitties.init.appCtx
@@ -27,7 +26,7 @@ object DirectLinkUpload {
}
val analyzeUrl = AnalyzeUrl(url)
val res = analyzeUrl.upload(fileName, file, contentType)
val analyzeRule = AnalyzeRule(RuleData()).setContent(res.body, res.url)
val analyzeRule = AnalyzeRule().setContent(res.body, res.url)
val downloadUrl = analyzeRule.getString(downloadUrlRule)
if (downloadUrl.isBlank()) {
throw NoStackTraceException("上传失败,${res.body}")

View File

@@ -1,23 +1,9 @@
package io.legado.app.model.analyzeRule
import io.legado.app.constant.AppLog
class RuleData : RuleDataInterface {
override val variableMap by lazy {
hashMapOf<String, String>()
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
}
}

View File

@@ -4,7 +4,13 @@ interface RuleDataInterface {
val variableMap: HashMap<String, String>
fun putVariable(key: String, value: String?)
fun putVariable(key: String, value: String?) {
if (value == null) {
variableMap.remove(key)
} else if (value.length < 1000) {
variableMap[key] = value
}
}
fun getVariable(key: String): String? {
return variableMap[key]