mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
Store shallowRef of litegraph canvas (#722)
* Store shallowRef of litegraph canvas * nit
This commit is contained in:
@@ -36,12 +36,14 @@ import {
|
|||||||
} from '@comfyorg/litegraph'
|
} from '@comfyorg/litegraph'
|
||||||
import type { RenderedTreeExplorerNode } from '@/types/treeExplorerTypes'
|
import type { RenderedTreeExplorerNode } from '@/types/treeExplorerTypes'
|
||||||
import { useNodeBookmarkStore } from '@/stores/nodeBookmarkStore'
|
import { useNodeBookmarkStore } from '@/stores/nodeBookmarkStore'
|
||||||
|
import { useCanvasStore } from '@/stores/graphStore'
|
||||||
|
|
||||||
const emit = defineEmits(['ready'])
|
const emit = defineEmits(['ready'])
|
||||||
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
const nodeDefStore = useNodeDefStore()
|
const nodeDefStore = useNodeDefStore()
|
||||||
const workspaceStore = useWorkspaceStore()
|
const workspaceStore = useWorkspaceStore()
|
||||||
|
const canvasStore = useCanvasStore()
|
||||||
|
|
||||||
const betaMenuEnabled = computed(
|
const betaMenuEnabled = computed(
|
||||||
() => settingStore.get('Comfy.UseNewMenu') !== 'Disabled'
|
() => settingStore.get('Comfy.UseNewMenu') !== 'Disabled'
|
||||||
@@ -49,33 +51,27 @@ const betaMenuEnabled = computed(
|
|||||||
const nodeSearchEnabled = computed<boolean>(
|
const nodeSearchEnabled = computed<boolean>(
|
||||||
() => settingStore.get('Comfy.NodeSearchBoxImpl') === 'default'
|
() => settingStore.get('Comfy.NodeSearchBoxImpl') === 'default'
|
||||||
)
|
)
|
||||||
watch(
|
|
||||||
nodeSearchEnabled,
|
|
||||||
(newVal) => {
|
|
||||||
LiteGraph.release_link_on_empty_shows_menu = !newVal
|
|
||||||
if (comfyApp.canvas) comfyApp.canvas.allow_searchbox = !newVal
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
)
|
|
||||||
const canvasInfoEnabled = computed<boolean>(() =>
|
|
||||||
settingStore.get('Comfy.Graph.CanvasInfo')
|
|
||||||
)
|
|
||||||
watch(
|
|
||||||
canvasInfoEnabled,
|
|
||||||
(newVal) => {
|
|
||||||
if (comfyApp.canvas) comfyApp.canvas.show_info = newVal
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
const zoomSpeed = computed(() => settingStore.get('Comfy.Graph.ZoomSpeed'))
|
watchEffect(() => {
|
||||||
watch(
|
LiteGraph.release_link_on_empty_shows_menu = !nodeSearchEnabled.value
|
||||||
zoomSpeed,
|
if (canvasStore.canvas) {
|
||||||
(newVal: number) => {
|
canvasStore.canvas.allow_searchbox = !nodeSearchEnabled.value
|
||||||
if (comfyApp.canvas) comfyApp.canvas['zoom_speed'] = newVal
|
}
|
||||||
},
|
})
|
||||||
{ immediate: true }
|
|
||||||
)
|
watchEffect(() => {
|
||||||
|
const canvasInfoEnabled = settingStore.get('Comfy.Graph.CanvasInfo')
|
||||||
|
if (canvasStore.canvas) {
|
||||||
|
canvasStore.canvas.show_info = canvasInfoEnabled
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
const zoomSpeed = settingStore.get('Comfy.Graph.ZoomSpeed')
|
||||||
|
if (canvasStore.canvas) {
|
||||||
|
canvasStore.canvas.zoom_speed = zoomSpeed
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
nodeDefStore.showDeprecated = settingStore.get('Comfy.Node.ShowDeprecated')
|
nodeDefStore.showDeprecated = settingStore.get('Comfy.Node.ShowDeprecated')
|
||||||
@@ -117,9 +113,7 @@ onMounted(async () => {
|
|||||||
|
|
||||||
workspaceStore.spinner = true
|
workspaceStore.spinner = true
|
||||||
await comfyApp.setup(canvasRef.value)
|
await comfyApp.setup(canvasRef.value)
|
||||||
comfyApp.canvas.allow_searchbox = !nodeSearchEnabled.value
|
canvasStore.canvas = comfyApp.canvas
|
||||||
comfyApp.canvas.show_info = canvasInfoEnabled.value
|
|
||||||
comfyApp.canvas['zoom_speed'] = zoomSpeed.value
|
|
||||||
workspaceStore.spinner = false
|
workspaceStore.spinner = false
|
||||||
|
|
||||||
window['app'] = comfyApp
|
window['app'] = comfyApp
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
import { LGraphNode, LGraphGroup } from '@comfyorg/litegraph'
|
import { LGraphNode, LGraphGroup, LGraphCanvas } from '@comfyorg/litegraph'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { shallowRef } from 'vue'
|
||||||
|
|
||||||
export const useTitleEditorStore = defineStore('titleEditor', () => {
|
export const useTitleEditorStore = defineStore('titleEditor', () => {
|
||||||
const titleEditorTarget = ref<LGraphNode | LGraphGroup | null>(null)
|
const titleEditorTarget = shallowRef<LGraphNode | LGraphGroup | null>(null)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
titleEditorTarget
|
titleEditorTarget
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const useCanvasStore = defineStore('canvas', () => {
|
||||||
|
const canvas = shallowRef<LGraphCanvas | null>(null)
|
||||||
|
|
||||||
|
return {
|
||||||
|
canvas
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user