kunfei 4 سال پیش
والد
کامیت
ecbd1d0788

+ 1 - 10
app/src/main/java/io/legado/app/data/entities/Book.kt

@@ -2,7 +2,6 @@ package io.legado.app.data.entities
 
 
 import android.os.Parcelable
 import android.os.Parcelable
 import androidx.room.*
 import androidx.room.*
-import io.legado.app.constant.AppLog
 import io.legado.app.constant.AppPattern
 import io.legado.app.constant.AppPattern
 import io.legado.app.constant.BookType
 import io.legado.app.constant.BookType
 import io.legado.app.data.appDb
 import io.legado.app.data.appDb
@@ -144,15 +143,7 @@ data class Book(
     }
     }
 
 
     override fun putVariable(key: String, value: String?) {
     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)
         variable = GSON.toJson(variableMap)
     }
     }
 
 

+ 1 - 10
app/src/main/java/io/legado/app/data/entities/BookChapter.kt

@@ -7,7 +7,6 @@ import androidx.room.Ignore
 import androidx.room.Index
 import androidx.room.Index
 import com.github.liuyueyi.quick.transfer.ChineseUtils
 import com.github.liuyueyi.quick.transfer.ChineseUtils
 import io.legado.app.R
 import io.legado.app.R
-import io.legado.app.constant.AppLog
 import io.legado.app.constant.AppPattern
 import io.legado.app.constant.AppPattern
 import io.legado.app.help.config.AppConfig
 import io.legado.app.help.config.AppConfig
 import io.legado.app.model.analyzeRule.AnalyzeUrl
 import io.legado.app.model.analyzeRule.AnalyzeUrl
@@ -56,15 +55,7 @@ data class BookChapter(
     }
     }
 
 
     override fun putVariable(key: String, value: String?) {
     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)
         variable = GSON.toJson(variableMap)
     }
     }
 
 

+ 1 - 10
app/src/main/java/io/legado/app/data/entities/RssArticle.kt

@@ -2,7 +2,6 @@ package io.legado.app.data.entities
 
 
 import androidx.room.Entity
 import androidx.room.Entity
 import androidx.room.Ignore
 import androidx.room.Ignore
-import io.legado.app.constant.AppLog
 import io.legado.app.model.analyzeRule.RuleDataInterface
 import io.legado.app.model.analyzeRule.RuleDataInterface
 import io.legado.app.utils.GSON
 import io.legado.app.utils.GSON
 import io.legado.app.utils.fromJsonObject
 import io.legado.app.utils.fromJsonObject
@@ -42,15 +41,7 @@ data class RssArticle(
     }
     }
 
 
     override fun putVariable(key: String, value: String?) {
     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)
         variable = GSON.toJson(variableMap)
     }
     }
 
 

+ 1 - 10
app/src/main/java/io/legado/app/data/entities/RssStar.kt

@@ -2,7 +2,6 @@ package io.legado.app.data.entities
 
 
 import androidx.room.Entity
 import androidx.room.Entity
 import androidx.room.Ignore
 import androidx.room.Ignore
-import io.legado.app.constant.AppLog
 import io.legado.app.model.analyzeRule.RuleDataInterface
 import io.legado.app.model.analyzeRule.RuleDataInterface
 import io.legado.app.utils.GSON
 import io.legado.app.utils.GSON
 import io.legado.app.utils.fromJsonObject
 import io.legado.app.utils.fromJsonObject
@@ -34,15 +33,7 @@ data class RssStar(
     }
     }
 
 
     override fun putVariable(key: String, value: String?) {
     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)
         variable = GSON.toJson(variableMap)
     }
     }
 
 

+ 1 - 5
app/src/main/java/io/legado/app/data/entities/SearchBook.kt

@@ -64,11 +64,7 @@ data class SearchBook(
     }
     }
 
 
     override fun putVariable(key: String, value: String?) {
     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)
         variable = GSON.toJson(variableMap)
     }
     }
 
 

+ 1 - 2
app/src/main/java/io/legado/app/help/DirectLinkUpload.kt

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

+ 0 - 14
app/src/main/java/io/legado/app/model/analyzeRule/RuleData.kt

@@ -1,23 +1,9 @@
 package io.legado.app.model.analyzeRule
 package io.legado.app.model.analyzeRule
 
 
-import io.legado.app.constant.AppLog
-
 class RuleData : RuleDataInterface {
 class RuleData : RuleDataInterface {
 
 
     override val variableMap by lazy {
     override val variableMap by lazy {
         hashMapOf<String, String>()
         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)
-        }
-    }
-
 }
 }

+ 7 - 1
app/src/main/java/io/legado/app/model/analyzeRule/RuleDataInterface.kt

@@ -4,7 +4,13 @@ interface RuleDataInterface {
 
 
     val variableMap: HashMap<String, String>
     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? {
     fun getVariable(key: String): String? {
         return variableMap[key]
         return variableMap[key]