优化终端socket断开后逻辑

This commit is contained in:
chaos-zhu 2024-08-15 09:37:41 +08:00
parent fb36c5ddc4
commit e0b12a98e8
2 changed files with 5 additions and 4 deletions

View File

@ -59,10 +59,7 @@ const fitAddon = ref(null)
const searchBar = ref(null)
const hasRegisterEvent = ref(false)
// const isConnectSuccess = ref(false)
// const isConnectFail = ref(false)
// const isConnecting = ref(true)
// const isReConnect = ref(false)
const socketConnected = ref(false)
const curStatus = ref(CONNECTING)
const terminal = ref(null)
const terminalRef = ref(null)
@ -121,6 +118,7 @@ const connectIO = () => {
})
socket.value.on('connect', () => {
console.log('/terminal socket已连接', host.value)
socketConnected.value = true
socket.value.emit('create', { host: host.value, token: token.value })
socket.value.on('connect_terminal_success', () => {
if (hasRegisterEvent.value) return // , . socket
@ -180,6 +178,7 @@ const connectIO = () => {
socket.value.removeAllListeners() //
// socket.value.off('output') // output,onData
curStatus.value = CONNECT_FAIL
socketConnected.value = false
term.value.write('\r\nError: 与面板socket连接断开。请关闭此tab并检查本地与面板连接是否稳定\r\n')
})
@ -313,6 +312,7 @@ function extractLastCdPath(text) {
const onData = () => {
// term.value.off('data', listenerInput)
term.value.onData((key) => {
if (socketConnected.value === false) return
let acsiiCode = key.codePointAt()
if (acsiiCode === 22) return handlePaste()
if (acsiiCode === 6) return searchBar.value.show()

View File

@ -481,6 +481,7 @@ const handleInputCommand = async (command) => {
height: 8px;
border-radius: 50%;
margin-right: 5px;
transition: all 0.5s;
// background-color: var(--el-color-primary);
}
}