From 226ddadbd1b7eaf0c111856870a17602d52cc021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Fri, 22 Mar 2024 22:52:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(Terminal):=E4=BF=AE=E5=A4=8D=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E6=89=A7=E8=A1=8C=E5=91=BD=E4=BB=A4=E6=97=B6=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/stores/terminal.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/src/stores/terminal.ts b/web/src/stores/terminal.ts index 0887648f..203c1908 100644 --- a/web/src/stores/terminal.ts +++ b/web/src/stores/terminal.ts @@ -80,9 +80,11 @@ export const useTerminal = defineStore( } function taskCompleted(idx: number) { - if (typeof state.taskList[idx].callback != 'function') { - return - } + // 命令执行完毕,重新打开热更新 + if (import.meta.hot) import.meta.hot.send('custom:open-hot', { type: 'terminal' }) + + if (typeof state.taskList[idx].callback != 'function') return + const status = state.taskList[idx].status if (status == taskStatus.Failed || status == taskStatus.Unknown) { state.taskList[idx].callback(taskStatus.Failed) @@ -179,6 +181,9 @@ export const useTerminal = defineStore( } function startEventSource(taskKey: number) { + // 命令执行期间禁用热更新 + if (import.meta.hot) import.meta.hot.send('custom:close-hot', { type: 'terminal' }) + window.eventSource = new EventSource( buildTerminalUrl(state.taskList[taskKey].command, state.taskList[taskKey].uuid, state.taskList[taskKey].extend) )