mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-27 18:24:11 +00:00
App mode - store - 1 (#9022)
## Summary Adds a store to control the mode the app is in (app, graph, builder) Changes the existing linearMode in canvasStore to update new store ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9022-App-mode-store-1-30d6d73d365081498df1c1192c9860f0) by [Unito](https://www.unito.io)
This commit is contained in:
40
src/stores/appModeStore.ts
Normal file
40
src/stores/appModeStore.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { readonly, computed, ref } from 'vue'
|
||||
|
||||
type AppMode = 'graph' | 'app' | 'builder:select' | 'builder:arrange'
|
||||
|
||||
export const useAppModeStore = defineStore('appMode', () => {
|
||||
const mode = ref<AppMode>('graph')
|
||||
const builderSaving = ref(false)
|
||||
const hasOutputs = ref(true)
|
||||
|
||||
const isBuilderMode = computed(
|
||||
() => mode.value === 'builder:select' || mode.value === 'builder:arrange'
|
||||
)
|
||||
const isAppMode = computed(
|
||||
() => mode.value === 'app' || mode.value === 'builder:arrange'
|
||||
)
|
||||
const isGraphMode = computed(
|
||||
() => mode.value === 'graph' || mode.value === 'builder:select'
|
||||
)
|
||||
const isBuilderSaving = computed(
|
||||
() => builderSaving.value && isBuilderMode.value
|
||||
)
|
||||
|
||||
return {
|
||||
mode: readonly(mode),
|
||||
isBuilderMode,
|
||||
isAppMode,
|
||||
isGraphMode,
|
||||
isBuilderSaving,
|
||||
hasOutputs,
|
||||
setBuilderSaving: (newBuilderSaving: boolean) => {
|
||||
if (!isBuilderMode.value) return
|
||||
builderSaving.value = newBuilderSaving
|
||||
},
|
||||
setMode: (newMode: AppMode) => {
|
||||
if (newMode === mode.value) return
|
||||
mode.value = newMode
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user