293 lines
11 KiB
QML
293 lines
11 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Window 2.15
|
|
import QtQuick.Controls 2.15
|
|
import HuskarUI.Basic 1.0
|
|
import SSHManager 1.0
|
|
import QtQuick.Shapes 1.15
|
|
import QtQuick.Layouts 1.15
|
|
import QtGraphicalEffects 1.15
|
|
import "../MyGlobals" 1.0
|
|
import "../Component"
|
|
|
|
HusWindow {
|
|
id:addsw
|
|
width: 890
|
|
height: 630
|
|
visible: true
|
|
title: qsTr("我的服务器插件")
|
|
captionBar.topButtonVisible: true
|
|
captionBar.winIconDelegate: Image {
|
|
width: 20
|
|
height: 20
|
|
source: "qrc:/image/logo.png"
|
|
}
|
|
|
|
Shortcut {
|
|
sequences: ["Esc"]
|
|
onActivated: close()
|
|
}
|
|
|
|
|
|
// 初始化后自动连接示例(可选)
|
|
Component.onCompleted: {
|
|
|
|
}
|
|
|
|
// 窗口关闭时自动触发清理
|
|
Component.onDestruction: {
|
|
|
|
}
|
|
|
|
//0 服务端插件 1 双端插件
|
|
property int showMode : 0
|
|
|
|
//服务器的IP
|
|
property string server_ip: ""
|
|
|
|
property var pluginModel: []
|
|
property var pluginInfoWidow: null
|
|
|
|
//监听全局变量的变化 这里需要监听 因为在本页会产生刷新数据
|
|
Connections {
|
|
target: GlobalVars
|
|
//服务器插件信息
|
|
function onMyServerPluginListChanged(){
|
|
if(showMode === 0)initModel();
|
|
}
|
|
function onMyServerExPluginMapChanged(){
|
|
if(showMode === 1)initModel();
|
|
}
|
|
}
|
|
|
|
//窗口初始化
|
|
function init(serverip){
|
|
server_ip = serverip
|
|
getData();
|
|
}
|
|
|
|
//获取插件信息
|
|
function getData(){
|
|
if(server_ip.length === 0)return
|
|
//获取服务器的全部服务器插件
|
|
if(showMode === 0){
|
|
GlobalVars.getServerPlugins(server_ip)
|
|
}
|
|
//获取服务器的全部双端插件
|
|
else if(showMode === 1){
|
|
GlobalVars.getServerExPlugins(server_ip)
|
|
}
|
|
}
|
|
|
|
//通过信息构造模型
|
|
function initModel(){
|
|
var buf = [];
|
|
var Data = null;
|
|
if(showMode === 0){
|
|
//全局数据插件列表存在
|
|
if(GlobalVars.myServerPluginList){
|
|
Data = GlobalVars.myServerPluginList;
|
|
// 遍历对象的属性
|
|
for (var key in Data) {
|
|
var obj = Data[key];
|
|
if(GlobalVars.serverPluginMap[obj.ProjectName]){
|
|
if(GlobalVars.serverPluginMap[obj.ProjectName].ProjectVersion > obj.ProjectVersion){
|
|
obj["needupdate"] = true
|
|
}
|
|
}
|
|
buf.push(obj);
|
|
}
|
|
pluginModel =buf;
|
|
}
|
|
}
|
|
else if(showMode === 1){
|
|
//全局数据插件列表存在
|
|
if(GlobalVars.myServerExPluginMap){
|
|
Data = GlobalVars.myServerExPluginMap;
|
|
// 遍历对象的属性
|
|
for (var key in Data) {
|
|
var obj = Data[key];
|
|
obj.ProjectName = key
|
|
buf.push(obj);
|
|
}
|
|
pluginModel =buf;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
HusTabView {
|
|
id: defaultTabView
|
|
anchors.fill: parent
|
|
anchors.topMargin: 30
|
|
tabSize: HusTabView.Size_Auto
|
|
tabCentered: true
|
|
addButtonDelegate:Item{}
|
|
// 监听标签页变化
|
|
onCurrentIndexChanged: {
|
|
showMode = currentIndex
|
|
pluginModel = [];
|
|
getData();
|
|
}
|
|
|
|
contentDelegate: Rectangle {
|
|
anchors.fill: parent
|
|
color:"transparent"
|
|
ScrollView {
|
|
anchors.fill: parent
|
|
GridView {
|
|
id: gv
|
|
anchors.fill: parent
|
|
anchors.leftMargin: 24
|
|
anchors.margins: 4
|
|
cellWidth: 420
|
|
cellHeight: showMode === 1 ? 300 : 128
|
|
clip: true
|
|
model:pluginModel
|
|
|
|
delegate:Item { // 每个格子的容器
|
|
width: gv.cellWidth
|
|
height: gv.cellHeight
|
|
|
|
Card {
|
|
id:card
|
|
anchors.centerIn: parent // 在格子容器中居中
|
|
width: parent.width - 24 // 改用相对尺寸
|
|
height: parent.height - 24
|
|
isDarkMode: HusTheme.isDark
|
|
onClicked:function(){
|
|
if (!pluginInfoWidow) {
|
|
var Path = "Window_PluginInfo_Private.qml";
|
|
if(showMode === 1)Path = "Window_ExPluginInfo_Private.qml"
|
|
// 创建新窗口
|
|
var component = Qt.createComponent(Path);
|
|
pluginInfoWidow = component.createObject(parent);
|
|
if(showMode === 0)pluginInfoWidow.init(index)
|
|
if(showMode === 1){
|
|
pluginInfoWidow.init(modelData.ProjectName)
|
|
}
|
|
|
|
// 绑定关闭时自动销毁
|
|
pluginInfoWidow.closing.connect(function() {
|
|
pluginInfoWidow.destroy()
|
|
pluginInfoWidow = null // 关键:释放引用
|
|
})
|
|
}
|
|
pluginInfoWidow.y = GlobalVars.main_Window.y + 85
|
|
pluginInfoWidow.show()
|
|
pluginInfoWidow.raise() // 把窗口提到最前面
|
|
}
|
|
content: ColumnLayout {
|
|
width: parent.width
|
|
height: parent.height
|
|
spacing: 4
|
|
Rectangle{
|
|
id:title_row
|
|
Layout.fillWidth: true
|
|
height: 30
|
|
color:"transparent"
|
|
Text {
|
|
id:title
|
|
text: modelData.ProjectName
|
|
font {
|
|
pixelSize: 24
|
|
family: HusTheme.Primary.fontPrimaryFamily
|
|
bold: true
|
|
}
|
|
color: HusTheme.Primary.colorTextBase
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Text {
|
|
id:author
|
|
anchors.top: title_row.top
|
|
anchors.topMargin: 4
|
|
anchors.right: title_row.right
|
|
anchors.rightMargin: 10
|
|
text: {
|
|
if(modelData.needupdate === true)return "有新的版本!";
|
|
else return "作者:" + modelData.ProjectAuthor
|
|
}
|
|
|
|
font {
|
|
pixelSize: 16
|
|
family: HusTheme.Primary.fontPrimaryFamily
|
|
bold: true
|
|
}
|
|
color: {
|
|
if(modelData.needupdate === true)return "#32CD32";
|
|
else return HusTheme.Primary.colorTextBase
|
|
}
|
|
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: modelData.ProjectDescribe
|
|
wrapMode: Text.WordWrap
|
|
maximumLineCount: 2
|
|
font {
|
|
pixelSize: 14
|
|
family: HusTheme.Primary.fontPrimaryFamily
|
|
}
|
|
color: HusTheme.Primary.colorTextSecondary
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Item {
|
|
visible: showMode === 1
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
height:300
|
|
HusRectangle {
|
|
id: imageContainer
|
|
anchors.fill: parent
|
|
radius: 6
|
|
color: "transparent"
|
|
clip: true
|
|
|
|
Image {
|
|
id: card_image
|
|
asynchronous: true // 异步加载不阻塞UI
|
|
cache: true // 启用内存缓存
|
|
anchors.fill: parent
|
|
source: GlobalVars.server_url + "/rindro/getimg/" + modelData.ProjectName + "/0"
|
|
fillMode: Image.PreserveAspectCrop
|
|
}
|
|
|
|
layer.enabled: true
|
|
layer.effect: OpacityMask {
|
|
maskSource: Rectangle {
|
|
width: imageContainer.width
|
|
height: imageContainer.height
|
|
radius: imageContainer.radius
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
initModel: [
|
|
{
|
|
key: "1",
|
|
icon: HusIcon.CreditCardOutlined,
|
|
title: "服务端插件"
|
|
},
|
|
{
|
|
key: "2",
|
|
icon: HusIcon.CreditCardOutlined,
|
|
title: "双端插件"
|
|
}
|
|
]
|
|
}
|
|
|
|
|
|
}
|