diff --git a/README.md b/README.md index f9151ddc1..4e77e9bca 100644 --- a/README.md +++ b/README.md @@ -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 { ## Acknowledgement 特别感谢 [JetBrains](https://www.jetbrains.com/?from=mirai) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai) 等 IDE 的授权 [](https://www.jetbrains.com/?from=mirai) - \ No newline at end of file + diff --git a/mirai-api-http/README_CH.md b/mirai-api-http/README_CH.md index d056170e4..895d1b2e3 100644 --- a/mirai-api-http/README_CH.md +++ b/mirai-api-http/README_CH.md @@ -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" //好友图片格式 } ``` diff --git a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt index 7e5633dee..b543a06ee 100644 --- a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt +++ b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt @@ -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) { launch(args) } -class MiraiGraphicalUI: App(PrimaryView::class) { +class MiraiGraphicalUI: App(Decorator::class) { override fun init() { super.init() diff --git a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/model/BotModel.kt b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/model/BotModel.kt index 8d15d6998..542f8b146 100644 --- a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/model/BotModel.kt +++ b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/model/BotModel.kt @@ -11,3 +11,9 @@ class BotModel(val uin: Long) { val logHistory = observableListOf() val admins = observableListOf() } + +class BotViewModel(botModel: BotModel? = null) : ItemViewModel(botModel) { + val bot = bind(BotModel::botProperty) + val logHistory = bind(BotModel::logHistory) + val admins = bind(BotModel::admins) +} \ No newline at end of file diff --git a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/Decorator.kt b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/Decorator.kt new file mode 100644 index 000000000..9ecff5fda --- /dev/null +++ b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/Decorator.kt @@ -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().root) +} \ No newline at end of file diff --git a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginFragment.kt b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginFragment.kt index 437031ca4..387fcc7da 100644 --- a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginFragment.kt +++ b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/LoginFragment.kt @@ -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(FX.defaultScope) - private val qq = SimpleStringProperty("0") + private val controller = find() + 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() - } } } \ No newline at end of file diff --git a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt index 58036ac6e..1a81c3721 100644 --- a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt +++ b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt @@ -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() { - 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().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().root } + + tab("Plugin") + + tab("Settings") + + logTab("Main", controller.mainLog) } } } + +private fun TabPane.logTab( + text: String? = null, + logs: ObservableList, + op: Tab.() -> Unit = {} +)= tab(text) { + listview(logs) { + + fitToParentSize() + cellFormat { + graphic = label(it) { + maxWidthProperty().bind(this@listview.widthProperty()) + isWrapText = true + } + } + } + also(op) +} \ No newline at end of file diff --git a/mirai-console-graphical/src/main/resources/logo.png b/mirai-console-graphical/src/main/resources/logo.png index 7be6c6871..bded5f137 100644 Binary files a/mirai-console-graphical/src/main/resources/logo.png and b/mirai-console-graphical/src/main/resources/logo.png differ