解决点击取消,不输入密码,安装显示进度不到100%;安装失败,显示进度条颜色为红色

This commit is contained in:
dinglili 2024-07-16 16:41:54 +08:00 committed by wangpenglong
parent 919fdefc9c
commit 9e942f12b5
5 changed files with 43 additions and 25 deletions

View File

@ -144,6 +144,7 @@
<span class="progressinfoValue">00.00%</span>
</div>
<div>
<span id="progressInfoFinishFail" class="progressInfoFinishFail"></span>
<span id="progressInfoFinish" class="progressInfoFinish"></span>
<label id="progressInfoCancel" class="progressInfoCancel">取消</label>
</div>
@ -174,7 +175,6 @@
<div class="helpLink" id="helpLink" style="float: left;" ></div>
<div class="btn-group" style="float: right;">
<button class="prevStep" id="prevStep">上一步</button>
<button class="cancel" id="cancel" style="display:none"></button>
<button class="nextStep" id="nextStep" type="submit">下一步</button>
</div>
</div>

View File

@ -145,6 +145,7 @@
<span class="progressinfoValue">00.00%</span>
</div>
<div>
<span id="progressInfoFinishFail" class="progressInfoFinishFail"></span>
<span id="progressInfoFinish" class="progressInfoFinish"></span>
<label id="progressInfoCancel" class="progressInfoCancel">取消</label>
</div>
@ -175,7 +176,6 @@
<div class="helpLink" id="helpLink" style="float: left;" ></div>
<div class="btn-group" style="float: right;">
<button class="prevStep" id="prevStep">上一步</button>
<button class="cancel" id="cancel" style="display:none"></button>
<button class="nextStep" id="nextStep" type="submit">下一步</button>
</div>
</div>

View File

