[refactor] centralize hardcoded URLs into organized constants

- Create src/constants/urls.ts with centralized URL constants (COMFY_URLS, GITHUB_REPOS, MODEL_SOURCES, DEVELOPER_TOOLS)
- Move runtime domain config to src/config/comfyDomain.ts to allow forkers to customize via env var
- Rename uvMirrors.ts to mirrors.ts for better naming consistency
- Add platform and locale-aware desktop guide URL generation (matching PR #4471)
- Update 10 components to use centralized URL constants
- Add comprehensive unit and e2e tests for URL constants validation

This refactoring improves maintainability by centralizing 150+ hardcoded URLs found across 50+ files into a single organized structure.
This commit is contained in:
bymyself
2025-07-18 13:28:30 -07:00
parent 282f9ce27a
commit 5faf9e0105
13 changed files with 288 additions and 42 deletions

View File

@@ -123,6 +123,7 @@ import Button from 'primevue/button'
import { type CSSProperties, computed, nextTick, onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { COMFY_URLS, GITHUB_REPOS, getDesktopGuideUrl } from '@/constants/urls'
import { type ReleaseNote } from '@/services/releaseService'
import { useCommandStore } from '@/stores/commandStore'
import { useReleaseStore } from '@/stores/releaseStore'
@@ -143,11 +144,10 @@ interface MenuItem {
// Constants
const EXTERNAL_LINKS = {
DOCS: 'https://docs.comfy.org/',
DISCORD: 'https://www.comfy.org/discord',
GITHUB: 'https://github.com/comfyanonymous/ComfyUI',
DESKTOP_GUIDE: 'https://comfyorg.notion.site/',
UPDATE_GUIDE: 'https://docs.comfy.org/installation/update_comfyui'
DOCS: COMFY_URLS.docs.base,
DISCORD: COMFY_URLS.community.discord,
GITHUB: GITHUB_REPOS.comfyui,
UPDATE_GUIDE: COMFY_URLS.docs.installation.update
} as const
const TIME_UNITS = {
@@ -199,7 +199,7 @@ const menuItems = computed<MenuItem[]>(() => {
type: 'item',
label: t('helpCenter.desktopUserGuide'),
action: () => {
openExternalLink(EXTERNAL_LINKS.DESKTOP_GUIDE)
openExternalLink(getDesktopGuideUrl(locale.value))
emit('close')
}
},
@@ -451,8 +451,8 @@ const onUpdate = (_: ReleaseNote): void => {
const getChangelogUrl = (): string => {
const isChineseLocale = locale.value === 'zh'
return isChineseLocale
? 'https://docs.comfy.org/zh-CN/changelog'
: 'https://docs.comfy.org/changelog'
? COMFY_URLS.docs.changelog.zh
: COMFY_URLS.docs.changelog.en
}
// Lifecycle