mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
[Refactor] Terminal output drawer shared component (#2457)
This commit is contained in:
61
src/components/maintenance/TerminalOutputDrawer.vue
Normal file
61
src/components/maintenance/TerminalOutputDrawer.vue
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<template>
|
||||||
|
<Drawer
|
||||||
|
v-model:visible="terminalVisible"
|
||||||
|
:header
|
||||||
|
position="bottom"
|
||||||
|
style="height: max(50vh, 34rem)"
|
||||||
|
>
|
||||||
|
<BaseTerminal @created="terminalCreated" @unmounted="terminalUnmounted" />
|
||||||
|
</Drawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Terminal } from '@xterm/xterm'
|
||||||
|
import Drawer from 'primevue/drawer'
|
||||||
|
import { Ref, onMounted } from 'vue'
|
||||||
|
|
||||||
|
import BaseTerminal from '@/components/bottomPanel/tabs/terminal/BaseTerminal.vue'
|
||||||
|
import type { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
|
||||||
|
import { useTerminalBuffer } from '@/composables/bottomPanelTabs/useTerminalBuffer'
|
||||||
|
import { electronAPI } from '@/utils/envUtil'
|
||||||
|
|
||||||
|
// Model
|
||||||
|
const terminalVisible = defineModel<boolean>({ required: true })
|
||||||
|
const props = defineProps<{
|
||||||
|
header: string
|
||||||
|
defaultMessage: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const electron = electronAPI()
|
||||||
|
|
||||||
|
/** The actual output of all terminal commands - not rendered */
|
||||||
|
const buffer = useTerminalBuffer()
|
||||||
|
let xterm: Terminal | null = null
|
||||||
|
|
||||||
|
// Created and destroyed with the Drawer - contents copied from hidden buffer
|
||||||
|
const terminalCreated = (
|
||||||
|
{ terminal, useAutoSize }: ReturnType<typeof useTerminal>,
|
||||||
|
root: Ref<HTMLElement>
|
||||||
|
) => {
|
||||||
|
xterm = terminal
|
||||||
|
useAutoSize({ root, autoRows: true, autoCols: true })
|
||||||
|
terminal.write(props.defaultMessage)
|
||||||
|
buffer.copyTo(terminal)
|
||||||
|
|
||||||
|
terminal.options.cursorBlink = false
|
||||||
|
terminal.options.cursorStyle = 'bar'
|
||||||
|
terminal.options.cursorInactiveStyle = 'bar'
|
||||||
|
terminal.options.disableStdin = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const terminalUnmounted = () => {
|
||||||
|
xterm = null
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
electron.onLogMessage((message: string) => {
|
||||||
|
buffer.write(message)
|
||||||
|
xterm?.write(message)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -26,17 +26,11 @@
|
|||||||
@click="toggleConsoleDrawer"
|
@click="toggleConsoleDrawer"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Drawer
|
<TerminalOutputDrawer
|
||||||
v-model:visible="terminalVisible"
|
v-model="terminalVisible"
|
||||||
:header="t('g.terminal')"
|
:header="t('g.terminal')"
|
||||||
position="bottom"
|
:default-message="t('desktopUpdate.terminalDefaultMessage')"
|
||||||
style="height: max(50vh, 34rem)"
|
/>
|
||||||
>
|
|
||||||
<BaseTerminal
|
|
||||||
@created="terminalCreated"
|
|
||||||
@unmounted="terminalUnmounted"
|
|
||||||
/>
|
|
||||||
</Drawer>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Toast />
|
<Toast />
|
||||||
@@ -44,16 +38,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Terminal } from '@xterm/xterm'
|
|
||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
import Drawer from 'primevue/drawer'
|
|
||||||
import ProgressSpinner from 'primevue/progressspinner'
|
import ProgressSpinner from 'primevue/progressspinner'
|
||||||
import Toast from 'primevue/toast'
|
import Toast from 'primevue/toast'
|
||||||
import { Ref, onMounted, onUnmounted, ref } from 'vue'
|
import { onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
import BaseTerminal from '@/components/bottomPanel/tabs/terminal/BaseTerminal.vue'
|
import TerminalOutputDrawer from '@/components/maintenance/TerminalOutputDrawer.vue'
|
||||||
import type { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
|
|
||||||
import { useTerminalBuffer } from '@/composables/bottomPanelTabs/useTerminalBuffer'
|
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
import { electronAPI } from '@/utils/envUtil'
|
import { electronAPI } from '@/utils/envUtil'
|
||||||
|
|
||||||
@@ -63,41 +53,10 @@ const electron = electronAPI()
|
|||||||
|
|
||||||
const terminalVisible = ref(false)
|
const terminalVisible = ref(false)
|
||||||
|
|
||||||
/** The actual output of all terminal commands - not rendered */
|
|
||||||
const buffer = useTerminalBuffer()
|
|
||||||
let xterm: Terminal | null = null
|
|
||||||
|
|
||||||
// Created and destroyed with the Drawer - contents copied from hidden buffer
|
|
||||||
const terminalCreated = (
|
|
||||||
{ terminal, useAutoSize }: ReturnType<typeof useTerminal>,
|
|
||||||
root: Ref<HTMLElement>
|
|
||||||
) => {
|
|
||||||
xterm = terminal
|
|
||||||
useAutoSize({ root, autoRows: true, autoCols: true })
|
|
||||||
terminal.write(t('desktopUpdate.terminalDefaultMessage'))
|
|
||||||
buffer.copyTo(terminal)
|
|
||||||
|
|
||||||
terminal.options.cursorBlink = false
|
|
||||||
terminal.options.cursorStyle = 'bar'
|
|
||||||
terminal.options.cursorInactiveStyle = 'bar'
|
|
||||||
terminal.options.disableStdin = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const terminalUnmounted = () => {
|
|
||||||
xterm = null
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleConsoleDrawer = () => {
|
const toggleConsoleDrawer = () => {
|
||||||
terminalVisible.value = !terminalVisible.value
|
terminalVisible.value = !terminalVisible.value
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
electron.onLogMessage((message: string) => {
|
|
||||||
buffer.write(message)
|
|
||||||
xterm?.write(message)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
onUnmounted(() => electron.Validation.dispose())
|
onUnmounted(() => electron.Validation.dispose())
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -73,17 +73,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Drawer
|
<TerminalOutputDrawer
|
||||||
v-model:visible="terminalVisible"
|
v-model="terminalVisible"
|
||||||
:header="t('g.terminal')"
|
:header="t('g.terminal')"
|
||||||
position="bottom"
|
:default-message="t('maintenance.terminalDefaultMessage')"
|
||||||
style="height: max(50vh, 34rem)"
|
/>
|
||||||
>
|
|
||||||
<BaseTerminal
|
|
||||||
@created="terminalCreated"
|
|
||||||
@unmounted="terminalUnmounted"
|
|
||||||
/>
|
|
||||||
</Drawer>
|
|
||||||
<Toast />
|
<Toast />
|
||||||
</div>
|
</div>
|
||||||
</BaseViewTemplate>
|
</BaseViewTemplate>
|
||||||
@@ -91,21 +85,17 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PrimeIcons } from '@primevue/core/api'
|
import { PrimeIcons } from '@primevue/core/api'
|
||||||
import { Terminal } from '@xterm/xterm'
|
|
||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
import Drawer from 'primevue/drawer'
|
|
||||||
import SelectButton from 'primevue/selectbutton'
|
import SelectButton from 'primevue/selectbutton'
|
||||||
import Toast from 'primevue/toast'
|
import Toast from 'primevue/toast'
|
||||||
import { useToast } from 'primevue/usetoast'
|
import { useToast } from 'primevue/usetoast'
|
||||||
import { Ref, computed, onMounted, onUnmounted, ref } from 'vue'
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||||
import { watch } from 'vue'
|
import { watch } from 'vue'
|
||||||
|
|
||||||
import BaseTerminal from '@/components/bottomPanel/tabs/terminal/BaseTerminal.vue'
|
|
||||||
import RefreshButton from '@/components/common/RefreshButton.vue'
|
import RefreshButton from '@/components/common/RefreshButton.vue'
|
||||||
import StatusTag from '@/components/maintenance/StatusTag.vue'
|
import StatusTag from '@/components/maintenance/StatusTag.vue'
|
||||||
import TaskListPanel from '@/components/maintenance/TaskListPanel.vue'
|
import TaskListPanel from '@/components/maintenance/TaskListPanel.vue'
|
||||||
import type { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
|
import TerminalOutputDrawer from '@/components/maintenance/TerminalOutputDrawer.vue'
|
||||||
import { useTerminalBuffer } from '@/composables/bottomPanelTabs/useTerminalBuffer'
|
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
import { useMaintenanceTaskStore } from '@/stores/maintenanceTaskStore'
|
import { useMaintenanceTaskStore } from '@/stores/maintenanceTaskStore'
|
||||||
import { MaintenanceFilter } from '@/types/desktop/maintenanceTypes'
|
import { MaintenanceFilter } from '@/types/desktop/maintenanceTypes'
|
||||||
@@ -147,10 +137,6 @@ const filterOptions = ref([
|
|||||||
/** Filter binding; can be set to show all tasks, or only errors. */
|
/** Filter binding; can be set to show all tasks, or only errors. */
|
||||||
const filter = ref<MaintenanceFilter>(filterOptions.value[1])
|
const filter = ref<MaintenanceFilter>(filterOptions.value[1])
|
||||||
|
|
||||||
/** The actual output of all terminal commands - not rendered */
|
|
||||||
const buffer = useTerminalBuffer()
|
|
||||||
let xterm: Terminal | null = null
|
|
||||||
|
|
||||||
/** If valid, leave the validation window. */
|
/** If valid, leave the validation window. */
|
||||||
const completeValidation = async (alertOnFail = true) => {
|
const completeValidation = async (alertOnFail = true) => {
|
||||||
const isValid = await electron.Validation.complete()
|
const isValid = await electron.Validation.complete()
|
||||||
@@ -164,26 +150,6 @@ const completeValidation = async (alertOnFail = true) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Created and destroyed with the Drawer - contents copied from hidden buffer
|
|
||||||
const terminalCreated = (
|
|
||||||
{ terminal, useAutoSize }: ReturnType<typeof useTerminal>,
|
|
||||||
root: Ref<HTMLElement>
|
|
||||||
) => {
|
|
||||||
xterm = terminal
|
|
||||||
useAutoSize({ root, autoRows: true, autoCols: true })
|
|
||||||
terminal.write(t('maintenance.terminalDefaultMessage'))
|
|
||||||
buffer.copyTo(terminal)
|
|
||||||
|
|
||||||
terminal.options.cursorBlink = false
|
|
||||||
terminal.options.cursorStyle = 'bar'
|
|
||||||
terminal.options.cursorInactiveStyle = 'bar'
|
|
||||||
terminal.options.disableStdin = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const terminalUnmounted = () => {
|
|
||||||
xterm = null
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleConsoleDrawer = () => {
|
const toggleConsoleDrawer = () => {
|
||||||
terminalVisible.value = !terminalVisible.value
|
terminalVisible.value = !terminalVisible.value
|
||||||
}
|
}
|
||||||
@@ -207,11 +173,6 @@ watch(
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
electron.Validation.onUpdate(processUpdate)
|
electron.Validation.onUpdate(processUpdate)
|
||||||
|
|
||||||
electron.onLogMessage((message: string) => {
|
|
||||||
buffer.write(message)
|
|
||||||
xterm?.write(message)
|
|
||||||
})
|
|
||||||
|
|
||||||
const update = await electron.Validation.getStatus()
|
const update = await electron.Validation.getStatus()
|
||||||
processUpdate(update)
|
processUpdate(update)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user