mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-10 10:00:08 +00:00
## Summary Extracts desktop UI into apps/desktop-ui package with minimal changes. ## Changes - **What**: - Separates desktop-specific code into standalone package with independent Vite config, router, and i18n - Drastically simplifies the main app router by removing all desktop routes - Adds a some code duplication, most due to the existing design - Some duplication can be refactored to be *simpler* on either side - no need to split things by `isElectron()` - Rudimentary storybook support has been added - **Breaking**: Stacked PR for publishing must be merged before this PR makes it to stable core (but publishing _could_ be done manually) - #5915 - **Dependencies**: Takes full advantage of pnpm catalog. No additional dependencies added. ## Review Focus - Should be no changes to normal frontend operation - Scripts added to root package.json are acceptable - The duplication in this PR is copied as is, wherever possible. Any corrections or fix-ups beyond the scope of simply migrating the functionality as-is, can be addressed in later PRs. That said, if any changes are made, it instantly becomes more difficult to separate the duplicated code out into a shared utility. - Tracking issue to address concerns: #5925 ### i18n Fixing i18n is out of scope for this PR. It is a larger task that we should consider carefully and implement properly. Attempting to isolate the desktop i18n and duplicate the _current_ localisation scripts would be wasted energy.
63 lines
1.7 KiB
Vue
63 lines
1.7 KiB
Vue
<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 type { Terminal } from '@xterm/xterm'
|
|
import Drawer from 'primevue/drawer'
|
|
import type { Ref } from 'vue'
|
|
import { 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 | undefined>
|
|
) => {
|
|
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>
|