mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
[refactor] Refactor minimap initialization logic (#5052)
* move ref initialization to the component * remove redundant init
This commit is contained in:
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
<MiniMap
|
<MiniMap
|
||||||
v-if="comfyAppReady && minimapEnabled"
|
v-if="comfyAppReady && minimapEnabled"
|
||||||
ref="minimapRef"
|
|
||||||
class="pointer-events-auto"
|
class="pointer-events-auto"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -71,7 +70,6 @@ import { useContextMenuTranslation } from '@/composables/useContextMenuTranslati
|
|||||||
import { useCopy } from '@/composables/useCopy'
|
import { useCopy } from '@/composables/useCopy'
|
||||||
import { useGlobalLitegraph } from '@/composables/useGlobalLitegraph'
|
import { useGlobalLitegraph } from '@/composables/useGlobalLitegraph'
|
||||||
import { useLitegraphSettings } from '@/composables/useLitegraphSettings'
|
import { useLitegraphSettings } from '@/composables/useLitegraphSettings'
|
||||||
import { useMinimap } from '@/composables/useMinimap'
|
|
||||||
import { usePaste } from '@/composables/usePaste'
|
import { usePaste } from '@/composables/usePaste'
|
||||||
import { useWorkflowAutoSave } from '@/composables/useWorkflowAutoSave'
|
import { useWorkflowAutoSave } from '@/composables/useWorkflowAutoSave'
|
||||||
import { useWorkflowPersistence } from '@/composables/useWorkflowPersistence'
|
import { useWorkflowPersistence } from '@/composables/useWorkflowPersistence'
|
||||||
@@ -119,9 +117,7 @@ const selectionToolboxEnabled = computed(() =>
|
|||||||
settingStore.get('Comfy.Canvas.SelectionToolbox')
|
settingStore.get('Comfy.Canvas.SelectionToolbox')
|
||||||
)
|
)
|
||||||
|
|
||||||
const minimapRef = ref<InstanceType<typeof MiniMap>>()
|
|
||||||
const minimapEnabled = computed(() => settingStore.get('Comfy.Minimap.Visible'))
|
const minimapEnabled = computed(() => settingStore.get('Comfy.Minimap.Visible'))
|
||||||
const minimap = useMinimap()
|
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
nodeDefStore.showDeprecated = settingStore.get('Comfy.Node.ShowDeprecated')
|
nodeDefStore.showDeprecated = settingStore.get('Comfy.Node.ShowDeprecated')
|
||||||
@@ -358,13 +354,6 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
whenever(
|
|
||||||
() => minimapRef.value,
|
|
||||||
(ref) => {
|
|
||||||
minimap.setMinimapRef(ref)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
whenever(
|
whenever(
|
||||||
() => useCanvasStore().canvas,
|
() => useCanvasStore().canvas,
|
||||||
(canvas) => {
|
(canvas) => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
v-if="visible && initialized"
|
v-if="visible && initialized"
|
||||||
|
ref="minimapRef"
|
||||||
class="minimap-main-container flex absolute bottom-[20px] right-[90px] z-[1000]"
|
class="minimap-main-container flex absolute bottom-[20px] right-[90px] z-[1000]"
|
||||||
>
|
>
|
||||||
<MiniMapPanel
|
<MiniMapPanel
|
||||||
@@ -54,15 +55,13 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
import { onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
import { useMinimap } from '@/composables/useMinimap'
|
import { useMinimap } from '@/composables/useMinimap'
|
||||||
import { useCanvasStore } from '@/stores/graphStore'
|
|
||||||
|
|
||||||
import MiniMapPanel from './MiniMapPanel.vue'
|
import MiniMapPanel from './MiniMapPanel.vue'
|
||||||
|
|
||||||
const minimap = useMinimap()
|
const minimapRef = ref<HTMLDivElement>()
|
||||||
const canvasStore = useCanvasStore()
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
initialized,
|
initialized,
|
||||||
@@ -80,13 +79,13 @@ const {
|
|||||||
renderBypass,
|
renderBypass,
|
||||||
renderError,
|
renderError,
|
||||||
updateOption,
|
updateOption,
|
||||||
init,
|
|
||||||
destroy,
|
destroy,
|
||||||
handlePointerDown,
|
handlePointerDown,
|
||||||
handlePointerMove,
|
handlePointerMove,
|
||||||
handlePointerUp,
|
handlePointerUp,
|
||||||
handleWheel
|
handleWheel,
|
||||||
} = minimap
|
setMinimapRef
|
||||||
|
} = useMinimap()
|
||||||
|
|
||||||
const showOptionsPanel = ref(false)
|
const showOptionsPanel = ref(false)
|
||||||
|
|
||||||
@@ -94,20 +93,8 @@ const toggleOptionsPanel = () => {
|
|||||||
showOptionsPanel.value = !showOptionsPanel.value
|
showOptionsPanel.value = !showOptionsPanel.value
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
onMounted(() => {
|
||||||
() => canvasStore.canvas,
|
setMinimapRef(minimapRef.value)
|
||||||
async (canvas) => {
|
|
||||||
if (canvas && !initialized.value) {
|
|
||||||
await init()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
if (canvasStore.canvas) {
|
|
||||||
await init()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user