修改多次点击下一步按钮时,页面自动向后跳问题, 添加点击时间间隔逻辑
This commit is contained in:
parent
f77887bd02
commit
0b598b9674
|
@ -50,6 +50,8 @@ class deployWindow {
|
|||
scriptList: any[] = [];
|
||||
configData = [];
|
||||
|
||||
nextBtnInvokeCheck: EventInvokeCheck | undefined;
|
||||
|
||||
// 创建监听器
|
||||
listenerInit = async (event: IpcRendererEvent, msg: any) => {
|
||||
{
|
||||
|
@ -390,6 +392,8 @@ class deployWindow {
|
|||
this.depList = [];
|
||||
this.scriptList = [];
|
||||
this.configData = [];
|
||||
|
||||
this.nextBtnInvokeCheck = new EventInvokeCheck(300);
|
||||
console.log("reset complete");
|
||||
}
|
||||
|
||||
|
@ -764,7 +768,9 @@ class deployWindow {
|
|||
|
||||
document.getElementById('nextStep')?.addEventListener('click', () => {
|
||||
console.log('click nextStep');
|
||||
this.nextPrev(1);
|
||||
if (this.nextBtnInvokeCheck!.canInvoke()) {
|
||||
this.nextPrev(1);
|
||||
}
|
||||
});
|
||||
document.getElementById('progressInfoCancel')?.addEventListener('click', () => {
|
||||
console.log('click cancel');
|
||||
|
@ -1195,6 +1201,36 @@ class deployWindow {
|
|||
}
|
||||
}
|
||||
|
||||
class EventInvokeCheck {
|
||||
|
||||
private lastInvokeTime: number; // 上一次触发时间
|
||||
private invokeInterval: number; // 触发间隔, 单位毫秒, 在此时间间隔内不再触发
|
||||
|
||||
constructor(invokeInterval: number) {
|
||||
this.lastInvokeTime = -1;
|
||||
this.invokeInterval = invokeInterval;
|
||||
}
|
||||
|
||||
public canInvoke(): boolean {
|
||||
if (this.invokeInterval <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
if (this.lastInvokeTime < 0) {
|
||||
this.lastInvokeTime = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (now - this.lastInvokeTime > this.invokeInterval) {
|
||||
this.lastInvokeTime = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function startup(configuration: DeployWindowConfiguration): void {
|
||||
console.log("-----------------dll---------head----startupdeploy");
|
||||
// const platformClass = configuration.data.platform === 'win32' ? 'windows' : configuration.data.platform === 'linux' ? 'linux' : 'mac';
|
||||
|
|
Loading…
Reference in New Issue