Merge remote-tracking branch 'origin/master'

This commit is contained in:
Him188 2020-09-04 21:13:14 +08:00
commit 3492a3ad7e
2 changed files with 30 additions and 8 deletions

View File

@ -0,0 +1,26 @@
package net.mamoe.mirai.utils
import java.awt.Desktop
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import java.net.URI
import javax.swing.JLabel
/**
* 构造方法中url指代用户需要点击的链接, text为显示的提示内容
*/
internal class HyperLinkLabel constructor(url: String, text: String) : JLabel() {
init {
super.setText("<html><a href='$url'>$text</a></html>");
addMouseListener(object : MouseAdapter() {
override fun mouseClicked(e: MouseEvent) {
try {
Desktop.getDesktop().browse(URI(url))
} catch (ex: Exception) {
ex.printStackTrace()
}
}
})
}
}

View File

@ -38,18 +38,14 @@ public object SwingSolver : LoginSolver() {
public override suspend fun onSolveUnsafeDeviceLoginVerify(bot: Bot, url: String): String? {
return openWindow("Mirai UnsafeDeviceLoginVerify(${bot.id})") {
JLabel(
"""
JLabel("""
<html>
需要进行账户安全认证<br>
该账户有[设备锁]/[不常用登录地点]/[不常用设备登录]的问题<br>
完成以下账号认证即可成功登录|理论本认证在mirai每个账户中最多出现1次<br>
请将该链接在QQ浏览器中打开并完成认证<br>
成功后请关闭该窗口<br>
这步操作将在后续的版本中优化
""".trimIndent()
).last()
JTextField(url).append()
成功后请关闭该窗口
""".trimIndent()).append()
HyperLinkLabel(url, "设备锁验证").last()
}
}
}