import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtMultimedia 5.15 import DelegateUI 1.0 import QmlTool 1.0 import FileTransfer 1.0 import SSHManager 1.0 import "../MyGlobals" 1.0 import "../Component" 1.0 DelWindow { id:plugininfo_goods width: 890 height: 630 visible: true title: qsTr("插件详情页") captionBar.topButtonVisible: true captionBar.winIconDelegate: Image { id: name width: 20 height: 20 source: "qrc:/image/logo.png" } //原始数据 property var p_basedata: null //商店原始数据 property var p_shopbasedata:null //插件名 property string p_name : "未定名插件" //作者名 property string p_author : "未定名作者" //版本号 property string p_version: "0.0.1" //描述 property string p_description: "暂无描述" //售价 property int p_price: 0 //插件文件数组 property var p_filelist : [] //是否是凌众插件 property bool p_isrindro : false //图像 property string p_image:"qrc:/image/logo2.png" Component.onCompleted: { } Shortcut { sequences: ["Esc"] onActivated: close() } function escapeString(input) { return input .replace(/\\/g, "\\\\") // 转义反斜杠 .replace(/"/g, "\\\"") // 转义双引号 .replace(/\n/g, "\\n") // 转义换行符 .replace(/\r/g, "\\r") // 转义回车符 .replace(/\t/g, "\\t"); // 转义制表符 } function init(index){ if(!GlobalVars.myServerPluginList)return; var Data = GlobalVars.myServerPluginList[index] p_basedata = Data; p_name = Data.ProjectName p_author = Data.ProjectAuthor p_version = Data.ProjectVersion p_description = Data.ProjectDescribe //如果有插件文件数组 if(Data.ProjectFiles)p_filelist = Data.ProjectFiles //如果有售价才设置售价 if(Data.ProjectPrice)p_price = Data.ProjectPrice else p_price = 0 //如果是凌众的插件 if(Data.isrindro)p_isrindro = true else p_isrindro = false //去商店脚本辨别出自己的项目 for(var id in GlobalVars.serverPluginList){ var obj = GlobalVars.serverPluginList[id]; if(obj.ProjectName === p_name && obj.ProjectAuthor === p_author){ p_shopbasedata = obj } } //请求自己项目的配置文件 if(Data.ProjectConfig)GlobalVars.getServerPluginConfig(GlobalVars.sshConnectServer,Data.ProjectConfig,function(config){ var model = []; if(config){ configTabView.visible = true configTabView.initModel = []; } //老的解析方法和新的解析方法 if(typeof config.newcontent !== "string"){ if(config.newcontent)config.newcontent = JSON.stringify(config.newcontent,null,2); if(config.oldcontent)config.oldcontent = JSON.stringify(config.oldcontent,null,2); } else { if(config.newcontent)config.newcontent = Qt.atob(config.newcontent); if(config.oldcontent)config.oldcontent = Qt.atob(config.oldcontent); } if(config.newcontent){ model.push({ key: "1", icon: DelIcon.CreditCardOutlined, title: "配置文件", config:config.newcontent }) } if(config.oldcontent){ model.push({ key: "2", icon: DelIcon.CreditCardOutlined, title: "配置文件(旧)", config:config.oldcontent }) } if(model.length > 0){ configTabView.initModel = model } }); //判断是否需要更新 if(p_shopbasedata.ProjectVersion > p_version){ update_button.visible = true } } function buildQuest(filename){ var downloadurl = GlobalVars.server_url + "/dps/download/" + p_name + ":"; var updir = (filename.indexOf(".json") === -1 ? ("OfficialProject/" + p_shopbasedata.ProjectName + "/") : "OfficialConfig/"); GlobalVars.downlad_quest_window.addQuest(p_shopbasedata.ProjectName + ":" + filename,[ function(quest){ //下载 quest.status = 1; FileTransfer.postDownload(downloadurl + filename, "download/" + filename,{key:p_shopbasedata.ProjectName + ":" + filename},"quest"); }, function(quest){ if(GlobalVars.accServerList){ var server = GlobalVars.accServerList[GlobalVars.selectServer].serverIp //上传 quest.status = 1; FileTransfer.postUpload("http://" + server + ":65170/api/uploadfiles", "download/" + filename, "/dp_s/" + updir,"quest"); } else{ quest.instruction = true } },function(quest){ GlobalVars.msg_control.success("文件 :" + p_shopbasedata.ProjectName + ":" + filename + " 已下载并上传至服务器!"); quest.instruction = true //配置文件是最后来的 if(filename.indexOf("Proj.ifo") !== -1){ GlobalVars.getServerPlugins(GlobalVars.sshConnectServer) close() } }]); } Rectangle{ id:title anchors.left: parent.left anchors.leftMargin: 10 anchors.right: parent.right anchors.rightMargin: 15 anchors.top: parent.top anchors.topMargin: 45 height:78 + headerdiv.height + description.height radius:8 border.color: DelTheme.isDark ? "#23272e" : "#f0f4f7" border.width: 2 color:"transparent" Image { id: logo source: "qrc:/image/logo.png" anchors.left: parent.left anchors.leftMargin: 10 anchors.top: parent.top anchors.topMargin: 15 width: 48 height: 48 } DelDivider { id:headerdiv anchors.top: logo.bottom anchors.left: parent.left anchors.leftMargin: 1 width: parent.width - 1 height: 30 } Text { id:description anchors.left: parent.left anchors.leftMargin: 10 anchors.right: parent.right anchors.rightMargin: 10 anchors.top: headerdiv.bottom text: p_description wrapMode: Text.WordWrap font { pixelSize: 14 family: DelTheme.Primary.fontPrimaryFamily } color: DelTheme.Primary.colorTextBase } Text { id:pluginname anchors.left: logo.right anchors.leftMargin: 10 anchors.top: parent.top anchors.topMargin: 14 text: p_name font { pixelSize: 20 family: DelTheme.Primary.fontPrimaryFamily } color: DelTheme.Primary.colorTextBase } Text { anchors.left: logo.right anchors.leftMargin: 10 anchors.top: pluginname.bottom anchors.topMargin: 2 text: "作者: " + p_author font { pixelSize: 14 family: DelTheme.Primary.fontPrimaryFamily } color: DelTheme.Primary.colorTextBase } DelTag { id:version_tag anchors.left: pluginname.right anchors.leftMargin: 15 anchors.top: pluginname.top anchors.topMargin: 2 text:"Ver:" + p_version presetColor:"green" } DelButton { id:update_button visible: false anchors.right: parent.right anchors.rightMargin: 10 anchors.top: parent.top anchors.topMargin: 12 height: 26 text: "更新" colorText: "#32cd33" onClicked: { GlobalVars.backupServerPluginConfig(GlobalVars.sshConnectServer,p_basedata.ProjectConfig,function(ret){ //备份完成开始更新 if(ret){ buildQuest("Proj.ifo"); //项目逻辑文件 for (var i = 0; i < p_shopbasedata.ProjectFiles.length; i++) { buildQuest(p_shopbasedata.ProjectFiles[i]); } //项目配置文件 if(p_shopbasedata && p_shopbasedata.ProjectConfig.length > 0){ buildQuest(p_shopbasedata.ProjectConfig); } } }); } } DelButton { id:delete_button visible: true anchors.right: parent.right anchors.rightMargin: 10 anchors.top: parent.top anchors.topMargin: 42 height: 26 text: "删除" colorText: "#ff0000" onClicked: { SSHManager.sendInput("rm -rf " + "/dp_s/OfficialProject/" + p_shopbasedata.ProjectName) SSHManager.sendInput("echo '删除插件成功!'") close() } } } Rectangle{ id:content anchors.left: parent.left anchors.leftMargin: 10 anchors.right: parent.right anchors.rightMargin: 15 anchors.top: title.bottom anchors.topMargin: 10 anchors.bottom:parent.bottom anchors.bottomMargin: 10 radius:8 border.color: DelTheme.isDark ? "#23272e" : "#f0f4f7" border.width: 2 color:"transparent" clip: true DelTabView { id: configTabView visible: false anchors.fill: parent tabSize: DelTabView.Size_Auto tabCentered: true addButtonDelegate:Item{} contentDelegate: Rectangle { anchors.fill: parent color:"transparent" JsonEditor{ id:config_editor anchors.fill:parent projectConfigStr:model.config saveFunction:function(config){ //在新配置这里点保存才有反应 if(model.key === "1"){ GlobalVars.setServerPluginConfig(GlobalVars.sshConnectServer,p_basedata.ProjectConfig,config) close() } } } } } } }