From 347563adf90f4a180965d15dc957fcf15b8a8bf4 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Sun, 15 Sep 2024 09:46:34 +0900 Subject: [PATCH] Move json format functions to formatUtil (#834) --- src/scripts/ui/menu/workflows.ts | 3 ++- src/scripts/workflows.ts | 12 +----------- src/utils/formatUtil.ts | 11 +++++++++++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/scripts/ui/menu/workflows.ts b/src/scripts/ui/menu/workflows.ts index 0ed3b281d..33478a58c 100644 --- a/src/scripts/ui/menu/workflows.ts +++ b/src/scripts/ui/menu/workflows.ts @@ -4,8 +4,9 @@ import { $el } from '../../ui' import { api } from '../../api' import { ComfyPopup } from '../components/popup' import { createSpinner } from '../spinner' -import { ComfyWorkflow, trimJsonExt } from '../../workflows' +import { ComfyWorkflow } from '../../workflows' import { ComfyAsyncDialog } from '../components/asyncDialog' +import { trimJsonExt } from '@/utils/formatUtil' import type { ComfyApp } from '@/scripts/app' import type { ComfyComponent } from '../components' diff --git a/src/scripts/workflows.ts b/src/scripts/workflows.ts index 30e70ccbb..bb7087220 100644 --- a/src/scripts/workflows.ts +++ b/src/scripts/workflows.ts @@ -4,17 +4,7 @@ import { ChangeTracker } from './changeTracker' import { ComfyAsyncDialog } from './ui/components/asyncDialog' import { getStorageValue, setStorageValue } from './utils' import { LGraphCanvas, LGraph } from '@comfyorg/litegraph' - -function appendJsonExt(path: string) { - if (!path.toLowerCase().endsWith('.json')) { - path += '.json' - } - return path -} - -export function trimJsonExt(path: string) { - return path?.replace(/\.json$/, '') -} +import { appendJsonExt, trimJsonExt } from '@/utils/formatUtil' export class ComfyWorkflowManager extends EventTarget { executionStore: any = null diff --git a/src/utils/formatUtil.ts b/src/utils/formatUtil.ts index 0cecd4923..6bec35cec 100644 --- a/src/utils/formatUtil.ts +++ b/src/utils/formatUtil.ts @@ -22,3 +22,14 @@ export function formatCamelCase(str: string): string { // Join the words with spaces return processedWords.join(' ') } + +export function appendJsonExt(path: string) { + if (!path.toLowerCase().endsWith('.json')) { + path += '.json' + } + return path +} + +export function trimJsonExt(path: string) { + return path.replace(/\.json$/, '') +}