Check plugins update

This commit is contained in:
ryoii 2020-04-03 17:28:35 +08:00
parent 234db0a65a
commit c9b1dac567
3 changed files with 34 additions and 19 deletions

View File

@ -125,7 +125,7 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
}
}
fun checkLatest(plugin: PluginModel) {
fun checkUpdate(plugin: PluginModel) {
pluginList.forEach {
if (it.name == plugin.name && it.author == plugin.author) {
if (plugin.version > it.version) {

View File

@ -99,15 +99,17 @@ class PluginsCenterView : View() {
val map = center.fetchPlugin(page++)
if (map.isEmpty()) return@runBlocking
map.forEach {
ret.add(
PluginModel(
it.value.name,
it.value.version,
it.value.author,
it.value.description,
it.value
)
)
with(PluginModel(
it.value.name,
it.value.version,
it.value.author,
it.value.description,
it.value
)) {
ret.add(this)
controller.checkUpdate(this)
controller.checkAmbiguous(this)
}
}
}
}

View File

@ -1,12 +1,15 @@
package net.mamoe.mirai.console.graphical.view
import com.jfoenix.controls.JFXTreeTableColumn
import javafx.scene.control.TreeTableCell
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import net.mamoe.mirai.console.graphical.model.PluginModel
import net.mamoe.mirai.console.graphical.stylesheet.PluginViewStyleSheet
import net.mamoe.mirai.console.graphical.util.jfxButton
import net.mamoe.mirai.console.graphical.util.jfxTreeTableView
import tornadofx.View
import tornadofx.addStylesheet
import tornadofx.visibleWhen
class PluginsView : View() {
@ -50,15 +53,25 @@ class PluginsView : View() {
JFXTreeTableColumn<PluginModel, PluginModel>("操作").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.08))
// setCellValueFactory { return@setCellValueFactory it.value.valueProperty() }
//
// setCellFactory {
// return@setCellFactory object : TreeTableCell<PluginModel, PluginModel>() {
// override fun updateItem(item: PluginModel?, empty: Boolean) {
//
// }
// }
// }
setCellValueFactory { return@setCellValueFactory it.value.valueProperty() }
setCellFactory {
return@setCellFactory object : TreeTableCell<PluginModel, PluginModel>() {
override fun updateItem(item: PluginModel?, empty: Boolean) {
if (item != null && !empty) {
graphic = jfxButton("更新") {
visibleWhen(item.expiredProperty)
// to do update
}
text = ""
} else {
graphic = null
text = ""
}
}
}
}
}
)
}