Line data Source code
1 : import { defineStore } from 'pinia'
2 : import { computed } from 'vue'
3 :
4 : import { useExternalLink } from '@/composables/useExternalLink'
5 : import { isCloud, isDesktop } from '@/platform/distribution/types'
6 : import type { AboutPageBadge } from '@/types/comfy'
7 : import { electronAPI } from '@/utils/envUtil'
8 : import { formatCommitHash } from '@/utils/formatUtil'
9 :
10 : import { useExtensionStore } from '@/platform/extensions/stores/extensionStore'
11 : import { useSystemStatsStore } from './systemStatsStore'
12 :
13 4 : export const useAboutPanelStore = defineStore('aboutPanel', () => {
14 4 : const frontendVersion = __COMFYUI_FRONTEND_VERSION__
15 4 : const extensionStore = useExtensionStore()
16 4 : const systemStatsStore = useSystemStatsStore()
17 4 : const { staticUrls } = useExternalLink()
18 4 : const coreVersion = computed(
19 : () => systemStatsStore.systemStats?.system.comfyui_version ?? ''
20 : )
21 4 : const templatesVersion = computed(
22 : () => systemStatsStore.systemStats?.system.installed_templates_version ?? ''
23 : )
24 4 : const requiredTemplatesVersion = computed(
25 : () => systemStatsStore.systemStats?.system.required_templates_version ?? ''
26 : )
27 4 : const isTemplatesOutdated = computed(
28 : () =>
29 : templatesVersion.value !== '' &&
30 : requiredTemplatesVersion.value !== '' &&
31 : templatesVersion.value !== requiredTemplatesVersion.value
32 : )
33 :
34 4 : const coreBadges = computed<AboutPageBadge[]>(() => [
35 : {
36 : label: `ComfyUI ${
37 : isDesktop
38 : ? 'v' + electronAPI().getComfyUIVersion()
39 : : formatCommitHash(coreVersion.value)
40 : }`,
41 : url: isCloud ? staticUrls.comfyOrg : staticUrls.github,
42 : icon: isCloud ? 'icon-[lucide--cloud]' : 'icon-[lucide--github]'
43 : },
44 : {
45 : label: `ComfyUI_frontend v${frontendVersion}`,
46 : url: staticUrls.githubFrontend,
47 : icon: 'icon-[lucide--github]'
48 : },
49 : ...(templatesVersion.value
50 : ? [
51 : {
52 : label: `Templates v${templatesVersion.value}`,
53 : url: 'https://pypi.org/project/comfyui-workflow-templates/',
54 : icon: 'icon-[lucide--book]',
55 : ...(isTemplatesOutdated.value
56 : ? { severity: 'danger' as const }
57 : : {})
58 : }
59 : ]
60 : : []),
61 : {
62 : label: 'Discord',
63 : url: staticUrls.discord,
64 : icon: 'pi pi-discord'
65 : },
66 : {
67 : label: 'ComfyOrg',
68 : url: staticUrls.comfyOrg,
69 : icon: 'icon-[lucide--globe]'
70 : }
71 : ])
72 :
73 : const allBadges = computed<AboutPageBadge[]>(() => [
74 : ...coreBadges.value,
75 : ...extensionStore.extensions
76 : .filter((e) => extensionStore.contributes(e.name))
77 : .flatMap((e) => e.aboutPageBadges ?? [])
78 : ])
79 :
80 4 : return {
81 : badges: allBadges
82 : }
83 : })
|