✨ 优化终端socket断开后逻辑
This commit is contained in:
parent
fb36c5ddc4
commit
e0b12a98e8
@ -59,10 +59,7 @@ const fitAddon = ref(null)
|
|||||||
const searchBar = ref(null)
|
const searchBar = ref(null)
|
||||||
const hasRegisterEvent = ref(false)
|
const hasRegisterEvent = ref(false)
|
||||||
|
|
||||||
// const isConnectSuccess = ref(false)
|
const socketConnected = ref(false)
|
||||||
// const isConnectFail = ref(false)
|
|
||||||
// const isConnecting = ref(true)
|
|
||||||
// const isReConnect = ref(false)
|
|
||||||
const curStatus = ref(CONNECTING)
|
const curStatus = ref(CONNECTING)
|
||||||
const terminal = ref(null)
|
const terminal = ref(null)
|
||||||
const terminalRef = ref(null)
|
const terminalRef = ref(null)
|
||||||
@ -121,6 +118,7 @@ const connectIO = () => {
|
|||||||
})
|
})
|
||||||
socket.value.on('connect', () => {
|
socket.value.on('connect', () => {
|
||||||
console.log('/terminal socket已连接:', host.value)
|
console.log('/terminal socket已连接:', host.value)
|
||||||
|
socketConnected.value = true
|
||||||
socket.value.emit('create', { host: host.value, token: token.value })
|
socket.value.emit('create', { host: host.value, token: token.value })
|
||||||
socket.value.on('connect_terminal_success', () => {
|
socket.value.on('connect_terminal_success', () => {
|
||||||
if (hasRegisterEvent.value) return // 以下事件连接成功后仅可注册一次, 否则会多次触发. 除非socket重连
|
if (hasRegisterEvent.value) return // 以下事件连接成功后仅可注册一次, 否则会多次触发. 除非socket重连
|
||||||
@ -180,6 +178,7 @@ const connectIO = () => {
|
|||||||
socket.value.removeAllListeners() // 取消所有监听
|
socket.value.removeAllListeners() // 取消所有监听
|
||||||
// socket.value.off('output') // 取消output监听,取消onData输入监听,重新注册
|
// socket.value.off('output') // 取消output监听,取消onData输入监听,重新注册
|
||||||
curStatus.value = CONNECT_FAIL
|
curStatus.value = CONNECT_FAIL
|
||||||
|
socketConnected.value = false
|
||||||
term.value.write('\r\nError: 与面板socket连接断开。请关闭此tab,并检查本地与面板连接是否稳定\r\n')
|
term.value.write('\r\nError: 与面板socket连接断开。请关闭此tab,并检查本地与面板连接是否稳定\r\n')
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -313,6 +312,7 @@ function extractLastCdPath(text) {
|
|||||||
const onData = () => {
|
const onData = () => {
|
||||||
// term.value.off('data', listenerInput)
|
// term.value.off('data', listenerInput)
|
||||||
term.value.onData((key) => {
|
term.value.onData((key) => {
|
||||||
|
if (socketConnected.value === false) return
|
||||||
let acsiiCode = key.codePointAt()
|
let acsiiCode = key.codePointAt()
|
||||||
if (acsiiCode === 22) return handlePaste()
|
if (acsiiCode === 22) return handlePaste()
|
||||||
if (acsiiCode === 6) return searchBar.value.show()
|
if (acsiiCode === 6) return searchBar.value.show()
|
||||||
|
@ -481,6 +481,7 @@ const handleInputCommand = async (command) => {
|
|||||||
height: 8px;
|
height: 8px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
transition: all 0.5s;
|
||||||
// background-color: var(--el-color-primary);
|
// background-color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user