fix: Fix the problem that the terminal exit fails (#8189)
Some checks failed
SonarCloud Scan / SonarCloud (push) Failing after -28s

This commit is contained in:
ssongliu 2025-03-19 11:43:21 +08:00 committed by GitHub
parent 99775e1eb4
commit 79eb0288b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 = () => {