Skip to content

Commit 3c0b227

Browse files
DrJKLampcode-com
andcommitted
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>
1 parent 0a73c5a commit 3c0b227

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

src/App.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
<script setup lang="ts">
1212
import { captureException } from '@sentry/vue'
13-
import { useEventListener } from '@vueuse/core'
1413
import BlockUI from 'primevue/blockui'
1514
import ProgressSpinner from 'primevue/progressspinner'
1615
import { computed, onMounted } from 'vue'
@@ -21,15 +20,13 @@ import { useWorkspaceStore } from '@/stores/workspaceStore'
2120
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
2221
2322
import { electronAPI, isElectron } from './utils/envUtil'
23+
import { app } from '@/scripts/app'
2424
2525
const workspaceStore = useWorkspaceStore()
26+
app.extensionManager = useWorkspaceStore()
27+
2628
const conflictDetection = useConflictDetection()
2729
const isLoading = computed<boolean>(() => workspaceStore.spinner)
28-
const handleKey = (e: KeyboardEvent) => {
29-
workspaceStore.shiftDown = e.shiftKey
30-
}
31-
useEventListener(window, 'keydown', handleKey)
32-
useEventListener(window, 'keyup', handleKey)
3330
3431
const showContextMenu = (event: MouseEvent) => {
3532
const { target } = event

src/stores/workspaceStore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useMagicKeys } from '@vueuse/core'
12
import { defineStore } from 'pinia'
23
import { computed, ref } from 'vue'
34

@@ -18,7 +19,7 @@ import { useSidebarTabStore } from './workspace/sidebarTabStore'
1819

1920
export const useWorkspaceStore = defineStore('workspace', () => {
2021
const spinner = ref(false)
21-
const shiftDown = ref(false)
22+
const { shift: shiftDown } = useMagicKeys()
2223
/**
2324
* Whether the workspace is in focus mode.
2425
* When in focus mode, only the graph editor is visible.

src/views/GraphView.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ import { useServerConfigStore } from '@/stores/serverConfigStore'
7979
import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
8080
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
8181
import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore'
82-
import { useWorkspaceStore } from '@/stores/workspaceStore'
8382
import { electronAPI, isElectron } from '@/utils/envUtil'
8483
import LinearView from '@/views/LinearView.vue'
8584
import ManagerProgressToast from '@/workbench/extensions/manager/components/ManagerProgressToast.vue'
@@ -195,15 +194,12 @@ watchEffect(() => {
195194
queueStore.maxHistoryItems = settingStore.get('Comfy.Queue.MaxHistoryItems')
196195
})
197196
198-
const init = () => {
199-
const coreCommands = useCoreCommands()
200-
useCommandStore().registerCommands(coreCommands)
201-
useMenuItemStore().registerCoreMenuCommands()
202-
useKeybindingService().registerCoreKeybindings()
203-
useSidebarTabStore().registerCoreSidebarTabs()
204-
useBottomPanelStore().registerCoreBottomPanelTabs()
205-
app.extensionManager = useWorkspaceStore()
206-
}
197+
const coreCommands = useCoreCommands()
198+
useCommandStore().registerCommands(coreCommands)
199+
useMenuItemStore().registerCoreMenuCommands()
200+
useKeybindingService().registerCoreKeybindings()
201+
useSidebarTabStore().registerCoreSidebarTabs()
202+
useBottomPanelStore().registerCoreBottomPanelTabs()
207203
208204
const queuePendingTaskCountStore = useQueuePendingTaskCountStore()
209205
const sidebarTabStore = useSidebarTabStore()
@@ -280,7 +276,6 @@ onMounted(() => {
280276
executionStore.bindExecutionEvents()
281277
282278
try {
283-
init()
284279
// Relocate the legacy menu container to the graph canvas container so it is below other elements
285280
graphCanvasContainerRef.value?.prepend(app.ui.menuContainer)
286281
} catch (e) {

0 commit comments

Comments
 (0)