[Desktop] Persist troubleshooting terminal when hidden (#2398)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
filtered
2025-02-03 06:29:47 +11:00
committed by GitHub
parent 4eed9c7e53
commit 5f59fbdead
11 changed files with 115 additions and 18 deletions

View 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
}
}