mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-31 03:22:36 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
974ef61b25
@ -1,8 +1,7 @@
|
|||||||
package net.mamoe.mirai.api.http.data.common
|
package net.mamoe.mirai.api.http.data.common
|
||||||
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.Transient
|
||||||
import kotlinx.serialization.modules.SerializersModule
|
|
||||||
import net.mamoe.mirai.api.http.AuthedSession
|
import net.mamoe.mirai.api.http.AuthedSession
|
||||||
|
|
||||||
interface DTO
|
interface DTO
|
||||||
@ -16,3 +15,8 @@ abstract class VerifyDTO : DTO {
|
|||||||
@Transient
|
@Transient
|
||||||
lateinit var session: AuthedSession // 反序列化验证成功后传入
|
lateinit var session: AuthedSession // 反序列化验证成功后传入
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
open class EventDTO : DTO
|
||||||
|
|
||||||
|
object IgnoreEventDTO : EventDTO()
|
@ -0,0 +1,118 @@
|
|||||||
|
package net.mamoe.mirai.api.http.data.common
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import net.mamoe.mirai.contact.MemberPermission
|
||||||
|
import net.mamoe.mirai.event.events.BotEvent
|
||||||
|
import net.mamoe.mirai.event.events.*
|
||||||
|
import net.mamoe.mirai.message.MessagePacket
|
||||||
|
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
open class BotEventDTO : EventDTO()
|
||||||
|
|
||||||
|
@UseExperimental(MiraiExperimentalAPI::class)
|
||||||
|
fun BotEvent.toDTO() = when(this) {
|
||||||
|
is MessagePacket<*, *> -> toDTO()
|
||||||
|
else -> when(this) {
|
||||||
|
is BotOnlineEvent -> BotOnlineEventDTO(bot.uin)
|
||||||
|
is BotOfflineEvent.Active -> BotOfflineEventActiveDTO(bot.uin)
|
||||||
|
is BotOfflineEvent.Force -> BotOfflineEventForceDTO(bot.uin, title, message)
|
||||||
|
is BotOfflineEvent.Dropped -> BotOfflineEventDroppedDTO(bot.uin)
|
||||||
|
is BotReloginEvent -> BotReloginEventDTO(bot.uin)
|
||||||
|
// is MessageSendEvent.GroupMessageSendEvent -> {}
|
||||||
|
// is MessageSendEvent.FriendMessageSendEvent -> {}
|
||||||
|
// is BeforeImageUploadEvent -> {}
|
||||||
|
// is ImageUploadEvent.Succeed -> {}
|
||||||
|
is BotGroupPermissionChangeEvent -> BotGroupPermissionChangeEventDTO(origin, new, GroupDTO(group))
|
||||||
|
is BotMuteEvent -> BotMuteEventDTO(durationSeconds, MemberDTO(operator))
|
||||||
|
is BotUnmuteEvent -> BotUnmuteEventDTO(MemberDTO(operator))
|
||||||
|
is BotJoinGroupEvent -> BotJoinGroupEventDTO(GroupDTO(group))
|
||||||
|
// is GroupSettingChangeEvent<*> -> {} // 不知道会改什么
|
||||||
|
is GroupNameChangeEvent -> GroupNameChangeEventDTO(origin, new, GroupDTO(group), isByBot)
|
||||||
|
is GroupEntranceAnnouncementChangeEvent -> GroupEntranceAnnouncementChangeEventDTO(origin, new, GroupDTO(group), operator?.let(::MemberDTO))
|
||||||
|
is GroupMuteAllEvent -> GroupMuteAllEventDTO(origin, new, GroupDTO(group), operator?.let(::MemberDTO))
|
||||||
|
is GroupAllowAnonymousChatEvent -> GroupAllowAnonymousChatEventDTO(origin, new, GroupDTO(group), operator?.let(::MemberDTO))
|
||||||
|
is GroupAllowConfessTalkEvent -> GroupAllowConfessTalkEventDTO(origin, new, GroupDTO(group), isByBot)
|
||||||
|
is GroupAllowMemberInviteEvent -> GroupAllowMemberInviteEventDTO(origin, new, GroupDTO(group), operator?.let(::MemberDTO))
|
||||||
|
is MemberJoinEvent -> MemberJoinEventDTO(MemberDTO(member))
|
||||||
|
is MemberLeaveEvent.Kick -> MemberLeaveEventKickDTO(MemberDTO(member), operator?.let(::MemberDTO))
|
||||||
|
is MemberLeaveEvent.Quit -> MemberLeaveEventQuitDTO(MemberDTO(member))
|
||||||
|
is MemberCardChangeEvent -> MemberCardChangeEventDTO(origin, new, GroupDTO(group), operator?.let(::MemberDTO))
|
||||||
|
is MemberSpecialTitleChangeEvent -> MemberSpecialTitleChangeEventDTO(origin, new, MemberDTO(member))
|
||||||
|
is MemberPermissionChangeEvent -> MemberPermissionChangeEventDTO(origin, new, MemberDTO(member))
|
||||||
|
is MemberMuteEvent -> MemberMuteEventDTO(durationSeconds, MemberDTO(member), operator?.let(::MemberDTO))
|
||||||
|
is MemberUnmuteEvent -> MemberUnmuteEventDTO(MemberDTO(member), operator?.let(::MemberDTO))
|
||||||
|
else -> IgnoreEventDTO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotOnlineEvent")
|
||||||
|
data class BotOnlineEventDTO(val qq: Long) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotOfflineEventActive")
|
||||||
|
data class BotOfflineEventActiveDTO(val qq: Long) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotOfflineEventForce")
|
||||||
|
data class BotOfflineEventForceDTO(val qq: Long, val title: String, val message: String) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotOfflineEventDropped")
|
||||||
|
data class BotOfflineEventDroppedDTO(val qq: Long) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotReloginEvent")
|
||||||
|
data class BotReloginEventDTO(val qq: Long) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotGroupPermissionChangeEvent")
|
||||||
|
data class BotGroupPermissionChangeEventDTO(val origin: MemberPermission, val new: MemberPermission, val groupDTO: GroupDTO) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotMuteEvent")
|
||||||
|
data class BotMuteEventDTO(val durationSeconds: Int, val operator: MemberDTO) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotUnmuteEvent")
|
||||||
|
data class BotUnmuteEventDTO(val operator: MemberDTO) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("BotJoinGroupEvent")
|
||||||
|
data class BotJoinGroupEventDTO(val group: GroupDTO) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("GroupNameChangeEvent")
|
||||||
|
data class GroupNameChangeEventDTO(val origin: String, val new: String, val group: GroupDTO, val isByBot: Boolean) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("GroupEntranceAnnouncementChangeEvent")
|
||||||
|
data class GroupEntranceAnnouncementChangeEventDTO(val origin: String, val new: String, val group: GroupDTO, val operator: MemberDTO?) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("GroupMuteAllEvent")
|
||||||
|
data class GroupMuteAllEventDTO(val origin: Boolean, val new: Boolean, val group: GroupDTO, val operator: MemberDTO?) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("GroupAllowAnonymousChatEvent")
|
||||||
|
data class GroupAllowAnonymousChatEventDTO(val origin: Boolean, val new: Boolean, val group: GroupDTO, val operator: MemberDTO?) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("GroupAllowConfessTalkEvent")
|
||||||
|
data class GroupAllowConfessTalkEventDTO(val origin: Boolean, val new: Boolean, val group: GroupDTO, val isByBot: Boolean) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("GroupAllowMemberInviteEvent")
|
||||||
|
data class GroupAllowMemberInviteEventDTO(val origin: Boolean, val new: Boolean, val group: GroupDTO, val operator: MemberDTO?) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("MemberJoinEvent")
|
||||||
|
data class MemberJoinEventDTO(val member: MemberDTO) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("MemberLeaveEventKick")
|
||||||
|
data class MemberLeaveEventKickDTO(val member: MemberDTO, val operator: MemberDTO?) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("MemberLeaveEventQuit")
|
||||||
|
data class MemberLeaveEventQuitDTO(val member: MemberDTO) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("MemberCardChangeEvent")
|
||||||
|
data class MemberCardChangeEventDTO(val origin: String, val new: String, val group: GroupDTO, val operator: MemberDTO?) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("MemberSpecialTitleChangeEvent")
|
||||||
|
data class MemberSpecialTitleChangeEventDTO(val origin: String, val new: String, val member: MemberDTO) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("MemberPermissionChangeEvent")
|
||||||
|
data class MemberPermissionChangeEventDTO(val origin: MemberPermission, val new: MemberPermission, val member: MemberDTO) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("MemberMuteEvent")
|
||||||
|
data class MemberMuteEventDTO(val durationSeconds: Int, val member: MemberDTO, val operator: MemberDTO?) : BotEventDTO()
|
||||||
|
@Serializable
|
||||||
|
@SerialName("MemberUnmuteEvent")
|
||||||
|
data class MemberUnmuteEventDTO(val member: MemberDTO, val operator: MemberDTO?) : BotEventDTO()
|
@ -0,0 +1,47 @@
|
|||||||
|
package net.mamoe.mirai.console.graphical.styleSheet
|
||||||
|
|
||||||
|
import javafx.scene.Cursor
|
||||||
|
import javafx.scene.effect.BlurType
|
||||||
|
import javafx.scene.effect.DropShadow
|
||||||
|
import javafx.scene.paint.Color
|
||||||
|
import javafx.scene.text.FontWeight
|
||||||
|
import tornadofx.*
|
||||||
|
|
||||||
|
class LoginViewStyleSheet : Stylesheet() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val vBox by csselement("VBox")
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
|
||||||
|
vBox {
|
||||||
|
maxWidth = 500.px
|
||||||
|
maxHeight = 500.px
|
||||||
|
|
||||||
|
backgroundColor += c("39c5BB", 0.3)
|
||||||
|
backgroundRadius += box(15.px)
|
||||||
|
|
||||||
|
padding = box(50.px, 100.px)
|
||||||
|
spacing = 25.px
|
||||||
|
|
||||||
|
borderRadius += box(15.px)
|
||||||
|
effect = DropShadow(BlurType.THREE_PASS_BOX, Color.GRAY, 10.0, 0.0, 15.0, 15.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
textField {
|
||||||
|
prefHeight = 30.px
|
||||||
|
textFill = Color.BLACK
|
||||||
|
fontWeight = FontWeight.BOLD
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
backgroundColor += c("00BCD4", 0.8)
|
||||||
|
padding = box(10.px, 0.px)
|
||||||
|
prefWidth = 500.px
|
||||||
|
textFill = Color.WHITE
|
||||||
|
fontWeight = FontWeight.BOLD
|
||||||
|
cursor = Cursor.HAND
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,20 +17,20 @@ internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op:
|
|||||||
if (graphic != null) it.graphic = graphic
|
if (graphic != null) it.graphic = graphic
|
||||||
}
|
}
|
||||||
|
|
||||||
fun EventTarget.jfxTextfield(value: String? = null, op: TextField.() -> Unit = {}) = JFXTextField().attachTo(this, op) {
|
fun EventTarget.jfxTextfield(value: String? = null, op: JFXTextField.() -> Unit = {}) = JFXTextField().attachTo(this, op) {
|
||||||
if (value != null) it.text = value
|
if (value != null) it.text = value
|
||||||
}
|
}
|
||||||
|
|
||||||
fun EventTarget.jfxTextfield(property: ObservableValue<String>, op: TextField.() -> Unit = {}) = jfxTextfield().apply {
|
fun EventTarget.jfxTextfield(property: ObservableValue<String>, op: JFXTextField.() -> Unit = {}) = jfxTextfield().apply {
|
||||||
bind(property)
|
bind(property)
|
||||||
op(this)
|
op(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun EventTarget.jfxPasswordfield(value: String? = null, op: TextField.() -> Unit = {}) = JFXPasswordField().attachTo(this, op) {
|
fun EventTarget.jfxPasswordfield(value: String? = null, op: JFXPasswordField.() -> Unit = {}) = JFXPasswordField().attachTo(this, op) {
|
||||||
if (value != null) it.text = value
|
if (value != null) it.text = value
|
||||||
}
|
}
|
||||||
|
|
||||||
fun EventTarget.jfxPasswordfield(property: ObservableValue<String>, op: TextField.() -> Unit = {}) = jfxPasswordfield().apply {
|
fun EventTarget.jfxPasswordfield(property: ObservableValue<String>, op: JFXPasswordField.() -> Unit = {}) = jfxPasswordfield().apply {
|
||||||
bind(property)
|
bind(property)
|
||||||
op(this)
|
op(this)
|
||||||
}
|
}
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
package net.mamoe.mirai.console.graphical.view
|
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXAlert
|
|
||||||
import com.jfoenix.controls.JFXPopup
|
|
||||||
import javafx.beans.property.SimpleStringProperty
|
|
||||||
import javafx.scene.control.Label
|
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
|
||||||
import net.mamoe.mirai.console.graphical.util.jfxButton
|
|
||||||
import net.mamoe.mirai.console.graphical.util.jfxPasswordfield
|
|
||||||
import net.mamoe.mirai.console.graphical.util.jfxTextfield
|
|
||||||
import tornadofx.*
|
|
||||||
|
|
||||||
class LoginView : View() {
|
|
||||||
|
|
||||||
private val controller = find<MiraiGraphicalUIController>()
|
|
||||||
private val qq = SimpleStringProperty("")
|
|
||||||
private val psd = SimpleStringProperty("")
|
|
||||||
|
|
||||||
override val root = pane {
|
|
||||||
form {
|
|
||||||
fieldset("登录") {
|
|
||||||
field("QQ") {
|
|
||||||
jfxTextfield(qq)
|
|
||||||
}
|
|
||||||
field("密码") {
|
|
||||||
jfxPasswordfield(psd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jfxButton("登录").action {
|
|
||||||
runAsync {
|
|
||||||
runBlocking {
|
|
||||||
controller.login(qq.value, psd.value)
|
|
||||||
}
|
|
||||||
}.ui {
|
|
||||||
// show dialog
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,50 @@
|
|||||||
|
package net.mamoe.mirai.console.graphical.view
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleStringProperty
|
||||||
|
import javafx.geometry.Pos
|
||||||
|
import javafx.scene.image.Image
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||||
|
import net.mamoe.mirai.console.graphical.styleSheet.LoginViewStyleSheet
|
||||||
|
import net.mamoe.mirai.console.graphical.util.jfxButton
|
||||||
|
import net.mamoe.mirai.console.graphical.util.jfxPasswordfield
|
||||||
|
import net.mamoe.mirai.console.graphical.util.jfxTextfield
|
||||||
|
import tornadofx.*
|
||||||
|
|
||||||
|
class LoginView : View("CNM") {
|
||||||
|
|
||||||
|
private val controller = find<MiraiGraphicalUIController>()
|
||||||
|
private val qq = SimpleStringProperty("")
|
||||||
|
private val psd = SimpleStringProperty("")
|
||||||
|
|
||||||
|
override val root = borderpane {
|
||||||
|
|
||||||
|
addStylesheet(LoginViewStyleSheet::class)
|
||||||
|
|
||||||
|
center = vbox {
|
||||||
|
|
||||||
|
imageview(Image(LoginView::class.java.classLoader.getResourceAsStream("character.png"))) {
|
||||||
|
alignment = Pos.CENTER
|
||||||
|
}
|
||||||
|
|
||||||
|
jfxTextfield(qq) {
|
||||||
|
promptText = "QQ"
|
||||||
|
isLabelFloat = true
|
||||||
|
}
|
||||||
|
|
||||||
|
jfxPasswordfield(psd) {
|
||||||
|
promptText = "Password"
|
||||||
|
isLabelFloat = true
|
||||||
|
}
|
||||||
|
|
||||||
|
jfxButton("Login").action {
|
||||||
|
runAsync {
|
||||||
|
runBlocking { controller.login(qq.value, psd.value) }
|
||||||
|
}.ui {
|
||||||
|
qq.value = ""
|
||||||
|
psd.value = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
mirai-console-graphical/src/main/resources/character.png
Normal file
BIN
mirai-console-graphical/src/main/resources/character.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Loading…
Reference in New Issue
Block a user