fix: Fix the problem that the terminal exit fails (#8189)

This commit is contained in:
ssongliu
2025-03-19 11:43:21 +08:00
committed by GitHub
parent 99775e1eb4
commit 79eb0288b4
3 changed files with 12 additions and 10 deletions

View File

@@ -68,9 +68,8 @@ func (b *BaseApi) WsSsh(c *gin.Context) {
<-quitChan
if wshandleError(wsConn, err) {
return
}
dt := time.Now().Add(time.Second)
_ = wsConn.WriteControl(websocket.CloseMessage, nil, dt)
}
func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
@@ -133,9 +132,9 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
<-quitChan
global.LOG.Info("websocket finished")
if wshandleError(wsConn, err) {
return
}
dt := time.Now().Add(time.Second)
_ = wsConn.WriteControl(websocket.CloseMessage, nil, dt)
}
func loadRedisInitCmd(c *gin.Context) (string, string, error) {

View File

@@ -100,4 +100,5 @@ func (lcmd *LocalCommand) Wait(quitChan chan bool) {
global.LOG.Errorf("ssh session wait failed, err: %v", err)
setQuit(quitChan)
}
setQuit(quitChan)
}

View File

@@ -85,7 +85,9 @@ function onClose(isKeepShow: boolean = false) {
term.value.dispose();
} catch {}
}
terminalElement.value.innerHTML = '';
if (terminalElement.value) {
terminalElement.value.innerHTML = '';
}
}
// terminal 相关代码 start
@@ -202,10 +204,10 @@ const errorRealTerminal = (ex: any) => {
const closeRealTerminal = (ev: CloseEvent) => {
if (heartbeatTimer.value) {
clearInterval(heartbeatTimer.value);
clearInterval(Number(heartbeatTimer.value));
}
term.value.write('The connection has been disconnected.');
term.value.write(ev.reason);
term.value?.write('The connection has been disconnected.');
term.value?.write(ev.reason);
};
const isWsOpen = () => {