mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 15:40:10 +00:00
## Summary Refactors bootstrap and lifecycle management to parallelize initialization, use Vue best practices, and fix a logout state bug. ## Changes ### Bootstrap Store (`bootstrapStore.ts`) - Extract early bootstrap logic into a dedicated store using `useAsyncState` - Parallelize settings, i18n, and workflow sync loading (previously sequential) - Handle multi-user login scenarios by deferring settings/workflows until authenticated ### GraphCanvas Refactoring - Move non-DOM composables (`useGlobalLitegraph`, `useCopy`, `usePaste`, etc.) to script setup level for earlier initialization - Move `watch` and `whenever` declarations outside `onMounted` (Vue best practice) - Use `until()` from VueUse to await bootstrap store readiness instead of direct async calls ### GraphView Simplification - Replace manual `addEventListener`/`removeEventListener` with `useEventListener` - Replace `setInterval` with `useIntervalFn` for automatic cleanup - Move core command registration to script setup level ### Bug Fix Using `router.push()` for logout caused `isSettingsReady` to persist as `true`, making new users inherit the previous user's cached settings. Reverted to `window.location.reload()` with TODOs for future store reset implementation. ## Testing - Verified login/logout cycle clears settings correctly - Verified bootstrap sequence completes without errors --------- Co-authored-by: Amp <amp@ampcode.com>
66 lines
2.0 KiB
Vue
66 lines
2.0 KiB
Vue
<template>
|
|
<router-view />
|
|
<ProgressSpinner
|
|
v-if="isLoading"
|
|
class="absolute inset-0 flex h-[unset] items-center justify-center"
|
|
/>
|
|
<GlobalDialog />
|
|
<BlockUI full-screen :blocked="isLoading" />
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { captureException } from '@sentry/vue'
|
|
import BlockUI from 'primevue/blockui'
|
|
import ProgressSpinner from 'primevue/progressspinner'
|
|
import { computed, onMounted } from 'vue'
|
|
|
|
import GlobalDialog from '@/components/dialog/GlobalDialog.vue'
|
|
import config from '@/config'
|
|
import { useWorkspaceStore } from '@/stores/workspaceStore'
|
|
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
|
|
|
|
import { electronAPI, isElectron } from './utils/envUtil'
|
|
import { app } from '@/scripts/app'
|
|
|
|
const workspaceStore = useWorkspaceStore()
|
|
app.extensionManager = useWorkspaceStore()
|
|
|
|
const conflictDetection = useConflictDetection()
|
|
const isLoading = computed<boolean>(() => workspaceStore.spinner)
|
|
|
|
const showContextMenu = (event: MouseEvent) => {
|
|
const { target } = event
|
|
switch (true) {
|
|
case target instanceof HTMLTextAreaElement:
|
|
case target instanceof HTMLInputElement && target.type === 'text':
|
|
// TODO: Context input menu explicitly for text input
|
|
electronAPI()?.showContextMenu({ type: 'text' })
|
|
return
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
window['__COMFYUI_FRONTEND_VERSION__'] = config.app_version
|
|
|
|
if (isElectron()) {
|
|
document.addEventListener('contextmenu', showContextMenu)
|
|
}
|
|
|
|
window.addEventListener('vite:preloadError', (event) => {
|
|
event.preventDefault()
|
|
// eslint-disable-next-line no-undef
|
|
if (__DISTRIBUTION__ === 'cloud') {
|
|
captureException(event.payload, {
|
|
tags: { error_type: 'vite_preload_error' }
|
|
})
|
|
} else {
|
|
console.error('[vite:preloadError]', event.payload)
|
|
}
|
|
})
|
|
|
|
// Initialize conflict detection in background
|
|
// This runs async and doesn't block UI setup
|
|
void conflictDetection.initializeConflictDetection()
|
|
})
|
|
</script>
|