diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/HyperLinkLabel.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/HyperLinkLabel.kt
new file mode 100644
index 000000000..46cc82c74
--- /dev/null
+++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/HyperLinkLabel.kt
@@ -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为显示的提示内容
+ */
+class HyperLinkLabel constructor(url :String, text :String) : JLabel() {
+ init {
+ super.setText("$text");
+ addMouseListener(object : MouseAdapter() {
+
+ override fun mouseClicked(e: MouseEvent) {
+ try {
+ Desktop.getDesktop().browse(URI(url))
+ } catch (ex: Exception) {
+ ex.printStackTrace()
+ }
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/LoginSolver.swing.jvm.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/LoginSolver.swing.jvm.kt
index 378ecef52..89893b27f 100644
--- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/LoginSolver.swing.jvm.kt
+++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/LoginSolver.swing.jvm.kt
@@ -38,18 +38,8 @@ object SwingSolver : LoginSolver() {
override suspend fun onSolveUnsafeDeviceLoginVerify(bot: Bot, url: String): String? {
return openWindow("Mirai UnsafeDeviceLoginVerify(${bot.id})") {
- JLabel(
- """
-
- 需要进行账户安全认证
- 该账户有[设备锁]/[不常用登录地点]/[不常用设备登录]的问题
- 完成以下账号认证即可成功登录|理论本认证在mirai每个账户中最多出现1次
- 请将该链接在QQ浏览器中打开并完成认证
- 成功后请关闭该窗口
- 这步操作将在后续的版本中优化
- """.trimIndent()
- ).last()
- JTextField(url).append()
+ HyperLinkLabel(url, "设备锁验证").last()
+ JTextField("点击下方链接进行设备锁验证, 验证通过后关闭本窗口").append()
}
}
}
\ No newline at end of file