mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 18:00:33 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0643e9eac9
@ -126,7 +126,7 @@ JVM 上启动需 80M 内存, 每多一个机器人实例需要 30M 内存.
|
||||
您的 star 是对我们最大的鼓励(点击项目右上角)
|
||||
|
||||
## Wiki
|
||||
在 [Wiki](https://github.com/mamoe/mirai/wiki/Home) 中查看各类帮助,**如 API 示例**(可能过时,待 QQ Android 协议完成后会重写)。
|
||||
在 [Wiki](https://github.com/mamoe/mirai/wiki/Home) 中查看各类帮助,**如 API 示例**。
|
||||
|
||||
## Try
|
||||
|
||||
@ -187,4 +187,4 @@ bot.subscribeAlways<MemberPermissionChangedEvent> {
|
||||
## Acknowledgement
|
||||
特别感谢 [JetBrains](https://www.jetbrains.com/?from=mirai) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai) 等 IDE 的授权
|
||||
[<img src=".github/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=mirai)
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ fun main() {
|
||||
|
||||
MiraiHttpAPIServer.start()
|
||||
|
||||
bot.network.awaitDisconnection()
|
||||
bot.join()
|
||||
}
|
||||
```
|
||||
|
||||
@ -463,7 +463,7 @@ Content-Type:multipart/form-data
|
||||
{
|
||||
"type": "Image",
|
||||
"imageId": "{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.png" //群图片格式
|
||||
"imageId": "/f8f1ab55-bf8e-4236-b55e-955848d7069f" //好友图片格式
|
||||
//"imageId": "/f8f1ab55-bf8e-4236-b55e-955848d7069f" //好友图片格式
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -1,9 +1,15 @@
|
||||
package net.mamoe.mirai.console.graphical
|
||||
|
||||
import com.jfoenix.controls.JFXDecorator
|
||||
import javafx.scene.control.Button
|
||||
import javafx.stage.Stage
|
||||
import net.mamoe.mirai.console.MiraiConsole
|
||||
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||
import net.mamoe.mirai.console.graphical.view.Decorator
|
||||
import net.mamoe.mirai.console.graphical.view.PrimaryView
|
||||
import tornadofx.App
|
||||
import tornadofx.FX.Companion.primaryStage
|
||||
import tornadofx.UIComponent
|
||||
import tornadofx.find
|
||||
import tornadofx.launch
|
||||
|
||||
@ -11,7 +17,7 @@ fun main(args: Array<String>) {
|
||||
launch<MiraiGraphicalUI>(args)
|
||||
}
|
||||
|
||||
class MiraiGraphicalUI: App(PrimaryView::class) {
|
||||
class MiraiGraphicalUI: App(Decorator::class) {
|
||||
|
||||
override fun init() {
|
||||
super.init()
|
||||
|
@ -11,3 +11,9 @@ class BotModel(val uin: Long) {
|
||||
val logHistory = observableListOf<String>()
|
||||
val admins = observableListOf<Long>()
|
||||
}
|
||||
|
||||
class BotViewModel(botModel: BotModel? = null) : ItemViewModel<BotModel>(botModel) {
|
||||
val bot = bind(BotModel::botProperty)
|
||||
val logHistory = bind(BotModel::logHistory)
|
||||
val admins = bind(BotModel::admins)
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package net.mamoe.mirai.console.graphical.view
|
||||
|
||||
import com.jfoenix.controls.JFXDecorator
|
||||
import tornadofx.View
|
||||
|
||||
class Decorator: View() {
|
||||
|
||||
override val root = JFXDecorator(primaryStage, find<PrimaryView>().root)
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
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
|
||||
@ -8,26 +11,31 @@ import net.mamoe.mirai.console.graphical.util.jfxPasswordfield
|
||||
import net.mamoe.mirai.console.graphical.util.jfxTextfield
|
||||
import tornadofx.*
|
||||
|
||||
class LoginFragment : Fragment() {
|
||||
class LoginView : View() {
|
||||
|
||||
private val controller = find<MiraiGraphicalUIController>(FX.defaultScope)
|
||||
private val qq = SimpleStringProperty("0")
|
||||
private val controller = find<MiraiGraphicalUIController>()
|
||||
private val qq = SimpleStringProperty("")
|
||||
private val psd = SimpleStringProperty("")
|
||||
|
||||
override val root = form {
|
||||
fieldset("登录") {
|
||||
field("QQ") {
|
||||
jfxTextfield(qq)
|
||||
override val root = pane {
|
||||
form {
|
||||
fieldset("登录") {
|
||||
field("QQ") {
|
||||
jfxTextfield(qq)
|
||||
}
|
||||
field("密码") {
|
||||
jfxPasswordfield(psd)
|
||||
}
|
||||
}
|
||||
field("密码") {
|
||||
jfxPasswordfield(psd)
|
||||
jfxButton("登录").action {
|
||||
runAsync {
|
||||
runBlocking {
|
||||
controller.login(qq.value, psd.value)
|
||||
}
|
||||
}.ui {
|
||||
// show dialog
|
||||
}
|
||||
}
|
||||
}
|
||||
jfxButton("登录").action {
|
||||
runBlocking {
|
||||
controller.login(qq.value, psd.value)
|
||||
}
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +1,15 @@
|
||||
package net.mamoe.mirai.console.graphical.view
|
||||
|
||||
import com.jfoenix.controls.JFXListCell
|
||||
import javafx.geometry.Insets
|
||||
import javafx.geometry.Pos
|
||||
import com.jfoenix.controls.*
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.scene.control.Tab
|
||||
import javafx.scene.control.TabPane
|
||||
import javafx.scene.image.Image
|
||||
import javafx.scene.paint.Color
|
||||
import javafx.scene.text.FontWeight
|
||||
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||
import net.mamoe.mirai.console.graphical.model.BotModel
|
||||
import net.mamoe.mirai.console.graphical.util.jfxButton
|
||||
import net.mamoe.mirai.console.graphical.util.jfxListView
|
||||
import net.mamoe.mirai.console.graphical.util.jfxTabPane
|
||||
import tornadofx.*
|
||||
import java.io.FileInputStream
|
||||
|
||||
class PrimaryView : View() {
|
||||
|
||||
@ -35,20 +30,12 @@ class PrimaryView : View() {
|
||||
|
||||
setCellFactory {
|
||||
object : JFXListCell<BotModel>() {
|
||||
var tab: Tab? = null
|
||||
|
||||
init {
|
||||
onDoubleClick {
|
||||
if (tab == null) {
|
||||
(center as TabPane).tab(item.uin.toString()) {
|
||||
listview(item.logHistory)
|
||||
onDoubleClick { close() }
|
||||
tab = this
|
||||
}
|
||||
} else {
|
||||
(center as TabPane).tabs.add(tab)
|
||||
}
|
||||
tab?.select()
|
||||
(center as TabPane).logTab(
|
||||
text = item.uin.toString(),
|
||||
logs = item.logHistory
|
||||
).select()
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,44 +52,37 @@ class PrimaryView : View() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hbox {
|
||||
padding = Insets(10.0)
|
||||
spacing = 10.0
|
||||
alignment = Pos.CENTER
|
||||
|
||||
jfxButton("L").action {
|
||||
find<LoginFragment>().openModal()
|
||||
}
|
||||
jfxButton("P")
|
||||
jfxButton("S")
|
||||
|
||||
|
||||
style { backgroundColor += c("00BCD4") }
|
||||
children.style(true) {
|
||||
backgroundColor += c("00BCD4")
|
||||
fontSize = 15.px
|
||||
fontWeight = FontWeight.BOLD
|
||||
textFill = Color.WHITE
|
||||
borderRadius += box(25.px)
|
||||
backgroundRadius += box(25.px)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
center = jfxTabPane {
|
||||
tab("Main") {
|
||||
listview(controller.mainLog) {
|
||||
|
||||
fitToParentSize()
|
||||
cellFormat {
|
||||
graphic = label(it) {
|
||||
maxWidthProperty().bind(this@listview.widthProperty())
|
||||
isWrapText = true
|
||||
}
|
||||
}
|
||||
}
|
||||
tab("Login") {
|
||||
this += find<LoginView>().root
|
||||
}
|
||||
|
||||
tab("Plugin")
|
||||
|
||||
tab("Settings")
|
||||
|
||||
logTab("Main", controller.mainLog)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun TabPane.logTab(
|
||||
text: String? = null,
|
||||
logs: ObservableList<String>,
|
||||
op: Tab.() -> Unit = {}
|
||||
)= tab(text) {
|
||||
listview(logs) {
|
||||
|
||||
fitToParentSize()
|
||||
cellFormat {
|
||||
graphic = label(it) {
|
||||
maxWidthProperty().bind(this@listview.widthProperty())
|
||||
isWrapText = true
|
||||
}
|
||||
}
|
||||
}
|
||||
also(op)
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 4.6 KiB |
Loading…
Reference in New Issue
Block a user