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,16 +103,20 @@ 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 {
val json = when { try {
it.startsWith("@js:", true) -> evalJS(it.substring(4)).toString() val json = when {
it.startsWith("<js>", true) -> evalJS( it.startsWith("@js:", true) -> evalJS(it.substring(4)).toString()
it.substring(4, it.lastIndexOf("<")) it.startsWith("<js>", true) -> evalJS(
).toString() it.substring(4, it.lastIndexOf("<"))
).toString()
else -> it else -> it
} }
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)) {
@@ -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,11 +347,13 @@ class ReadMenu @JvmOverloads constructor(
if (AppConfig.readUrlInBrowser) { if (AppConfig.readUrlInBrowser) {
context.openUrl(tvChapterUrl.text.toString().substringBefore(",{")) context.openUrl(tvChapterUrl.text.toString().substringBefore(",{"))
} else { } else {
context.startActivity<WebViewActivity> { Coroutine.async {
val url = tvChapterUrl.text.toString() context.startActivity<WebViewActivity> {
putExtra("title", tvChapterName.text) val url = tvChapterUrl.text.toString()
putExtra("url", url) putExtra("title", tvChapterName.text)
IntentData.put(url, ReadBook.bookSource?.getHeaderMap(true)) putExtra("url", url)
IntentData.put(url, ReadBook.bookSource?.getHeaderMap(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"