DPS_Manage/Page/Page_Home.qml

151 lines
4.5 KiB
QML
Raw Normal View History

2025-05-29 14:04:05 +08:00
import QtQuick 2.15
import QtQuick.Window 2.15
import DelegateUI 1.0
import "../MyGlobals" 1.0
import SSHManager 1.0
Item {
id:root_item
y : GlobalVars.main_Window.captionBar.height
height: GlobalVars.main_Window.height - GlobalVars.main_Window.captionBar.height
Component.onCompleted: {
GlobalVars.page_home = this;
//获取市场所有插件信息
GlobalVars.getShopAllProject();
//获取市场所有双端插件信息
GlobalVars.getShopAllProjectex();
//获取账号下的所有服务器
GlobalVars.getAccServerList();
//获取账号的个人信息
GlobalVars.getAccInfo();
//临时测试 创建一个下载窗口
// 创建新窗口
var component = Qt.createComponent("Window_DownloadQuest.qml");
var windowbuf = component.createObject(parent);
// 绑定关闭时
windowbuf.closing.connect(function() {
windowbuf.close.accepted = false // 阻止默认关闭行为
windowbuf.width = 799
windowbuf.hide() // 隐藏窗口
})
pageLoader.source = "Tab_home.qml"
initMenuServerList()
}
function initMenuServerList(){
if(GlobalVars.accServerList){
var arrbuf = [];
for(var i = 0; i < GlobalVars.accServerList.length;i++){
var obj = GlobalVars.accServerList[i];
var buf = {
key:"server",
source:"Tab_server.qml",
label: qsTr(obj.serverIp),
port:obj.port,
user:obj.userName,
passwd:obj.password,
iconSource: DelIcon.HomeOutlined
}
arrbuf.push(buf);
}
menu.setProperty(2,"menuChildren" , arrbuf);
}
}
//监听全局变量的变化
Connections {
target: GlobalVars
function onAccServerListChanged(){
initMenuServerList();
}
}
Rectangle {
visible: true
width: 220
height: parent.height
color: "transparent"
DelMenu {
id: menu
anchors.fill: parent
// showEdge: true
initModel: [
{
label: qsTr("首页"),
iconSource: DelIcon.HomeOutlined,
source:"Tab_home.qml"
},
{
type: "divider"
},
{
label: qsTr("我的服务器"),
iconSource: DelIcon.CloudServerOutlined,
},
{
label: qsTr("插件市场(服务端)"),
iconSource: DelIcon.ShopOutlined,
source:"Tab_shop.qml"
},
{
label: qsTr("插件市场(双端)"),
iconSource: DelIcon.ShopOutlined,
source:"Tab_shopex.qml"
},
{
label: qsTr("个人中心"),
iconSource: DelIcon.ProductOutlined,
source:"Tab_personal.qml"
},
{
label: qsTr("更新日志"),
iconSource: DelIcon.ClockCircleOutlined,
source:"Tab_update.qml"
},
{
label: qsTr("关于(赞助请看这里)"),
iconSource: DelIcon.InfoCircleOutlined,
source:"Tab_about.qml"
}
]
onClickMenu: function(deep,menuKey,menuData){
//表层
if(deep === 0){
pageLoader.source = menuData.source;
}
//服务器层
else if(deep === 1){
//连接了服务器
if(menuData.key === "server"){
pageLoader.source = ""
pageLoader.source = menuData.source;
pageLoader.item.init(menuData.label, menuData.port, menuData.user, menuData.passwd);
}
}
}
}
}
// 用于显示页面的区域
Rectangle {
id: pageArea
x: menu.width
width: parent.width - menu.width
height: parent.height
color: "transparent"
Loader {
id: pageLoader
anchors.fill: parent
}
}
}