From 9905458192fae1348ebfa29625b2f79c3b6afac5 Mon Sep 17 00:00:00 2001 From: Yiqun Xu <71995731+yiqun12@users.noreply.github.com> Date: Wed, 11 Jun 2025 20:30:44 -0700 Subject: [PATCH] pref: pref code --- src/components/graph/GraphCanvas.vue | 7 +++--- src/stores/settingStore.ts | 2 +- src/utils/versioning.ts | 37 ---------------------------- 3 files changed, 4 insertions(+), 42 deletions(-) delete mode 100644 src/utils/versioning.ts diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 00304d5fe..705a23a57 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -86,7 +86,6 @@ import { useSettingStore } from '@/stores/settingStore' import { useToastStore } from '@/stores/toastStore' import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore' import { useWorkspaceStore } from '@/stores/workspaceStore' -import { getCurrentVersion } from '@/utils/versioning' const emit = defineEmits<{ ready: [] @@ -301,11 +300,11 @@ onMounted(async () => { CORE_SETTINGS.forEach((setting) => { settingStore.addSetting(setting) }) - if (!settingStore.get('Comfy.InstalledVersion')) { + if (!settingStore.exists('Comfy.InstalledVersion')) { const currentVersion = Object.keys(settingStore.settingValues).length > 0 - ? '0.0.1' - : getCurrentVersion() + ? '' + : __COMFYUI_FRONTEND_VERSION__ await settingStore.set('Comfy.InstalledVersion', currentVersion) } // @ts-expect-error fixme ts strict error diff --git a/src/stores/settingStore.ts b/src/stores/settingStore.ts index 18cc801a0..abbab28ce 100644 --- a/src/stores/settingStore.ts +++ b/src/stores/settingStore.ts @@ -7,7 +7,7 @@ import { api } from '@/scripts/api' import { app } from '@/scripts/app' import type { SettingParams } from '@/types/settingTypes' import type { TreeNode } from '@/types/treeExplorerTypes' -import { compareVersions } from '@/utils/versioning' +import { compareVersions } from '@/utils/formatUtil' export const getSettingInfo = (setting: SettingParams) => { const parts = setting.category || setting.id.split('.') diff --git a/src/utils/versioning.ts b/src/utils/versioning.ts deleted file mode 100644 index 2f6104144..000000000 --- a/src/utils/versioning.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { electronAPI, isElectron } from '@/utils/envUtil' - -/** - * Compare two semantic version strings. - * @param a - First version string - * @param b - Second version string - * @returns 0 if equal, 1 if a > b, -1 if a < b - */ -export function compareVersions(a: string, b: string): number { - const parseVersion = (version: string) => { - return version.split('.').map((v) => parseInt(v, 10) || 0) - } - - const versionA = parseVersion(a) - const versionB = parseVersion(b) - - for (let i = 0; i < Math.max(versionA.length, versionB.length); i++) { - const numA = versionA[i] || 0 - const numB = versionB[i] || 0 - - if (numA > numB) return 1 - if (numA < numB) return -1 - } - - return 0 -} - -/** - * Get the current ComfyUI version for version tracking - */ -export function getCurrentVersion(): string { - if (isElectron()) { - return electronAPI().getComfyUIVersion() - } - // For web version, fallback to frontend version - return __COMFYUI_FRONTEND_VERSION__ -}