DPS_Manage/Page/Window_ExPluginInfo_Private...

404 lines
14 KiB
QML
Raw Normal View History

2025-05-29 14:04:05 +08:00
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Dialogs 1.3
import QtMultimedia 5.15
2025-09-15 09:46:04 +08:00
import HuskarUI.Basic 1.0
2025-05-29 14:04:05 +08:00
import QmlTool 1.0
import FileTransfer 1.0
import SSHManager 1.0
import "../MyGlobals" 1.0
import "../Component" 1.0
2025-09-15 09:46:04 +08:00
HusWindow {
2025-05-29 14:04:05 +08:00
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_endTime: "null"
//描述
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 init(index){
if(!GlobalVars.myServerExPluginMap)return;
var Data = GlobalVars.myServerExPluginMap[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.ProjectDetails)details.model = Data.ProjectDetails
//判断是否启用
if(Data.open)plugins_check.checked = Data.open === 1 ? true : false
//判断到期时间
if(Data.endTime)p_endTime = Data.endTime;
// //判断是否需要更新
// 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()
}
}]);
}
FileDialog {
id: fileDialog
title: "请选择保存路径"
selectFolder: true // 选择文件而非文件夹
selectMultiple: false // 不允许多选
onAccepted: {
var filePath = fileDialog.fileUrl.toString()
var cleanPath = filePath.replace(/^(file:\/{2,3})/, "");
var filename = "双端插件-" + p_name + "导入包.zip";
GlobalVars.downlad_quest_window.addQuest(filename,[
function(quest){
//下载
quest.status = 1;
FileTransfer.postDownload(GlobalVars.server_url + "/rindro/download", cleanPath + "/" + filename,{projectName:p_name},"quest");
},
function(quest){
GlobalVars.msg_control.success(cleanPath + filename + "已下载完成!");
quest.instruction = true
}]);
}
onRejected: {
}
}
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
2025-09-15 09:46:04 +08:00
border.color: HusTheme.isDark ? "#23272e" : "#f0f4f7"
2025-05-29 14:04:05 +08:00
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
}
2025-09-15 09:46:04 +08:00
HusDivider {
2025-05-29 14:04:05 +08:00
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
2025-09-15 09:46:04 +08:00
family: HusTheme.Primary.fontPrimaryFamily
2025-05-29 14:04:05 +08:00
}
2025-09-15 09:46:04 +08:00
color: HusTheme.Primary.colorTextBase
2025-05-29 14:04:05 +08:00
}
Text {
id:pluginname
anchors.left: logo.right
anchors.leftMargin: 10
anchors.top: parent.top
anchors.topMargin: 14
text: p_name
font {
pixelSize: 20
2025-09-15 09:46:04 +08:00
family: HusTheme.Primary.fontPrimaryFamily
2025-05-29 14:04:05 +08:00
}
2025-09-15 09:46:04 +08:00
color: HusTheme.Primary.colorTextBase
2025-05-29 14:04:05 +08:00
}
Text {
anchors.left: logo.right
anchors.leftMargin: 10
anchors.top: pluginname.bottom
anchors.topMargin: 2
text: "作者: " + p_author
font {
pixelSize: 14
2025-09-15 09:46:04 +08:00
family: HusTheme.Primary.fontPrimaryFamily
2025-05-29 14:04:05 +08:00
}
2025-09-15 09:46:04 +08:00
color: HusTheme.Primary.colorTextBase
2025-05-29 14:04:05 +08:00
}
2025-09-15 09:46:04 +08:00
HusTag {
2025-05-29 14:04:05 +08:00
id:version_tag
anchors.left: pluginname.right
anchors.leftMargin: 15
anchors.top: pluginname.top
anchors.topMargin: 2
text:"Ver:" + p_version
presetColor:"green"
}
2025-09-15 09:46:04 +08:00
HusTag {
2025-05-29 14:04:05 +08:00
id:endTime_tag
anchors.left: version_tag.right
anchors.leftMargin: 15
anchors.top: pluginname.top
anchors.topMargin: 2
text:"到期时间:" + p_endTime
presetColor:"geekblue"
}
2025-09-15 09:46:04 +08:00
HusSwitch {
2025-05-29 14:04:05 +08:00
id:plugins_check
anchors.right: parent.right
anchors.rightMargin: 10
anchors.top: parent.top
anchors.topMargin: 15
checkedText: qsTr("开启插件")
uncheckedText: qsTr("关闭插件")
onCheckedChanged: {
GlobalVars.setServerExPluginsEnable(GlobalVars.sshConnectServer,p_name,checked === true ? 1 : 0);
}
}
2025-09-15 09:46:04 +08:00
HusButton {
2025-05-29 14:04:05 +08:00
id:delete_button
visible: true
anchors.right: parent.right
anchors.rightMargin: 10
anchors.top: parent.top
anchors.topMargin: 45
height: 26
text: "下载插件导入包"
// colorText: "#ff0000"
onClicked: {
fileDialog.open()
}
}
}
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
2025-09-15 09:46:04 +08:00
border.color: HusTheme.isDark ? "#23272e" : "#f0f4f7"
2025-05-29 14:04:05 +08:00
border.width: 2
color:"transparent"
clip: true
ScrollView {
anchors.fill: parent
anchors.margins: 10
Column {
id: contentColumn
anchors.fill: parent
spacing: 10
Repeater {
id:details
delegate: Column { // 直接使用 Column 作为根元素
width: parent.width
spacing: 0
Loader {
width: parent.width
sourceComponent: {
switch(modelData.type) {
case "str": return textComponent;
case "img": return imageComponent;
case "mov": return videoComponent;
default: return null;
}
}
// 动态绑定组件属性
property var itemData: modelData
}
}
}
}
}
}
// 定义组件映射
Component {
id: textComponent;
Text {
width: parent.width - 20
text: itemData.content
wrapMode: Text.Wrap
font {
pixelSize: 14
2025-09-15 09:46:04 +08:00
family: HusTheme.Primary.fontPrimaryFamily
2025-05-29 14:04:05 +08:00
}
2025-09-15 09:46:04 +08:00
color: HusTheme.Primary.colorTextBase
2025-05-29 14:04:05 +08:00
}
}
Component {
id: imageComponent;
Image {
source: GlobalVars.server_url + "/rindro/getimg/" + p_name + "/" + itemData.content
fillMode: Image.PreserveAspectFit
asynchronous: true
cache: true
// 动态计算宽度
width: Math.min(implicitWidth, parent.width)
// 让图像靠左边显示
anchors.left: parent.left
// 确保父级有明确宽度传递
property real maxWidth: parent ? parent.width : 0
// 异步加载完成后更新尺寸
onStatusChanged: {
if (status === Image.Ready) {
width = Math.min(implicitWidth, maxWidth)
}
}
}
}
Component {
id: videoComponent
Item {
id: videoContainer
width: parent.width
height: 400
// 视频播放器
Video {
id: videoPlayer
anchors.fill: parent
anchors.bottomMargin: 15
source: itemData.content
loops: MediaPlayer.Infinite
autoPlay: false
// 错误处理
onErrorChanged: {
if (error !== MediaPlayer.NoError) {
GlobalVars.msg_control.error("播放错误:", errorString);
}
}
}
// 播放控制按钮(可选)
Row {
anchors.top: videoPlayer.bottom
anchors.topMargin: 4
anchors.horizontalCenter: parent.horizontalCenter
spacing: 10
2025-09-15 09:46:04 +08:00
HusButton {
2025-05-29 14:04:05 +08:00
text: videoPlayer.playbackState === MediaPlayer.PlayingState ? "暂停" : "播放"
onClicked: videoPlayer.playbackState === MediaPlayer.PlayingState ? videoPlayer.pause() : videoPlayer.play()
}
2025-09-15 09:46:04 +08:00
HusButton {
2025-05-29 14:04:05 +08:00
text: "静音"
onClicked: videoPlayer.muted = !videoPlayer.muted
}
}
}
}
}