梳理开发场景后端代码

This commit is contained in:
dinglili 2024-05-28 13:48:01 +08:00 committed by wangpenglong
parent bd409989f1
commit f62dfb187d
3 changed files with 394 additions and 130 deletions

View File

@ -1,129 +0,0 @@
const os = require('os');
const logger = require('./logger'); // 导入logger.js中的logger对象
const { exec } = require('child_process');
let { ipcRenderer, shell } = require('electron');
function selectAllScenario(checkBox: HTMLElement) {
var checkboxes = document.querySelectorAll('.scenarioSelection input[type="checkbox"]');
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = checkBox.checked;
}
}
let configData = [];
function showDependences(arg: any) {
configData = [];
configData.push(arg);
var elements = document.getElementsByClassName("scenarioSelection");
let configList = {};
let formattedDoc = '';
let selectAllVal = document.getElementById("selectAll");
var checks = document.querySelectorAll(".scenarioSelection > input");
selectAllVal.onclick = function () {
// 遍历复选框元素对象
for (var i = 0; i < checks.length; i++) {
// 将复选框的选中状态设置为和全选框一致
if (checks[i].value != "JavaScript_key")
checks[i].checked = selectAllVal.checked;
}
};
for (var i = 0; i < elements.length; i++) {
elements[i].addEventListener("change", function (event) {
// 根据选中不同的checkbox显示不同输出
if (event.target.checked) {
var selectedValue = event.target.value;
var firstClassList = configData[0]["first_class_list"];
if (selectedValue === "selectAll") {
let firstClassList = configData[0]["first_class_list"];
for (let key in firstClassList) {
if (key.endsWith("_key") && key != "JavaScript_key") {
configList[key] = configData[0]["second_class"][key];
}
}
} else {
configList[selectedValue] = configData[0]["second_class"][selectedValue];
}
} else {
var selectedValue = event.target.value;
if (selectedValue === "selectAll") {
configList = {};
} else {
delete configList[selectedValue];
}
}
//页面更新
let extList = [];
let depList = [];
let scriptList = [];
if (Object.keys(configList).length > 0) {
document.getElementById("nextStep").disabled = false;
} else {
document.getElementById("nextStep").disabled = true;
}
for (let key in configList) {
for (let val of configList[key]["ext-list"]) {
extList.push(val);
}
}
extList = [...new Set(extList)];
for (let key in configList) {
for (let val of configList[key]["script-list"]) {
scriptList.push(val);
}
}
for (let key in configList) {
let tDepList = configList[key]["pkg-list"];
//暂时只做deb包的处理
// if (tDepList["rpm"]) {
// for (let val of tDepList["rpm"]) {
// depList.push(key);
// }
// }
// else {
// for (let key in tDepList["deb"]) {
// depList.push(key);
// }
// }
if (tDepList["deb"]) {
for (let key in tDepList["deb"]) {
depList.push(key);
}
}
}
depList = [...new Set(depList)];
var SelectedDatas = {
configList: configList,
extList: extList,
depList: depList,
scriptList: scriptList
}
ipcRenderer.send('message-to-jsb', SelectedDatas);
if (depList.length > 0) {
formattedDoc = '<h2>软件列表:<span style="color: yellow; font-size: 12px;">请点击下一步输入密码安装以下软件</span></h2>';
}
else
formattedDoc = '<h2>软件列表:</h2>';
formattedDoc += Object.values(depList).map(element => `<h4 style='font-size: 16px; line-height: 0.1;margin-left:20px;'>${element}</h4>`).join('');
formattedDoc += '<h2>插件列表:</h2>';
formattedDoc += extList.map(element => `<h4 style='font-size: 16px; line-height: 0.1;margin-left:20px;'>${element}</h4>`).join('');
document.getElementById("outputPre").innerHTML = formattedDoc;
});
}
}
window.onload = function () {
configData = [];
}

View File