@ -19,7 +19,6 @@ class deployWindow {
onlineUpdateConfigRadio: HTMLElement | null = null;
nextBtn: HTMLButtonElement | null;
prevBtn: HTMLButtonElement | null;
cancelBtn: HTMLButtonElement | null;
onlineInstallTabArray: string[] = ["homepage", "waitTab", "onlineInstallTab1", "onlineInstallTab2", "onlineInstallTab3", "onlineInstallTab4"];
onlineInstallTabArrayIndex = 0;
@ -262,7 +261,7 @@ class deployWindow {
console.log("end:" + key);
//检查某个开发场景的软件包是否全部安装成功
let tmp = this.getNameFromKey(key);
if (this.checkInstalledSucc(key, this.configList, this.extInstallState)) {
if (this.checkKeyInstalledSucc(key, this.configList, this.extInstallState)) {
writeKeyJson.push(key);
showContext += tmp + "安装成功\n";
} else {
@ -273,8 +272,8 @@ class deployWindow {
ipcRenderer.send("kylinide.installWizard.init", { type: "writeKey", keys: writeKeyJson });
}
showContext += "点击结束按钮退出开发环境快速部署\n"
this.goFinish(showContext, false, true);
let allSuccess = this.checkAllInstalledSucc(this.extInstallState);
this.goFinish(showContext, false, allSuccess);
console.log("安装结束:成功");
}
}
@ -296,7 +295,10 @@ class deployWindow {
let showContext = '';
showContext += "取消安装\n";
showContext += "点击结束按钮退出开发环境快速部署\n"
this.goFinish(showContext, false, false);
let allSuccess = this.checkAllInstalledSucc(this.extInstallState);
if (!allSuccess) {
this.goFinish(showContext, true, allSuccess);
}
console.log("安装结束:取消");
}
};
@ -305,8 +307,9 @@ class deployWindow {
if (msg.type == "pkgNotAuth") {
let showContext = '';
showContext += "授权失败,结束安装\n";
showContext += "点击结束按钮退出开发环境快速部署\n"
showContext += "点击结束按钮退出开发环境快速部署\n";
this.goFinish(showContext, true, false);
console.log("安装结束:授权失败")
}
};
@ -332,7 +335,6 @@ class deployWindow {
this.onlineUpdateConfigRadio = document.getElementById("onlineUpdateConfig");
this.nextBtn = document.getElementById("nextStep") as HTMLButtonElement;
this.prevBtn = document.getElementById("prevStep") as HTMLButtonElement;
this.cancelBtn = document.getElementById('cancel') as HTMLButtonElement;
this.showTab(this.currentTab);
this.removeAllListeners();
this.registerEventListener();
@ -420,11 +422,16 @@ class deployWindow {
var style = document.createElement('style');
style.textContent = ".progress-view::-webkit-progress-value { background-color: #1AC465; }";
document.head.appendChild(style);
} else {
document.getElementById("progressInfoFinishFail")!.style.display = 'inline-block';
// 选择包含进度条的元素,并设置伪元素样式
var style = document.createElement('style');
style.textContent = ".progress-view::-webkit-progress-value { background-color: red; }";
document.head.appendChild(style);
}
this.nextBtn!.innerText = "结束";
this.nextBtn!.disabled = false;
this.cancelBtn!.disabled = true;
this.logShow = 0;
ipcRenderer.send("kylinide.installWizard.removeFileLister", { type: "extFile" });
ipcRenderer.send("kylinide.installWizard.removeFileLister", { type: "pkgFile" });
@ -552,6 +559,7 @@ class deployWindow {
document.getElementsByClassName("progressinfoValue")[0].innerHTML = "0%";
document.getElementById("progressInfoCancel")!.style.display = 'inline-block';
document.getElementById("progressInfoFinish")!.style.display = 'none';
document.getElementById("progressInfoFinishFail")!.style.display = 'none';
let extPreElement = document.getElementById("extInstallLogPre");
extPreElement!.innerHTML = "";
@ -658,8 +666,6 @@ class deployWindow {
this.prevBtn!.disabled = true;
this.nextBtn!.disabled = true;
this.nextBtn!.innerHTML = "结束";
this.cancelBtn!.innerText = "取消";
// this.cancelBtn!.style.display = "inline";
}
}
}
@ -735,7 +741,6 @@ class deployWindow {
if (this.onlineInstallRadio instanceof HTMLInputElement && this.onlineInstallRadio!.checked
&& this.onlineInstallTabArray[this.onlineInstallTabArrayIndex] == "onlineInstallTab4"
&& this.finishFlag !== 0
// && this.cancelBtn!.disabled == false
) {
ipcRenderer.send('kylinide.installWizard.show', { type: "info", message: "正在进行安装操作,若关闭窗口,则需先点击取消按钮中断安装过程。", title: "提示" });
//检查是否有进程正在安装,如果是,则提醒用户先点击取消安装,停止后台程序。然后再关闭程序
@ -782,13 +787,6 @@ class deployWindow {
ipcRenderer.send('kylinide.installWizard.msg.process', { type: "cancel" });
console.log("render send kylinide.installWizard.msg.process:cancel");
});
this.cancelBtn!.addEventListener('click', () => {
console.log('click cancel');
// ipcRenderer.removeAllListeners('kylinide.installWizard.msg');
ipcRenderer.send('kylinide.installWizard.msg.process', { type: "cancel" });
console.log("render send kylinide.installWizard.msg.process:cancel");
});
/**
* /
*/
@ -1142,7 +1140,8 @@ class deployWindow {
}
return name;
}
checkInstalledSucc(key: any, configList: any, extInstallState: any) {
//获取开发场景安装状态
checkKeyInstalledSucc(key: any, configList: any, extInstallState: any) {
let flagjson = 0;
for (let depname in configList[key]['pkg-list']['deb']) {
if (extInstallState.get(depname) != 12) {
@ -1167,6 +1166,19 @@ class deployWindow {
return true;
}
}
//检查是否所有的软件包,插件,脚本均已成功
checkAllInstalledSucc(extInstallState: any) {
let flag = 0;
for (let value of extInstallState.values()) {
if (value != 12 && value != 15) {
flag++;
break;
}
}
return flag > 0 ? false : true;
}
//发送执行脚本请求
checkScripts(msg: any) {
@ -1179,7 +1191,6 @@ class deployWindow {
depList: this.depList,
script: obj
};
// console.log('renderer send kylinide.installWizard.msg.process', JSON.stringify(installMsg));
ipcRenderer.send("kylinide.installWizard.msg.process", installMsg);
} else if (msg.type === "depInstallFail") {
this.extInstallState.set(obj['file_name'], 16);

View File

@ -883,6 +883,12 @@ input[readonly] {
margin: 0px;
padding: 0px;
}
.progressInfoFinishFail:before{
content: "\2717";
color: red;
margin: 0px;
padding: 0px;
}
.progress-view {
height: 4px;

View File

@ -365,10 +365,11 @@ export class DeployMainService implements IDeployMainService {
}
}
else if (msg.type == "cancel") {
this.logger.info("用户点击取消安装按钮");
//1.结束监听
//2.结束正在执行的进程,下载,插件安装,软件包安装
if (this.installProcessId && this.installProcessId.pid && this.installProcessId.exitCode == null && this.flagPkexec == 0) {
this.println("取消安装before");
this.logger.info("取消依赖包安装");
// var killcommand = `pkexec sudo pkill -TERM -P ${installProcessId.pid}`;
var killcommand = `pkexec sudo pkill -f 'bash ${this.installConfig}/install.sh'`;
const sudokill = spawn(killcommand, { shell: true, stdio: 'inherit' });
@ -424,13 +425,13 @@ export class DeployMainService implements IDeployMainService {
}
} else if (msg.type === 'extFile') {
if (this.extlogFsWatcher) {
this.logger.info("关闭插件日志文件监听");
this.logger.info("关闭插件安装日志文件监听");
this.extlogFsWatcher.close();
this.extlogFsWatcher = null;
}
} else if (msg.type === 'pkgFile') {
if (this.pkglogFsWatcher) {
this.logger.info("关闭软件包日志文件监听");
this.logger.info("关闭软件包安装日志文件监听");
this.pkglogFsWatcher.close();
this.pkglogFsWatcher = null;
}