diff --git a/src/vs/code/electron-sandbox/deploy/deployWindowMain.ts b/src/vs/code/electron-sandbox/deploy/deployWindowMain.ts index cc4cabda..1e406d1f 100644 --- a/src/vs/code/electron-sandbox/deploy/deployWindowMain.ts +++ b/src/vs/code/electron-sandbox/deploy/deployWindowMain.ts @@ -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';