mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 11:30:13 +08:00
refactor: centralize all variable to sessionManager
This commit is contained in:
1 parent
5a7c4da628
commit
9c3c6adb16
6 files changed
+56
-39
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import { Terminal } from 'xterm'
|
||||
import { FitAddon } from 'xterm-addon-fit'
|
||||
import socket from './socket'
|
||||
import 'xterm/css/xterm.css'
|
||||
|
||||
class SocketTerminal {
|
||||
@@ -24,13 +23,14 @@ class SocketTerminal {
|
||||
this.fitAddon = new FitAddon()
|
||||
this.term.loadAddon(this.fitAddon)
|
||||
this.fitAddon.fit()
|
||||
this.socket = socket
|
||||
this.socket.on('terminal', (message) => {
|
||||
this.term.write(message)
|
||||
})
|
||||
this.term.onData((key) => {
|
||||
this.socket.emit('terminal', key)
|
||||
})
|
||||
}
|
||||
|
||||
write(message) {
|
||||
this.term.write(message)
|
||||
}
|
||||
|
||||
onData(callback) {
|
||||
this.term.onData(callback)
|
||||
}
|
||||
|
||||
resizeScreen() {
|
||||
@@ -48,4 +48,4 @@ class SocketTerminal {
|
||||
}
|
||||
}
|
||||
|
||||
export default new SocketTerminal(40, 100)
|
||||
export default SocketTerminal
|
||||
Reference in new issue
Block a user