Fix the error that directly closing the verification code window will block the coroutine.

This commit is contained in:
Karlatemp 2020-05-02 19:12:38 +08:00
parent 73c700b4b7
commit edb80ec0ca
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -22,6 +22,7 @@ import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent
import javax.swing.JFrame
import javax.swing.JTextField
import javax.swing.SwingUtilities
// 隔离类代码
internal object WindowHelperJvm {
@ -88,7 +89,9 @@ internal suspend fun openWindow(title: String = "", initializer: WindowInitialzi
frame.title = title
frame.isVisible = true
val result = def.await()
frame.dispose()
val result = def.await().trim()
SwingUtilities.invokeLater {
frame.dispose()
}
return result
}