Merge branch 'master' into master

pull/1551/head
Xwite 3 years ago committed by GitHub
commit 6cdc15b43c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app/src/main/assets/web/rssSource/index.html
  2. 5
      app/src/main/assets/web/rssSource/index.js
  3. 6
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  4. 9
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt

@ -107,7 +107,7 @@
placeholder="是否加载url (启用: true 关闭: false (可选,默认true))"></textarea> placeholder="是否加载url (启用: true 关闭: false (可选,默认true))"></textarea>
</div> </div>
<div> <div>
<div>启用JS :</div> <div>启用JS :</div>
<textarea rows="1" id="enableJs" class="base" title="enableJs" <textarea rows="1" id="enableJs" class="base" title="enableJs"
placeholder="是否启用Js (启用: true 关闭: false (可选,默认true))"></textarea> placeholder="是否启用Js (启用: true 关闭: false (可选,默认true))"></textarea>
</div> </div>
@ -148,6 +148,11 @@
<textarea rows="1" id="customOrder" class="base" title="customOrder" <textarea rows="1" id="customOrder" class="base" title="customOrder"
placeholder="整数: 0~N (可选,默认0) | 数字越小越靠前"></textarea> placeholder="整数: 0~N (可选,默认0) | 数字越小越靠前"></textarea>
</div> </div>
<div>
<div>单URL :</div>
<textarea rows="1" id="singleUrl" class="base" title="singleUrl"
placeholder="启用: true 关闭: false (可选,false)"></textarea>
</div>
</div> </div>
</div> </div>
<div class="menu"> <div class="menu">

@ -76,15 +76,16 @@ function rule2json() {
let RuleJSON = Container(); let RuleJSON = Container();
// 转换base // 转换base
Object.keys(RuleJSON).forEach(key => { Object.keys(RuleJSON).forEach(key => {
RuleJSON[key] = $('#' + key).value; RuleJSON[key] = $('#' + key).value;
}); });
//类型转换 //类型转换
RuleJSON.lastUpdateTime = new Date().getTime(); RuleJSON.lastUpdateTime = new Date().getTime();
RuleJSON.customOrder = RuleJSON.customOrder == '' ? 0 : parseInt(RuleJSON.customOrder); RuleJSON.customOrder = RuleJSON.customOrder == '' ? 0 : parseInt(RuleJSON.customOrder);
RuleJSON.articleStyle = RuleJSON.articleStyle == '' ? 0 : parseInt(RuleJSON.articleStyle); RuleJSON.articleStyle = RuleJSON.articleStyle == '' ? 0 : parseInt(RuleJSON.articleStyle);
RuleJSON.enabled = RuleJSON.enabled == '' || String(RuleJSON.enabled).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true'; RuleJSON.enabled = RuleJSON.enabled == '' || String(RuleJSON.enabled).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true';
RuleJSON.loadWithBaseUrl = RuleJSON.loadWithBaseUrl == '' || String(RuleJSON.loadWithBaseUrl).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true';
RuleJSON.enableJs = RuleJSON.enableJs == '' || String(RuleJSON.enableJs).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true'; RuleJSON.enableJs = RuleJSON.enableJs == '' || String(RuleJSON.enableJs).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true';
RuleJSON.loadWithBaseUrl = RuleJSON.loadWithBaseUrl == '' || String(RuleJSON.loadWithBaseUrl).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true';
RuleJSON.singleUrl = RuleJSON.singleUrl == '' || String(RuleJSON.singleUrl).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true';
return RuleJSON; return RuleJSON;
} }
// 将源对象填充到源表单 // 将源对象填充到源表单

@ -118,18 +118,20 @@ data class BookSource(
fun getContentRule() = ruleContent ?: ContentRule() fun getContentRule() = ruleContent ?: ContentRule()
fun addGroup(group: String) { fun addGroup(group: String): BookSource {
bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let { bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let {
it.add(group) it.add(group)
bookSourceGroup = TextUtils.join(",", it) bookSourceGroup = TextUtils.join(",", it)
} }
return this
} }
fun removeGroup(group: String) { fun removeGroup(group: String): BookSource {
bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let { bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let {
it.remove(group) it.remove(group)
bookSourceGroup = TextUtils.join(",", it) bookSourceGroup = TextUtils.join(",", it)
} }
return this
} }
fun equal(source: BookSource) = fun equal(source: BookSource) =

@ -3,7 +3,6 @@ package io.legado.app.ui.book.source.manage
import android.app.Application import android.app.Application
import android.text.TextUtils import android.text.TextUtils
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppPattern
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.utils.* import io.legado.app.utils.*
@ -92,23 +91,19 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
fun selectionAddToGroups(sources: List<BookSource>, groups: String) { fun selectionAddToGroups(sources: List<BookSource>, groups: String) {
execute { execute {
val list = arrayListOf<BookSource>()
sources.forEach { source -> sources.forEach { source ->
source.addGroup(groups) source.addGroup(groups)
list.add(source)
} }
appDb.bookSourceDao.update(*list.toTypedArray()) appDb.bookSourceDao.update(*sources.toTypedArray())
} }
} }
fun selectionRemoveFromGroups(sources: List<BookSource>, groups: String) { fun selectionRemoveFromGroups(sources: List<BookSource>, groups: String) {
execute { execute {
val list = arrayListOf<BookSource>()
sources.forEach { source -> sources.forEach { source ->
source.removeGroup(groups) source.removeGroup(groups)
list.add(source)
} }
appDb.bookSourceDao.update(*list.toTypedArray()) appDb.bookSourceDao.update(*sources.toTypedArray())
} }
} }

Loading…
Cancel
Save