mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
[backport core/1.32] feat: LOD setting for LG and Vue (#6848)
Backport of #6755 to `core/1.32` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6848-backport-core-1-32-feat-LOD-setting-for-LG-and-Vue-2b46d73d3650813d8105d5df3e3685e1) by [Unito](https://www.unito.io) Co-authored-by: Simula_r <18093452+simula-r@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
|||||||
test.describe('Vue Nodes Zoom', () => {
|
test.describe('Vue Nodes Zoom', () => {
|
||||||
test.beforeEach(async ({ comfyPage }) => {
|
test.beforeEach(async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
|
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
|
||||||
|
await comfyPage.setSetting('LiteGraph.Canvas.MinFontSizeForLOD', 8)
|
||||||
await comfyPage.vueNodes.waitForNodes()
|
await comfyPage.vueNodes.waitForNodes()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ test.beforeEach(async ({ comfyPage }) => {
|
|||||||
test.describe('Vue Nodes - LOD', () => {
|
test.describe('Vue Nodes - LOD', () => {
|
||||||
test.beforeEach(async ({ comfyPage }) => {
|
test.beforeEach(async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
|
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
|
||||||
|
await comfyPage.setSetting('LiteGraph.Canvas.MinFontSizeForLOD', 8)
|
||||||
await comfyPage.setup()
|
await comfyPage.setup()
|
||||||
await comfyPage.loadWorkflow('default')
|
await comfyPage.loadWorkflow('default')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { shallowRef, watch } from 'vue'
|
|||||||
|
|
||||||
import { useGraphNodeManager } from '@/composables/graph/useGraphNodeManager'
|
import { useGraphNodeManager } from '@/composables/graph/useGraphNodeManager'
|
||||||
import type { GraphNodeManager } from '@/composables/graph/useGraphNodeManager'
|
import type { GraphNodeManager } from '@/composables/graph/useGraphNodeManager'
|
||||||
|
import { useRenderModeSetting } from '@/composables/settings/useRenderModeSetting'
|
||||||
import { useVueFeatureFlags } from '@/composables/useVueFeatureFlags'
|
import { useVueFeatureFlags } from '@/composables/useVueFeatureFlags'
|
||||||
import { useVueNodesMigrationDismissed } from '@/composables/useVueNodesMigrationDismissed'
|
import { useVueNodesMigrationDismissed } from '@/composables/useVueNodesMigrationDismissed'
|
||||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||||
@@ -18,15 +19,18 @@ function useVueNodeLifecycleIndividual() {
|
|||||||
const canvasStore = useCanvasStore()
|
const canvasStore = useCanvasStore()
|
||||||
const layoutMutations = useLayoutMutations()
|
const layoutMutations = useLayoutMutations()
|
||||||
const { shouldRenderVueNodes } = useVueFeatureFlags()
|
const { shouldRenderVueNodes } = useVueFeatureFlags()
|
||||||
|
|
||||||
const nodeManager = shallowRef<GraphNodeManager | null>(null)
|
const nodeManager = shallowRef<GraphNodeManager | null>(null)
|
||||||
|
|
||||||
const { startSync } = useLayoutSync()
|
const { startSync } = useLayoutSync()
|
||||||
|
|
||||||
const isVueNodeToastDismissed = useVueNodesMigrationDismissed()
|
const isVueNodeToastDismissed = useVueNodesMigrationDismissed()
|
||||||
|
|
||||||
let hasShownMigrationToast = false
|
let hasShownMigrationToast = false
|
||||||
|
|
||||||
|
useRenderModeSetting(
|
||||||
|
{ setting: 'LiteGraph.Canvas.MinFontSizeForLOD', vue: 0, litegraph: 8 },
|
||||||
|
shouldRenderVueNodes
|
||||||
|
)
|
||||||
|
|
||||||
const initializeNodeManager = () => {
|
const initializeNodeManager = () => {
|
||||||
// Use canvas graph if available (handles subgraph contexts), fallback to app graph
|
// Use canvas graph if available (handles subgraph contexts), fallback to app graph
|
||||||
const activeGraph = comfyApp.canvas?.graph
|
const activeGraph = comfyApp.canvas?.graph
|
||||||
|
|||||||
42
src/composables/settings/useRenderModeSetting.ts
Normal file
42
src/composables/settings/useRenderModeSetting.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import type { ComputedRef } from 'vue'
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||||
|
import type { Settings } from '@/schemas/apiSchema'
|
||||||
|
|
||||||
|
interface RenderModeSettingConfig<TSettingKey extends keyof Settings> {
|
||||||
|
setting: TSettingKey
|
||||||
|
vue: Settings[TSettingKey]
|
||||||
|
litegraph: Settings[TSettingKey]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRenderModeSetting<TSettingKey extends keyof Settings>(
|
||||||
|
config: RenderModeSettingConfig<TSettingKey>,
|
||||||
|
isVueMode: ComputedRef<boolean>
|
||||||
|
) {
|
||||||
|
const settingStore = useSettingStore()
|
||||||
|
const vueValue = ref(config.vue)
|
||||||
|
const litegraphValue = ref(config.litegraph)
|
||||||
|
const lastWasVue = ref<boolean | null>(null)
|
||||||
|
|
||||||
|
const load = async (vue: boolean) => {
|
||||||
|
if (lastWasVue.value === vue) return
|
||||||
|
|
||||||
|
if (lastWasVue.value !== null) {
|
||||||
|
const currentValue = settingStore.get(config.setting)
|
||||||
|
if (lastWasVue.value) {
|
||||||
|
vueValue.value = currentValue
|
||||||
|
} else {
|
||||||
|
litegraphValue.value = currentValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await settingStore.set(
|
||||||
|
config.setting,
|
||||||
|
vue ? vueValue.value : litegraphValue.value
|
||||||
|
)
|
||||||
|
lastWasVue.value = vue
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(isVueMode, load, { immediate: true })
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user