Merge remote-tracking branch 'origin/master'

This commit is contained in:
Him188 2020-02-19 10:59:43 +08:00
commit 0643e9eac9
8 changed files with 81 additions and 72 deletions

View File

@ -126,7 +126,7 @@ JVM 上启动需 80M 内存, 每多一个机器人实例需要 30M 内存.
您的 star 是对我们最大的鼓励(点击项目右上角) 您的 star 是对我们最大的鼓励(点击项目右上角)
## Wiki ## Wiki
在 [Wiki](https://github.com/mamoe/mirai/wiki/Home) 中查看各类帮助,**如 API 示例**(可能过时,待 QQ Android 协议完成后会重写) 在 [Wiki](https://github.com/mamoe/mirai/wiki/Home) 中查看各类帮助,**如 API 示例**。
## Try ## Try
@ -187,4 +187,4 @@ bot.subscribeAlways<MemberPermissionChangedEvent> {
## Acknowledgement ## Acknowledgement
特别感谢 [JetBrains](https://www.jetbrains.com/?from=mirai) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai) 等 IDE 的授权 特别感谢 [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) [<img src=".github/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=mirai)

View File

@ -12,7 +12,7 @@ fun main() {
MiraiHttpAPIServer.start() MiraiHttpAPIServer.start()
bot.network.awaitDisconnection() bot.join()
} }
``` ```
@ -463,7 +463,7 @@ Content-Typemultipart/form-data
{ {
"type": "Image", "type": "Image",
"imageId": "{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.png" //群图片格式 "imageId": "{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.png" //群图片格式
"imageId": "/f8f1ab55-bf8e-4236-b55e-955848d7069f" //好友图片格式 //"imageId": "/f8f1ab55-bf8e-4236-b55e-955848d7069f" //好友图片格式
} }
``` ```

View File

@ -1,9 +1,15 @@
package net.mamoe.mirai.console.graphical 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.MiraiConsole
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController 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 net.mamoe.mirai.console.graphical.view.PrimaryView
import tornadofx.App import tornadofx.App
import tornadofx.FX.Companion.primaryStage
import tornadofx.UIComponent
import tornadofx.find import tornadofx.find
import tornadofx.launch import tornadofx.launch
@ -11,7 +17,7 @@ fun main(args: Array<String>) {
launch<MiraiGraphicalUI>(args) launch<MiraiGraphicalUI>(args)
} }
class MiraiGraphicalUI: App(PrimaryView::class) { class MiraiGraphicalUI: App(Decorator::class) {
override fun init() { override fun init() {
super.init() super.init()

View File

@ -11,3 +11,9 @@ class BotModel(val uin: Long) {
val logHistory = observableListOf<String>() val logHistory = observableListOf<String>()
val admins = observableListOf<Long>() 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)
}

View File

@ -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)
}

View File

@ -1,6 +1,9 @@
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 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.util.jfxButton 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 net.mamoe.mirai.console.graphical.util.jfxTextfield
import tornadofx.* import tornadofx.*
class LoginFragment : Fragment() { class LoginView : View() {
private val controller = find<MiraiGraphicalUIController>(FX.defaultScope) private val controller = find<MiraiGraphicalUIController>()
private val qq = SimpleStringProperty("0") private val qq = SimpleStringProperty("")
private val psd = SimpleStringProperty("") private val psd = SimpleStringProperty("")
override val root = form { override val root = pane {
fieldset("登录") { form {
field("QQ") { fieldset("登录") {
jfxTextfield(qq) field("QQ") {
jfxTextfield(qq)
}
field("密码") {
jfxPasswordfield(psd)
}
} }
field("密码") { jfxButton("登录").action {
jfxPasswordfield(psd) runAsync {
runBlocking {
controller.login(qq.value, psd.value)
}
}.ui {
// show dialog
}
} }
} }
jfxButton("登录").action {
runBlocking {
controller.login(qq.value, psd.value)
}
close()
}
} }
} }

View File

@ -1,20 +1,15 @@
package net.mamoe.mirai.console.graphical.view package net.mamoe.mirai.console.graphical.view
import com.jfoenix.controls.JFXListCell import com.jfoenix.controls.*
import javafx.geometry.Insets import javafx.collections.ObservableList
import javafx.geometry.Pos
import javafx.scene.control.Tab import javafx.scene.control.Tab
import javafx.scene.control.TabPane import javafx.scene.control.TabPane
import javafx.scene.image.Image 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.controller.MiraiGraphicalUIController
import net.mamoe.mirai.console.graphical.model.BotModel 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.jfxListView
import net.mamoe.mirai.console.graphical.util.jfxTabPane import net.mamoe.mirai.console.graphical.util.jfxTabPane
import tornadofx.* import tornadofx.*
import java.io.FileInputStream
class PrimaryView : View() { class PrimaryView : View() {
@ -35,20 +30,12 @@ class PrimaryView : View() {
setCellFactory { setCellFactory {
object : JFXListCell<BotModel>() { object : JFXListCell<BotModel>() {
var tab: Tab? = null
init { init {
onDoubleClick { onDoubleClick {
if (tab == null) { (center as TabPane).logTab(
(center as TabPane).tab(item.uin.toString()) { text = item.uin.toString(),
listview(item.logHistory) logs = item.logHistory
onDoubleClick { close() } ).select()
tab = this
}
} else {
(center as TabPane).tabs.add(tab)
}
tab?.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 { center = jfxTabPane {
tab("Main") {
listview(controller.mainLog) {
fitToParentSize() tab("Login") {
cellFormat { this += find<LoginView>().root
graphic = label(it) {
maxWidthProperty().bind(this@listview.widthProperty())
isWrapText = true
}
}
}
} }
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