mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
refactor: consolidate workspace spinner and shiftDown state
- Replace manual keydown/keyup listeners with useMagicKeys for shiftDown - Move app.extensionManager assignment to App.vue - Remove init() wrapper function in GraphView.vue Amp-Thread-ID: https://ampcode.com/threads/T-019bf90e-1cd0-71de-b23f-ea6cb0f99a87 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { captureException } from '@sentry/vue'
|
import { captureException } from '@sentry/vue'
|
||||||
import { useEventListener } from '@vueuse/core'
|
|
||||||
import BlockUI from 'primevue/blockui'
|
import BlockUI from 'primevue/blockui'
|
||||||
import ProgressSpinner from 'primevue/progressspinner'
|
import ProgressSpinner from 'primevue/progressspinner'
|
||||||
import { computed, onMounted } from 'vue'
|
import { computed, onMounted } from 'vue'
|
||||||
@@ -21,15 +20,13 @@ import { useWorkspaceStore } from '@/stores/workspaceStore'
|
|||||||
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
|
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
|
||||||
|
|
||||||
import { electronAPI, isElectron } from './utils/envUtil'
|
import { electronAPI, isElectron } from './utils/envUtil'
|
||||||
|
import { app } from '@/scripts/app'
|
||||||
|
|
||||||
const workspaceStore = useWorkspaceStore()
|
const workspaceStore = useWorkspaceStore()
|
||||||
|
app.extensionManager = useWorkspaceStore()
|
||||||
|
|
||||||
const conflictDetection = useConflictDetection()
|
const conflictDetection = useConflictDetection()
|
||||||
const isLoading = computed<boolean>(() => workspaceStore.spinner)
|
const isLoading = computed<boolean>(() => workspaceStore.spinner)
|
||||||
const handleKey = (e: KeyboardEvent) => {
|
|
||||||
workspaceStore.shiftDown = e.shiftKey
|
|
||||||
}
|
|
||||||
useEventListener(window, 'keydown', handleKey)
|
|
||||||
useEventListener(window, 'keyup', handleKey)
|
|
||||||
|
|
||||||
const showContextMenu = (event: MouseEvent) => {
|
const showContextMenu = (event: MouseEvent) => {
|
||||||
const { target } = event
|
const { target } = event
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useMagicKeys } from '@vueuse/core'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ import { useSidebarTabStore } from './workspace/sidebarTabStore'
|
|||||||
|
|
||||||
export const useWorkspaceStore = defineStore('workspace', () => {
|
export const useWorkspaceStore = defineStore('workspace', () => {
|
||||||
const spinner = ref(false)
|
const spinner = ref(false)
|
||||||
const shiftDown = ref(false)
|
const { shift: shiftDown } = useMagicKeys()
|
||||||
/**
|
/**
|
||||||
* Whether the workspace is in focus mode.
|
* Whether the workspace is in focus mode.
|
||||||
* When in focus mode, only the graph editor is visible.
|
* When in focus mode, only the graph editor is visible.
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ import { useServerConfigStore } from '@/stores/serverConfigStore'
|
|||||||
import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
|
import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
|
||||||
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
|
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
|
||||||
import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore'
|
import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore'
|
||||||
import { useWorkspaceStore } from '@/stores/workspaceStore'
|
|
||||||
import { electronAPI, isElectron } from '@/utils/envUtil'
|
import { electronAPI, isElectron } from '@/utils/envUtil'
|
||||||
import LinearView from '@/views/LinearView.vue'
|
import LinearView from '@/views/LinearView.vue'
|
||||||
import ManagerProgressToast from '@/workbench/extensions/manager/components/ManagerProgressToast.vue'
|
import ManagerProgressToast from '@/workbench/extensions/manager/components/ManagerProgressToast.vue'
|
||||||
@@ -195,15 +194,12 @@ watchEffect(() => {
|
|||||||
queueStore.maxHistoryItems = settingStore.get('Comfy.Queue.MaxHistoryItems')
|
queueStore.maxHistoryItems = settingStore.get('Comfy.Queue.MaxHistoryItems')
|
||||||
})
|
})
|
||||||
|
|
||||||
const init = () => {
|
const coreCommands = useCoreCommands()
|
||||||
const coreCommands = useCoreCommands()
|
useCommandStore().registerCommands(coreCommands)
|
||||||
useCommandStore().registerCommands(coreCommands)
|
useMenuItemStore().registerCoreMenuCommands()
|
||||||
useMenuItemStore().registerCoreMenuCommands()
|
useKeybindingService().registerCoreKeybindings()
|
||||||
useKeybindingService().registerCoreKeybindings()
|
useSidebarTabStore().registerCoreSidebarTabs()
|
||||||
useSidebarTabStore().registerCoreSidebarTabs()
|
useBottomPanelStore().registerCoreBottomPanelTabs()
|
||||||
useBottomPanelStore().registerCoreBottomPanelTabs()
|
|
||||||
app.extensionManager = useWorkspaceStore()
|
|
||||||
}
|
|
||||||
|
|
||||||
const queuePendingTaskCountStore = useQueuePendingTaskCountStore()
|
const queuePendingTaskCountStore = useQueuePendingTaskCountStore()
|
||||||
const sidebarTabStore = useSidebarTabStore()
|
const sidebarTabStore = useSidebarTabStore()
|
||||||
@@ -280,7 +276,6 @@ onMounted(() => {
|
|||||||
executionStore.bindExecutionEvents()
|
executionStore.bindExecutionEvents()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
init()
|
|
||||||
// Relocate the legacy menu container to the graph canvas container so it is below other elements
|
// Relocate the legacy menu container to the graph canvas container so it is below other elements
|
||||||
graphCanvasContainerRef.value?.prepend(app.ui.menuContainer)
|
graphCanvasContainerRef.value?.prepend(app.ui.menuContainer)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user