@ -71,6 +71,7 @@ class deployWindow {
extList = [];
depList = [];
scriptList = [];
configData = [];
private nativeHostService: INativeHostService;
// private productService: IProductService;
@ -584,12 +585,124 @@ class deployWindow {
form!.appendChild(label);
form!.appendChild(document.createElement("br"));
});
showDependences(depDataObject);
this.showDependences(depDataObject);
}
getLanguage() {
return 'zh-cn'
}
showDependences(arg: any) {
this.configData = [];
// this.configData.push(arg);
var elements = document.getElementsByClassName("scenarioSelection");
let configList: { [key: string]: any } = {};
let formattedDoc = '';
let selectAllVal = document.getElementById("selectAll") as HTMLInputElement;
var checks = document.querySelectorAll(".scenarioSelection > input");
selectAllVal.onclick = function () {
// 遍历复选框元素对象
for (var i = 0; i < checks.length; i++) {
// 将复选框的选中状态设置为和全选框一致
if ((checks[i] as HTMLInputElement).value != "JavaScript_key")
(checks[i] as HTMLInputElement).checked = selectAllVal.checked;
}
};
for (var i = 0; i < elements.length; i++) {
elements[i].addEventListener("change", (event) => {
// 根据选中不同的checkbox显示不同输出
const target = event.target as HTMLInputElement;
if (target!.checked) {
var selectedValue = target.value;
var firstClassList = arg["first_class_list"];
if (selectedValue === "selectAll") {
for (let key in firstClassList) {
if (key.endsWith("_key") && key != "JavaScript_key") {
configList[key] = arg["second_class"][key];
}
}
} else {
configList[selectedValue] = arg["second_class"][selectedValue];
}
} else {
var selectedValue = event.target.value;
if (selectedValue === "selectAll") {
configList = {};
} else {
delete configList[selectedValue];
}
}
//页面更新
let extList = [];
let depList = [];
let scriptList = [];
if (Object.keys(configList).length > 0) {
this.nextBtn!.disabled = false;
} else {
this.nextBtn!.disabled = true;
}
for (let key in configList) {
for (let val of configList[key]["ext-list"]) {
extList.push(val);
}
}
extList = [...new Set(extList)];
for (let key in configList) {
for (let val of configList[key]["script-list"]) {
scriptList.push(val);
}
}
for (let key in configList) {
let tDepList = configList[key]["pkg-list"];
//暂时只做deb包的处理
// if (tDepList["rpm"]) {
// for (let val of tDepList["rpm"]) {
// depList.push(key);
// }
// }
// else {
// for (let key in tDepList["deb"]) {
// depList.push(key);
// }
// }
if (tDepList["deb"]) {
for (let key in tDepList["deb"]) {
depList.push(key);
}
}
}
depList = [...new Set(depList)];
var SelectedDatas = {
configList: configList,
extList: extList,
depList: depList,
scriptList: scriptList
}
ipcRenderer.send('message-to-jsb', SelectedDatas);
if (depList.length > 0) {
formattedDoc = '<h2>软件列表:<span style="color: yellow; font-size: 12px;">请点击下一步输入密码安装以下软件</span></h2>';
}
else
formattedDoc = '<h2>软件列表:</h2>';
formattedDoc += Object.values(depList).map(element => `<h4 style='font-size: 16px; line-height: 0.1;margin-left:20px;'>${element}</h4>`).join('');
formattedDoc += '<h2>插件列表:</h2>';
formattedDoc += extList.map(element => `<h4 style='font-size: 16px; line-height: 0.1;margin-left:20px;'>${element}</h4>`).join('');
document.getElementById("outputPre")!.innerHTML = formattedDoc;
});
}
}
}
export function startup(configuration: DeployWindowConfiguration): void {

View File

@ -262,5 +262,285 @@ button#prevStep:disabled
align-items: flex-start;
}
.devContent {
display: flex;
flex-direction: row;
}
.devContentCol{
display: flex;
flex-direction: column;
}
/* 用圆圈表示表格的步骤: */
.indicator {
position: absolute;
bottom: 65px;
text-align: center;
left: 50%;
transform: translate(-50%);
}
.step {
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbbbbb;
border: none;
border-radius: 50%;
display: inline-block;
opacity: 0.5;
}
.scenarioSelection {
font-size: h4; /* 调整字体大小为h3 */
/* font-weight: bold; 可选:设置字体加粗 */
}
.depOutputTextbox input[type="text"],
.depOutputTextbox #outputPre {
height: 330px ;
overflow:auto;
width: 600px;
margin-left: 40px;
background-color: transparent;
border-width: 1px solid black;
}
#depOutDesc {
margin-top: -30px;
width: 600px;
}
.depOutputTextbox {
margin-left: 20px;
}
.installSelection,
.updateInstallConfig,
.installInfoConfig {
font-size: 18px;
line-height: 2.0;
}
.installInfo1 {
height: auto;
}
#checkboxForm {
width: 180px;
}
.formSeparator {
border-left: 1px solid;
/* 设置竖线样式 */
height: 360px;
/* 设置竖线高度,可以根据需要调整 */
margin-left: 10px;
/* 设置与form之间的间距可以根据需要调整 */
}
input[readonly] {
background-color: rgba(255, 255, 255, 0.5);
width: 400px;
}
.progress-container {
display: flex;
align-items: center;
margin: -8px;
}
.progress-download,
.progress-install,
.pkg-progress-install,
.progressinfo
{
position: absolute; /* 添加绝对定位 */
margin-left: 18%;
color: #000000;
}
.download-view,
.install-view,
.pkg-install-view,
.progress-view,
.progressDown
{
flex: 1;
height: 50px;
position: relative;
width: 800px;
margin-left: 8%;
}
.grey-progress-view {
flex: 1;
height: 26px;
position: relative;
width: 800px;
margin-left: 8%;
margin-top:10px;
margin-bottom: 8px;
border-radius: 30px;
background-color: grey;
border: 1px solid grey;
}
.detailShow{
margin-left: 8%;
font-weight: bold;
margin-top: 5px;
}
#DownShow,
#finishShow
{
height: 350px;
width: 700px;
flex: 1;
position: relative;
overflow-y: auto;
}
.detailInstallOutputTextbox{
margin-left: 8%;
font-weight: bold;
margin-top: 5px;
}
#detailInstallPre,
#installLogPre,
#extInstallLogPre,
#finishPage
{
height: 300px;
width: 700px;
flex: 1;
position: relative;
overflow-y: auto;
}
.dark{
color: #c6c6c6;
background-color: #3C3C3C;
}
pre .downloadHighlight::before {
content: "\2713"; /* Unicode对号字符 */
color: yellow;
margin-right: 5px;
}
pre .startHighlight::before {
content: "\25CF"; /* Unicode实心圆圈字符 */
color: gray;
margin-right: 5px;
}
pre .installedHighlight::before {
content: "\2713"; /* Unicode对号字符 */
color: green;
margin-right: 5px;
}
pre .depInstalledHighlight::before {
content: "\2713"; /* Unicode对号字符 */
color: green;
margin-right: 5px;
}
pre .depfailHighlight::before {
content: "\2717";
color: red;
margin-right: 5px;
}
.switchInstallOutput {
position: absolute;
}
.center div p {
margin-bottom: 0;
margin-top: 0;
font-size: 14px;
}
/* .graybt {
background-color:gray;
cursor:not-allowed;
}
button:disabled{
background-color:yellow;
}
.button.is-disabled, .button.is-disabled:focus, .button.is-disabled:hover{
background-color: gray;
border-color: transparent;
} */
button#prevStep:disabled ,
button#nextStep:disabled,
button#cancel:disabled
{
background-color: gray;
border-color: gray;
opacity: 0.5;
}
.checkbox {
-webkit-appearance:none;
-moz-appearance:none;
outline:none;
width:14px;
height:14px;
background:#fff;
vertical-align:middle;
}
.checkbox:checked{
background:#1177BB;
}
.checkbox:checked::after{
content:"";
height:5px;
width:8px;
border:#fff solid 2px;
position:absolute;
margin-top:2px;
margin-left:2px;
border-top:none;
border-right:none;
transform:rotate(-45deg);
}
.checkbox:disabled{
background: rgba(255, 255, 255, 0.5);
}
.checkboxselect {
-webkit-appearance:none;
-moz-appearance:none;
outline:none;
width:14px;
height:14px;
background:#1177BB;
vertical-align:middle;
}
.checkboxselect:checked{
background:#1177BB;
}
.checkboxselect:checked::after{
content:"";
height:5px;
width:8px;
border:#fff solid 2px;
position:absolute;
margin-top:2px;
margin-left:2px;
border-top:none;
border-right:none;
transform:rotate(-45deg);
}
.checkboxselect:disabled{
background: rgba(255, 255, 255, 0.5);
}