This commit is contained in:
Horis
2025-02-10 13:53:50 +08:00
parent dc5bcca376
commit e09fbf9043
4 changed files with 24 additions and 17 deletions
@@ -103,6 +103,7 @@ interface BaseSource : JsExtensions {
*/ */
fun getHeaderMap(hasLoginHeader: Boolean = false) = HashMap<String, String>().apply { fun getHeaderMap(hasLoginHeader: Boolean = false) = HashMap<String, String>().apply {
header?.let { header?.let {
try {
val json = when { val json = when {
it.startsWith("@js:", true) -> evalJS(it.substring(4)).toString() it.startsWith("@js:", true) -> evalJS(it.substring(4)).toString()
it.startsWith("<js>", true) -> evalJS( it.startsWith("<js>", true) -> evalJS(
@@ -114,6 +115,9 @@ interface BaseSource : JsExtensions {
GSON.fromJsonObject<Map<String, String>>(json).getOrNull()?.let { map -> GSON.fromJsonObject<Map<String, String>>(json).getOrNull()?.let { map ->
putAll(map) putAll(map)
} }
} catch (e: Exception) {
AppLog.put("getHeaderMap 出错\n$e", e)
}
} }
if (!has(AppConst.UA_NAME, true)) { if (!has(AppConst.UA_NAME, true)) {
put(AppConst.UA_NAME, AppConfig.userAgent) put(AppConst.UA_NAME, AppConfig.userAgent)
@@ -1293,7 +1293,7 @@ class ReadBookActivity : BaseReadBookActivity(),
analyzeRule.setBaseUrl(chapter.url) analyzeRule.setBaseUrl(chapter.url)
analyzeRule.chapter = chapter analyzeRule.chapter = chapter
analyzeRule.evalJS(payAction).toString() analyzeRule.evalJS(payAction).toString()
}.onSuccess { }.onSuccess(IO) {
if (it.isAbsUrl()) { if (it.isAbsUrl()) {
startActivity<WebViewActivity> { startActivity<WebViewActivity> {
putExtra("title", getString(R.string.chapter_pay)) putExtra("title", getString(R.string.chapter_pay))
@@ -23,6 +23,7 @@ import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.LocalConfig import io.legado.app.help.config.LocalConfig
import io.legado.app.help.config.ReadBookConfig import io.legado.app.help.config.ReadBookConfig
import io.legado.app.help.config.ThemeConfig import io.legado.app.help.config.ThemeConfig
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.Selector import io.legado.app.lib.theme.Selector
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
@@ -346,6 +347,7 @@ class ReadMenu @JvmOverloads constructor(
if (AppConfig.readUrlInBrowser) { if (AppConfig.readUrlInBrowser) {
context.openUrl(tvChapterUrl.text.toString().substringBefore(",{")) context.openUrl(tvChapterUrl.text.toString().substringBefore(",{"))
} else { } else {
Coroutine.async {
context.startActivity<WebViewActivity> { context.startActivity<WebViewActivity> {
val url = tvChapterUrl.text.toString() val url = tvChapterUrl.text.toString()
putExtra("title", tvChapterName.text) putExtra("title", tvChapterName.text)
@@ -354,6 +356,7 @@ class ReadMenu @JvmOverloads constructor(
} }
} }
} }
}
val chapterViewLongClickListener = OnLongClickListener { val chapterViewLongClickListener = OnLongClickListener {
if (ReadBook.isLocalBook) { if (ReadBook.isLocalBook) {
return@OnLongClickListener true return@OnLongClickListener true
@@ -159,7 +159,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/scroll_view" android:id="@+id/scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
@@ -379,7 +379,7 @@
</LinearLayout> </LinearLayout>
</ScrollView> </androidx.core.widget.NestedScrollView>
<LinearLayout <LinearLayout
android:id="@+id/fl_action" android:id="@+id/fl_action"