Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
974ef61b
Commit
974ef61b
authored
Feb 20, 2020
by
Him188
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
3e29fbf3
0795e42f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
226 additions
and
7 deletions
+226
-7
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/DTO.kt
...c/main/kotlin/net/mamoe/mirai/api/http/data/common/DTO.kt
+7
-3
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/EventDTO.kt
...n/kotlin/net/mamoe/mirai/api/http/data/common/EventDTO.kt
+118
-0
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/styleSheet/LoginViewStyleSheet.kt
...mirai/console/graphical/styleSheet/LoginViewStyleSheet.kt
+47
-0
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/util/JFoenixAdaptor.kt
.../net/mamoe/mirai/console/graphical/util/JFoenixAdaptor.kt
+4
-4
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginView.kt
...otlin/net/mamoe/mirai/console/graphical/view/LoginView.kt
+50
-0
mirai-console-graphical/src/main/resources/character.png
mirai-console-graphical/src/main/resources/character.png
+0
-0
No files found.
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/DTO.kt
View file @
974ef61b
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 {
...
@@ -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
()
\ No newline at end of file
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/EventDTO.kt
0 → 100644
View file @
974ef61b
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
()
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/styleSheet/LoginViewStyleSheet.kt
0 → 100644
View file @
974ef61b
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
}
}
}
\ No newline at end of file
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/util/JFoenixAdaptor.kt
View file @
974ef61b
...
@@ -17,20 +17,20 @@ internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op:
...
@@ -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
:
JFX
TextField
.()
->
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
:
JFX
TextField
.()
->
Unit
=
{})
=
jfxTextfield
().
apply
{
bind
(
property
)
bind
(
property
)
op
(
this
)
op
(
this
)
}
}
fun
EventTarget
.
jfxPasswordfield
(
value
:
String
?
=
null
,
op
:
Text
Field
.()
->
Unit
=
{})
=
JFXPasswordField
().
attachTo
(
this
,
op
)
{
fun
EventTarget
.
jfxPasswordfield
(
value
:
String
?
=
null
,
op
:
JFXPassword
Field
.()
->
Unit
=
{})
=
JFXPasswordField
().
attachTo
(
this
,
op
)
{
if
(
value
!=
null
)
it
.
text
=
value
if
(
value
!=
null
)
it
.
text
=
value
}
}
fun
EventTarget
.
jfxPasswordfield
(
property
:
ObservableValue
<
String
>,
op
:
Text
Field
.()
->
Unit
=
{})
=
jfxPasswordfield
().
apply
{
fun
EventTarget
.
jfxPasswordfield
(
property
:
ObservableValue
<
String
>,
op
:
JFXPassword
Field
.()
->
Unit
=
{})
=
jfxPasswordfield
().
apply
{
bind
(
property
)
bind
(
property
)
op
(
this
)
op
(
this
)
}
}
...
...
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/Login
Fragment
.kt
→
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/Login
View
.kt
View file @
974ef61b
package
net.mamoe.mirai.console.graphical.view
package
net.mamoe.mirai.console.graphical.view
import
com.jfoenix.controls.JFXAlert
import
com.jfoenix.controls.JFXPopup
import
javafx.beans.property.SimpleStringProperty
import
javafx.beans.property.SimpleStringProperty
import
javafx.scene.control.Label
import
javafx.geometry.Pos
import
javafx.scene.image.Image
import
kotlinx.coroutines.runBlocking
import
kotlinx.coroutines.runBlocking
import
net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
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.jfxButton
import
net.mamoe.mirai.console.graphical.util.jfxPasswordfield
import
net.mamoe.mirai.console.graphical.util.jfxPasswordfield
import
net.mamoe.mirai.console.graphical.util.jfxTextfield
import
net.mamoe.mirai.console.graphical.util.jfxTextfield
import
tornadofx.*
import
tornadofx.*
class
LoginView
:
View
()
{
class
LoginView
:
View
(
"CNM"
)
{
private
val
controller
=
find
<
MiraiGraphicalUIController
>()
private
val
controller
=
find
<
MiraiGraphicalUIController
>()
private
val
qq
=
SimpleStringProperty
(
""
)
private
val
qq
=
SimpleStringProperty
(
""
)
private
val
psd
=
SimpleStringProperty
(
""
)
private
val
psd
=
SimpleStringProperty
(
""
)
override
val
root
=
pane
{
override
val
root
=
borderpane
{
form
{
fieldset
(
"登录"
)
{
addStylesheet
(
LoginViewStyleSheet
::
class
)
field
(
"QQ"
)
{
jfxTextfield
(
qq
)
center
=
vbox
{
imageview
(
Image
(
LoginView
::
class
.
java
.
classLoader
.
getResourceAsStream
(
"character.png"
)))
{
alignment
=
Pos
.
CENTER
}
}
field
(
"密码"
)
{
jfxPasswordfield
(
psd
)
jfxTextfield
(
qq
)
{
promptText
=
"QQ"
isLabelFloat
=
true
}
}
jfxPasswordfield
(
psd
)
{
promptText
=
"Password"
isLabelFloat
=
true
}
}
jfxButton
(
"登录"
).
action
{
jfxButton
(
"Login"
).
action
{
runAsync
{
runAsync
{
runBlocking
{
runBlocking
{
controller
.
login
(
qq
.
value
,
psd
.
value
)
}
controller
.
login
(
qq
.
value
,
psd
.
value
)
}
}.
ui
{
}.
ui
{
// show dialog
qq
.
value
=
""
psd
.
value
=
""
}
}
}
}
}
}
...
...
mirai-console-graphical/src/main/resources/character.png
0 → 100644
View file @
974ef61b
29.7 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment