diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a7c53b1fd..2dffd3dc1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -293,7 +293,7 @@
android:launchMode="singleTop" />
diff --git a/app/src/main/java/io/legado/app/data/entities/BaseSource.kt b/app/src/main/java/io/legado/app/data/entities/BaseSource.kt
index c951985b1..0686c556f 100644
--- a/app/src/main/java/io/legado/app/data/entities/BaseSource.kt
+++ b/app/src/main/java/io/legado/app/data/entities/BaseSource.kt
@@ -14,6 +14,7 @@ import javax.script.SimpleBindings
/**
* 可在js里调用,source.xxx()
*/
+@Suppress("unused")
interface BaseSource : JsExtensions {
fun getStoreUrl(): String
@@ -39,7 +40,7 @@ interface BaseSource : JsExtensions {
}
}
if (hasLoginHeader) {
- getLoginHeader()?.let {
+ getLoginHeaderMap()?.let {
putAll(it)
}
}
@@ -48,8 +49,12 @@ interface BaseSource : JsExtensions {
/**
* 获取用于登录的头部信息
*/
- fun getLoginHeader(): Map? {
- val cache = CacheManager.get("loginHeader_${getStoreUrl()}") ?: return null
+ fun getLoginHeader(): String? {
+ return CacheManager.get("loginHeader_${getStoreUrl()}")
+ }
+
+ fun getLoginHeaderMap(): Map? {
+ val cache = getLoginHeader() ?: return null
return GSON.fromJsonObject(cache)
}
diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt
index 10d5157af..688d2b196 100644
--- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt
+++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt
@@ -61,18 +61,19 @@ data class BookSource(
if (ruleStr.isNotBlank()) {
kotlin.runCatching {
if (exploreUrl.startsWith("", false)
- || exploreUrl.startsWith("@js", false)
+ || exploreUrl.startsWith("@js:", false)
) {
val aCache = ACache.get(appCtx, "explore")
ruleStr = aCache.getAsString(bookSourceUrl) ?: ""
if (ruleStr.isBlank()) {
val bindings = SimpleBindings()
- bindings["baseUrl"] = bookSourceUrl
bindings["java"] = this
+ bindings["source"] = this
+ bindings["baseUrl"] = bookSourceUrl
bindings["cookie"] = CookieStore
bindings["cache"] = CacheManager
val jsStr = if (exploreUrl.startsWith("@")) {
- exploreUrl.substring(3)
+ exploreUrl.substring(4)
} else {
exploreUrl.substring(4, exploreUrl.lastIndexOf("<"))
}
@@ -91,6 +92,7 @@ data class BookSource(
}
}
}.onFailure {
+ it.printStackTrace()
kinds.add(ExploreKind(it.localizedMessage ?: ""))
}
}
diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
index 2c3c739ab..4218bb3e6 100644
--- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
@@ -32,11 +32,11 @@ import io.legado.app.ui.book.changecover.ChangeCoverDialog
import io.legado.app.ui.book.changesource.ChangeSourceDialog
import io.legado.app.ui.book.group.GroupSelectDialog
import io.legado.app.ui.book.info.edit.BookInfoEditActivity
-import io.legado.app.ui.book.login.SourceLoginActivity
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.toc.TocActivityResult
+import io.legado.app.ui.login.SourceLoginActivity
import io.legado.app.ui.widget.image.CoverImageView
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
index b0957beac..7025b6442 100644
--- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
@@ -34,7 +34,6 @@ import io.legado.app.service.BaseReadAloudService
import io.legado.app.service.help.ReadAloud
import io.legado.app.ui.book.changesource.ChangeSourceDialog
import io.legado.app.ui.book.info.BookInfoActivity
-import io.legado.app.ui.book.login.SourceLoginActivity
import io.legado.app.ui.book.read.config.*
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR
@@ -48,6 +47,7 @@ import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.toc.BookmarkDialog
import io.legado.app.ui.book.toc.TocActivityResult
import io.legado.app.ui.dict.DictDialog
+import io.legado.app.ui.login.SourceLoginActivity
import io.legado.app.ui.replace.ReplaceRuleActivity
import io.legado.app.ui.replace.edit.ReplaceEditActivity
import io.legado.app.ui.widget.dialog.TextDialog
diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
index ee14fe40e..65c91a24f 100644
--- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
@@ -24,10 +24,10 @@ import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.selector
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.backgroundColor
-import io.legado.app.ui.book.login.SourceLoginActivity
import io.legado.app.ui.book.source.debug.BookSourceDebugActivity
import io.legado.app.ui.document.FilePicker
import io.legado.app.ui.document.FilePickerParam
+import io.legado.app.ui.login.SourceLoginActivity
import io.legado.app.ui.qrcode.QrCodeResult
import io.legado.app.ui.widget.KeyboardToolPop
import io.legado.app.ui.widget.dialog.TextDialog
diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
index ca74e22ae..3a10541b9 100644
--- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
+++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
@@ -17,7 +17,7 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.databinding.ItemBookSourceBinding
import io.legado.app.lib.theme.backgroundColor
import io.legado.app.model.Debug
-import io.legado.app.ui.book.login.SourceLoginActivity
+import io.legado.app.ui.login.SourceLoginActivity
import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
import io.legado.app.ui.widget.recycler.ItemTouchCallback.Callback
import io.legado.app.utils.ColorUtils
diff --git a/app/src/main/java/io/legado/app/ui/book/login/RuleUiLoginDialog.kt b/app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt
similarity index 99%
rename from app/src/main/java/io/legado/app/ui/book/login/RuleUiLoginDialog.kt
rename to app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt
index 36a85ff5c..420bbdbc4 100644
--- a/app/src/main/java/io/legado/app/ui/book/login/RuleUiLoginDialog.kt
+++ b/app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.login
+package io.legado.app.ui.login
import android.content.DialogInterface
import android.os.Bundle
diff --git a/app/src/main/java/io/legado/app/ui/book/login/SourceLoginActivity.kt b/app/src/main/java/io/legado/app/ui/login/SourceLoginActivity.kt
similarity index 96%
rename from app/src/main/java/io/legado/app/ui/book/login/SourceLoginActivity.kt
rename to app/src/main/java/io/legado/app/ui/login/SourceLoginActivity.kt
index 78ff2d837..5042ee624 100644
--- a/app/src/main/java/io/legado/app/ui/book/login/SourceLoginActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/login/SourceLoginActivity.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.login
+package io.legado.app.ui.login
import android.os.Bundle
import androidx.activity.viewModels
diff --git a/app/src/main/java/io/legado/app/ui/book/login/SourceLoginViewModel.kt b/app/src/main/java/io/legado/app/ui/login/SourceLoginViewModel.kt
similarity index 94%
rename from app/src/main/java/io/legado/app/ui/book/login/SourceLoginViewModel.kt
rename to app/src/main/java/io/legado/app/ui/login/SourceLoginViewModel.kt
index 80e0035cd..f6ec8c962 100644
--- a/app/src/main/java/io/legado/app/ui/book/login/SourceLoginViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/login/SourceLoginViewModel.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.login
+package io.legado.app.ui.login
import android.app.Application
import io.legado.app.base.BaseViewModel
diff --git a/app/src/main/java/io/legado/app/ui/book/login/WebViewLoginFragment.kt b/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt
similarity index 98%
rename from app/src/main/java/io/legado/app/ui/book/login/WebViewLoginFragment.kt
rename to app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt
index ba93817df..9e955edab 100644
--- a/app/src/main/java/io/legado/app/ui/book/login/WebViewLoginFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.login
+package io.legado.app.ui.login
import android.annotation.SuppressLint
import android.graphics.Bitmap