mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 13:29:55 +00:00
Reload current workflow when locale changes (#1824)
This commit is contained in:
@@ -64,6 +64,7 @@ import { setStorageValue } from '@/scripts/utils'
|
||||
import { ChangeTracker } from '@/scripts/changeTracker'
|
||||
import { api } from '@/scripts/api'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
import { workflowService } from '@/services/workflowService'
|
||||
|
||||
const emit = defineEmits(['ready'])
|
||||
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
||||
@@ -317,8 +318,9 @@ onMounted(async () => {
|
||||
// Start watching for locale change after the initial value is loaded.
|
||||
watch(
|
||||
() => settingStore.get('Comfy.Locale'),
|
||||
() => {
|
||||
useCommandStore().execute('Comfy.RefreshNodeDefinitions')
|
||||
async () => {
|
||||
await useCommandStore().execute('Comfy.RefreshNodeDefinitions')
|
||||
workflowService.reloadCurrentWorkflow()
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -124,8 +124,27 @@ export const workflowService = {
|
||||
await app.loadGraphData(blankGraph)
|
||||
},
|
||||
|
||||
async openWorkflow(workflow: ComfyWorkflow) {
|
||||
if (useWorkflowStore().isActive(workflow)) return
|
||||
/**
|
||||
* Reload the current workflow
|
||||
* This is used to refresh the node definitions update, e.g. when the locale changes.
|
||||
*/
|
||||
async reloadCurrentWorkflow() {
|
||||
const workflow = useWorkflowStore().activeWorkflow
|
||||
if (workflow) {
|
||||
await this.openWorkflow(workflow, { force: true })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Open a workflow in the current workspace
|
||||
* @param workflow The workflow to open
|
||||
* @param options The options for opening the workflow
|
||||
*/
|
||||
async openWorkflow(
|
||||
workflow: ComfyWorkflow,
|
||||
options: { force: boolean } = { force: false }
|
||||
) {
|
||||
if (useWorkflowStore().isActive(workflow) && !options.force) return
|
||||
|
||||
const loadFromRemote = !workflow.isLoaded
|
||||
if (loadFromRemote) {
|
||||
|
||||
Reference in New Issue
Block a user