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

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