mirror of
				https://github.com/1Panel-dev/1Panel.git
				synced 2025-11-01 03:37:19 +08:00 
			
		
		
		
	fix: Fix the problem that the terminal exit fails (#8189)
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				SonarCloud Scan / SonarCloud (push) Failing after -28s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	SonarCloud Scan / SonarCloud (push) Failing after -28s
				
			This commit is contained in:
		
							parent
							
								
									99775e1eb4
								
							
						
					
					
						commit
						79eb0288b4
					
				
					 3 changed files with 12 additions and 10 deletions
				
			
		|  | @ -68,9 +68,8 @@ func (b *BaseApi) WsSsh(c *gin.Context) { | ||||||
| 
 | 
 | ||||||
| 	<-quitChan | 	<-quitChan | ||||||
| 
 | 
 | ||||||
| 	if wshandleError(wsConn, err) { | 	dt := time.Now().Add(time.Second) | ||||||
| 		return | 	_ = wsConn.WriteControl(websocket.CloseMessage, nil, dt) | ||||||
| 	} |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (b *BaseApi) ContainerWsSSH(c *gin.Context) { | func (b *BaseApi) ContainerWsSSH(c *gin.Context) { | ||||||
|  | @ -133,9 +132,9 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) { | ||||||
| 	<-quitChan | 	<-quitChan | ||||||
| 
 | 
 | ||||||
| 	global.LOG.Info("websocket finished") | 	global.LOG.Info("websocket finished") | ||||||
| 	if wshandleError(wsConn, err) { | 	dt := time.Now().Add(time.Second) | ||||||
| 		return | 	_ = wsConn.WriteControl(websocket.CloseMessage, nil, dt) | ||||||
| 	} | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func loadRedisInitCmd(c *gin.Context) (string, string, error) { | func loadRedisInitCmd(c *gin.Context) (string, string, error) { | ||||||
|  |  | ||||||
|  | @ -100,4 +100,5 @@ func (lcmd *LocalCommand) Wait(quitChan chan bool) { | ||||||
| 		global.LOG.Errorf("ssh session wait failed, err: %v", err) | 		global.LOG.Errorf("ssh session wait failed, err: %v", err) | ||||||
| 		setQuit(quitChan) | 		setQuit(quitChan) | ||||||
| 	} | 	} | ||||||
|  | 	setQuit(quitChan) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -85,7 +85,9 @@ function onClose(isKeepShow: boolean = false) { | ||||||
|             term.value.dispose(); |             term.value.dispose(); | ||||||
|         } catch {} |         } catch {} | ||||||
|     } |     } | ||||||
|     terminalElement.value.innerHTML = ''; |     if (terminalElement.value) { | ||||||
|  |         terminalElement.value.innerHTML = ''; | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // terminal 相关代码 start | // terminal 相关代码 start | ||||||
|  | @ -202,10 +204,10 @@ const errorRealTerminal = (ex: any) => { | ||||||
| 
 | 
 | ||||||
| const closeRealTerminal = (ev: CloseEvent) => { | const closeRealTerminal = (ev: CloseEvent) => { | ||||||
|     if (heartbeatTimer.value) { |     if (heartbeatTimer.value) { | ||||||
|         clearInterval(heartbeatTimer.value); |         clearInterval(Number(heartbeatTimer.value)); | ||||||
|     } |     } | ||||||
|     term.value.write('The connection has been disconnected.'); |     term.value?.write('The connection has been disconnected.'); | ||||||
|     term.value.write(ev.reason); |     term.value?.write(ev.reason); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const isWsOpen = () => { | const isWsOpen = () => { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue