mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-25 09:14:25 +00:00
[Desktop] Persist troubleshooting terminal when hidden (#2398)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
30
src/hooks/bottomPanelTabs/useTerminalBuffer.ts
Normal file
30
src/hooks/bottomPanelTabs/useTerminalBuffer.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { SerializeAddon } from '@xterm/addon-serialize'
|
||||
import { Terminal } from '@xterm/xterm'
|
||||
import { markRaw, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
export function useTerminalBuffer() {
|
||||
const serializeAddon = new SerializeAddon()
|
||||
const terminal = markRaw(new Terminal({ convertEol: true }))
|
||||
|
||||
const copyTo = (destinationTerminal: Terminal) => {
|
||||
destinationTerminal.write(serializeAddon.serialize())
|
||||
}
|
||||
|
||||
const write = (message: string) => terminal.write(message)
|
||||
|
||||
const serialize = () => serializeAddon.serialize()
|
||||
|
||||
onMounted(() => {
|
||||
terminal.loadAddon(serializeAddon)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
terminal.dispose()
|
||||
})
|
||||
|
||||
return {
|
||||
copyTo,
|
||||
serialize,
|
||||
write
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user