mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-27 09:45:13 +00:00
Store spinner state in workspace state store (#256)
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<ProgressSpinner v-if="isLoading" class="spinner"></ProgressSpinner>
|
<ProgressSpinner v-if="isLoading" class="spinner"></ProgressSpinner>
|
||||||
<GraphCanvas v-else />
|
<GraphCanvas />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, markRaw, onMounted, ref, watch } from 'vue'
|
import { computed, markRaw, onMounted, watch } from 'vue'
|
||||||
import GraphCanvas from '@/components/graph/GraphCanvas.vue'
|
import GraphCanvas from '@/components/graph/GraphCanvas.vue'
|
||||||
import QueueSideBarTab from '@/components/sidebar/tabs/QueueSideBarTab.vue'
|
import QueueSideBarTab from '@/components/sidebar/tabs/QueueSideBarTab.vue'
|
||||||
import ProgressSpinner from 'primevue/progressspinner'
|
import ProgressSpinner from 'primevue/progressspinner'
|
||||||
@@ -14,7 +14,7 @@ import { useI18n } from 'vue-i18n'
|
|||||||
import { useWorkspaceStore } from './stores/workspaceStateStore'
|
import { useWorkspaceStore } from './stores/workspaceStateStore'
|
||||||
import NodeLibrarySideBarTab from './components/sidebar/tabs/NodeLibrarySideBarTab.vue'
|
import NodeLibrarySideBarTab from './components/sidebar/tabs/NodeLibrarySideBarTab.vue'
|
||||||
|
|
||||||
const isLoading = ref(true)
|
const isLoading = computed<boolean>(() => useWorkspaceStore().spinner)
|
||||||
const theme = computed<string>(() =>
|
const theme = computed<string>(() =>
|
||||||
useSettingStore().get('Comfy.ColorPalette')
|
useSettingStore().get('Comfy.ColorPalette')
|
||||||
)
|
)
|
||||||
@@ -59,8 +59,6 @@ onMounted(() => {
|
|||||||
init()
|
init()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to init Vue app', e)
|
console.error('Failed to init Vue app', e)
|
||||||
} finally {
|
|
||||||
isLoading.value = false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -19,22 +19,29 @@ import { app as comfyApp } from '@/scripts/app'
|
|||||||
import { useSettingStore } from '@/stores/settingStore'
|
import { useSettingStore } from '@/stores/settingStore'
|
||||||
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'
|
||||||
import { useNodeDefStore } from '@/stores/nodeDefStore'
|
import { useNodeDefStore } from '@/stores/nodeDefStore'
|
||||||
|
import { useWorkspaceStore } from '@/stores/workspaceStateStore'
|
||||||
|
|
||||||
const emit = defineEmits(['ready'])
|
const emit = defineEmits(['ready'])
|
||||||
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
||||||
|
const settingStore = useSettingStore()
|
||||||
|
const workspaceStore = useWorkspaceStore()
|
||||||
|
|
||||||
const betaMenuEnabled = computed(
|
const betaMenuEnabled = computed(
|
||||||
() => useSettingStore().get('Comfy.UseNewMenu') !== 'Disabled'
|
() => settingStore.get('Comfy.UseNewMenu') !== 'Disabled'
|
||||||
)
|
)
|
||||||
const nodeSearchEnabled = computed<boolean>(
|
const nodeSearchEnabled = computed<boolean>(
|
||||||
() => useSettingStore().get('Comfy.NodeSearchBoxImpl') === 'default'
|
() => settingStore.get('Comfy.NodeSearchBoxImpl') === 'default'
|
||||||
)
|
)
|
||||||
|
|
||||||
let dropTargetCleanup = () => {}
|
let dropTargetCleanup = () => {}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
comfyApp.vueAppReady = true
|
comfyApp.vueAppReady = true
|
||||||
|
|
||||||
|
workspaceStore.spinner = true
|
||||||
await comfyApp.setup(canvasRef.value)
|
await comfyApp.setup(canvasRef.value)
|
||||||
|
workspaceStore.spinner = false
|
||||||
|
|
||||||
window['app'] = comfyApp
|
window['app'] = comfyApp
|
||||||
window['graph'] = comfyApp.graph
|
window['graph'] = comfyApp.graph
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import { SidebarTabExtension } from '@/types/extensionTypes'
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
interface WorkspaceState {
|
interface WorkspaceState {
|
||||||
|
spinner: boolean
|
||||||
activeSidebarTab: string | null
|
activeSidebarTab: string | null
|
||||||
sidebarTabs: SidebarTabExtension[]
|
sidebarTabs: SidebarTabExtension[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useWorkspaceStore = defineStore('workspace', {
|
export const useWorkspaceStore = defineStore('workspace', {
|
||||||
state: (): WorkspaceState => ({
|
state: (): WorkspaceState => ({
|
||||||
|
spinner: false,
|
||||||
activeSidebarTab: null,
|
activeSidebarTab: null,
|
||||||
sidebarTabs: []
|
sidebarTabs: []
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user