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 883c007fa..dc0262224 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 @@ -16,6 +16,7 @@ import tornadofx.* class PrimaryView : View() { private val controller = find() + private lateinit var mainTabPane : TabPane override val root = borderpane { @@ -71,15 +72,22 @@ class PrimaryView : View() { center = jfxTabPane { - tab("Login").content = find().root + logTab("Main", controller.mainLog) tab("Plugins").content = find().root tab("Settings").content = find().root - logTab("Main", controller.mainLog) + tab("Login").content = find().root + + mainTabPane = this } } + + fun Tab.select() = apply { + if (!mainTabPane.tabs.contains(this)) mainTabPane.tabs.add(this) + mainTabPane.selectionModel.select(this) + } } private fun TabPane.logTab( @@ -87,13 +95,21 @@ private fun TabPane.logTab( logs: ObservableList, op: Tab.() -> Unit = {} ) = tab(text) { - listview(logs) { - fitToParentSize() - cellFormat { - graphic = label(it) { - maxWidthProperty().bind(this@listview.widthProperty()) - isWrapText = true + vbox { + buttonbar { + button("导出日志").action { } + button("关闭").action { close() } + } + + listview(logs) { + + fitToParentSize() + cellFormat { + graphic = label(it) { + maxWidthProperty().bind(this@listview.widthProperty()) + isWrapText = true + } } } }