修改多次点击下一步按钮,页面自动向后跳问题: 点击之后禁用按钮,跳转之后再启用按钮

This commit is contained in:
weike 2024-06-26 14:05:31 +08:00 committed by wangpenglong
parent 7b70d4ea1b
commit a49c3d3c9e
1 changed files with 35 additions and 30 deletions

View File

@ -351,14 +351,14 @@ class deployWindow {
x[n].style.display = 'flex';
//... and fix the Previous/Next buttons:
if (n === 0) {
document.getElementById('prevStep')!.style.display = 'none';
this.prevBtn!.style.display = 'none';
} else {
document.getElementById('prevStep')!.style.display = 'inline';
this.prevBtn!.style.display = 'inline';
}
if (n === (x.length - 1)) {
document.getElementById('nextStep')!.innerHTML = '确定';
this.nextBtn!.innerHTML = '确定';
} else {
document.getElementById('nextStep')!.innerHTML = "下一步";
this.nextBtn!.innerHTML = "下一步";
}
}
@ -432,6 +432,10 @@ class deployWindow {
}
async nextPrev(n: number) {
this.nextBtn!.disabled = true;
this.prevBtn!.disabled = true;
// This function will figure out which tab to display
// let x = document.getElementsByClassName('tab');
// Exit the function if any field in the current tab is invalid:
@ -466,6 +470,7 @@ class deployWindow {
console.log("renderer send kylinide.installWizard.init.configSelect");
let result = await ipcRenderer.invoke('kylinide.installWizard.init.configSelect', data);
if (result === void 0) {
this.prevBtn!.disabled = false;
return;
}
const parentdiv = document.getElementById('osInfo') as HTMLDivElement;
@ -498,6 +503,7 @@ class deployWindow {
let result = await ipcRenderer.invoke('kylinide.installWizard.init.configGetValue', data);
if (result === void 0) {
console.log("kylinide.installWizard.init.configGetValue result is void");
this.prevBtn!.disabled = false;
return;
}
console.log("kylinide.installWizard.init configGetValue depInfoData:" + result.depInfoData)
@ -512,16 +518,6 @@ class deployWindow {
this.setFisrtClass(depInfoData, result.selectKey);
this.extAddressPath = result.extAddressPath;
let checkboxForm = document.getElementById("checkboxForm");
//设置下一步按钮显示状态
let selectedCheckboxes = checkboxForm?.querySelectorAll('input[type="checkbox"]:checked');
// console.log("aaa+" + selectedCheckboxes.length);
if (selectedCheckboxes && selectedCheckboxes.length > 1) {
this.nextBtn!.disabled = false;
} else {
this.nextBtn!.disabled = true;
}
} else if (this.onlineInstallTabArray[this.onlineInstallTabArrayIndex] === "onlineInstallTab3") {
const checkboxForm = document.getElementById("checkboxForm");
console.log("nextPrev onlineInstallTab3");
@ -588,6 +584,7 @@ class deployWindow {
console.log("renderer send kylinide.installWizard.init httpVerify");
let result = await ipcRenderer.invoke('kylinide.installWizard.init.httpVerify');
if (result === void 0) {
this.prevBtn!.disabled = false;
console.log("kylinide.installWizard.init.httpVerify result is void");
return;
}
@ -598,13 +595,10 @@ class deployWindow {
}
this.onlineInstallTabArrayIndex = this.onlineInstallTabArrayIndex + 1;
this.showTabFromIndex(this.onlineInstallTabArray, this.onlineInstallTabArrayIndex);
if (this.nextBtn)
this.nextBtn.disabled = true;
if (this.prevBtn)
this.prevBtn.disabled = true;
let configData = await ipcRenderer.invoke('kylinide.installWizard.init.configVersify', { type: "configVersify" });
console.log("kylinide.installWizard.init configVersify ");
if (configData === void 0) {
this.prevBtn!.disabled = false;
console.log("kylinide.installWizard.init.configVersify result is void");
return;
}
@ -631,23 +625,35 @@ class deployWindow {
parentdiv.innerHTML = configData.message;
}
}
if (this.nextBtn && this.prevBtn) {
this.nextBtn.disabled = false;
this.prevBtn.disabled = false;
}
this.nextPrev(1);
} else {
this.custom_print("nextPrev this.onlineInstallTabArrayIndex != 0")
if (this.onlineInstallTabArray[this.onlineInstallTabArrayIndex] === "onlineInstallTab2") {
let checkboxForm = document.getElementById("checkboxForm");
//设置下一步按钮显示状态
let selectedCheckboxes = checkboxForm?.querySelectorAll('input[type="checkbox"]:checked');
// console.log("aaa+" + selectedCheckboxes.length);
if (selectedCheckboxes && selectedCheckboxes.length > 1) {
this.nextBtn!.disabled = false;
} else {
this.nextBtn!.disabled = true;
}
} else {
this.nextBtn!.disabled = false;
}
let preTab = document.getElementById(this.onlineInstallTabArray[this.onlineInstallTabArrayIndex]) as HTMLDivElement;
preTab.style.display = 'none';
this.onlineInstallTabArrayIndex = this.onlineInstallTabArrayIndex + n;
this.showTabFromIndex(this.onlineInstallTabArray, this.onlineInstallTabArrayIndex);
this.prevBtn!.disabled = false;
}
}
// if (onlineInstallTabArray[onlineInstallTabArrayIndex] === "onlineInstallTab3") {
// document.getElementById('nextStep').disabled = true;
// document.getElementById('nextStep').innerHTML = setLanguage('okStep');
// this.nextBtn!.disabled = true;
// this.nextBtn!.innerHTML = setLanguage('okStep');
// }
if (this.onlineInstallTabArray[this.onlineInstallTabArrayIndex] === "onlineInstallTab4") {
@ -762,12 +768,12 @@ class deployWindow {
ipcRenderer.send('kylinide.installWizard.skipWizard');
});
document.getElementById('prevStep')?.addEventListener('click', () => {
this.prevBtn!.addEventListener('click', () => {
console.log('click prevStep');
this.Prev(-1);
});
document.getElementById('nextStep')?.addEventListener('click', () => {
this.nextBtn!.addEventListener('click', () => {
console.log('click nextStep');
if (this.nextBtnInvokeCheck!.canInvoke()) {
this.nextPrev(1);
@ -779,7 +785,7 @@ class deployWindow {
ipcRenderer.send('kylinide.installWizard.msg.process', { type: "cancel" });
console.log("render send kylinide.installWizard.msg.process:cancel");
});
document.getElementById('cancel')?.addEventListener('click', () => {
this.cancelBtn!.addEventListener('click', () => {
console.log('click cancel');
// ipcRenderer.removeAllListeners('kylinide.installWizard.msg');
ipcRenderer.send('kylinide.installWizard.msg.process', { type: "cancel" });
@ -843,8 +849,7 @@ class deployWindow {
this.onlineInstallTabArrayIndex = this.onlineInstallTabArrayIndex + n;
}
if (this.onlineInstallTabArray[this.onlineInstallTabArrayIndex] === 'onlineInstallTab2') {
let bt = document.getElementById('nextStep') as HTMLButtonElement;
bt.disabled = false;
this.nextBtn!.disabled = false;
}
this.showTabFromIndex(this.onlineInstallTabArray, this.onlineInstallTabArrayIndex);
}
@ -892,8 +897,8 @@ class deployWindow {
let constent = "";
let flag = 0;
for (let i = 0; i < jsonSelectKey.length; i++) {
console.log("json:" + firstClass[jsonSelectKey[i]]['zh_cn']);
if (firstClass.hasOwnProperty(jsonSelectKey[i])) {
console.log("json:" + firstClass[jsonSelectKey[i]]['zh_cn']);
flag++;
constent += firstClass[jsonSelectKey[i]]['zh_cn'] + " ";
installedPkg.push(firstClass[jsonSelectKey[i]]['zh_cn']);