mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
登录ui按钮支持JavaScript (#2558)
* LoginUI button supports running JavaScript * Update jsHelp.md * Update ruleHelp.md
This commit is contained in:
parent
1dac8be320
commit
d301b8af09
@ -107,12 +107,12 @@ java.getVerificationCode(imageUrl)
|
||||
java.longToast(msg: Any?)
|
||||
java.toast(msg: Any?)
|
||||
```
|
||||
* 从网络(由java.cacheFile实现)、本地导入JavaScript脚本
|
||||
* 从网络(由java.cacheFile实现)、本地读取JavaScript文件,导入上下文请手动`eval(String(...))`
|
||||
```
|
||||
{{java.importScript(url)}}
|
||||
java.importScript(url)
|
||||
//相对路径支持android/data/{package}/cache
|
||||
{{java.importScript(relativePath)}}
|
||||
{{java.importScript(absolutePath)}}
|
||||
java.importScript(relativePath)
|
||||
java.importScript(absolutePath)
|
||||
```
|
||||
* 缓存网络文件
|
||||
```
|
||||
@ -293,7 +293,7 @@ cookie.getCookie(url)
|
||||
获取cookie某一键值
|
||||
cookie.getKey(url,key)
|
||||
删除cookie
|
||||
cookie.removeCookie(key)
|
||||
cookie.removeCookie(url)
|
||||
```
|
||||
|
||||
## cache对象的部分可用函数
|
||||
|
@ -37,6 +37,11 @@
|
||||
name: "注册",
|
||||
type: "button",
|
||||
action: "http://www.yooike.com/xiaoshuo/#/register?title=%E6%B3%A8%E5%86%8C"
|
||||
},
|
||||
{
|
||||
name: "获取验证码",
|
||||
type: "button",
|
||||
action: "java.ajax(...)"
|
||||
}
|
||||
]
|
||||
成功登录后在js中获取读取登录信息
|
||||
|
@ -67,6 +67,15 @@ class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login, true) {
|
||||
it.root.onClick {
|
||||
if (rowUi.action.isAbsUrl()) {
|
||||
context?.openUrl(rowUi.action!!)
|
||||
} else {
|
||||
// JavaScript
|
||||
rowUi.action?.let {
|
||||
kotlin.runCatching {
|
||||
source.evalJS(it)
|
||||
}.onFailure {
|
||||
AppLog.put("LoginUI Button ${rowUi.name} JavaScript error", it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,4 +142,4 @@ class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login, true) {
|
||||
activity?.finish()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user