Centralized management of external links (#4471)

Update the desktop guide links to make them platform and locale-aware

Edited by Terry:
Refactor external link management by introducing a centralized
useExternalLink composable with automatic locale and platform detection
for documentation URLs.

- Created useExternalLink composable - A new centralized utility for
managing all external links
- Dynamic docs URL builder (buildDocsUrl) - Automatically constructs
docs.comfy.org URLs with:
  - Locale detection (Chinese vs English)
  - Platform detection (macOS vs Windows for desktop)
  - Flexible path construction with options

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-4471-Add-platform-and-locale-aware-desktop-guide-URL-2346d73d3650815ea4a4dd64be575bbe)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Terry Jia <terryjia88@gmail.com>
This commit is contained in:
ComfyUI Wiki
2025-11-14 13:35:28 +08:00
committed by GitHub
parent 1a6913c466
commit b347dd1734
17 changed files with 361 additions and 83 deletions

View File

@@ -309,6 +309,7 @@ import Skeleton from 'primevue/skeleton'
import TabPanel from 'primevue/tabpanel'
import CloudBadge from '@/components/topbar/CloudBadge.vue'
import { useExternalLink } from '@/composables/useExternalLink'
import SubscribeButton from '@/platform/cloud/subscription/components/SubscribeButton.vue'
import SubscriptionBenefits from '@/platform/cloud/subscription/components/SubscriptionBenefits.vue'
import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription'
@@ -316,6 +317,8 @@ import { useSubscriptionActions } from '@/platform/cloud/subscription/composable
import { useSubscriptionCredits } from '@/platform/cloud/subscription/composables/useSubscriptionCredits'
import { cn } from '@/utils/tailwindUtil'
const { buildDocsUrl } = useExternalLink()
const {
isActiveSubscription,
isCancelled,
@@ -340,7 +343,9 @@ const {
const handleOpenPartnerNodesInfo = () => {
window.open(
'https://docs.comfy.org/tutorials/api-nodes/overview#api-nodes',
buildDocsUrl('/tutorials/api-nodes/overview#api-nodes', {
includeLocale: true
}),
'_blank'
)
}

View File

@@ -46,14 +46,14 @@
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useExternalLink } from '@/composables/useExternalLink'
import { formatVersionAnchor } from '@/utils/formatUtil'
import type { ReleaseNote } from '../common/releaseService'
import { useReleaseStore } from '../common/releaseStore'
const { locale } = useI18n()
const { buildDocsUrl } = useExternalLink()
const releaseStore = useReleaseStore()
// Local state for dismissed status
@@ -71,16 +71,12 @@ const shouldShow = computed(
// Generate changelog URL with version anchor (language-aware)
const changelogUrl = computed(() => {
const isChineseLocale = locale.value === 'zh'
const baseUrl = isChineseLocale
? 'https://docs.comfy.org/zh-CN/changelog'
: 'https://docs.comfy.org/changelog'
const changelogBaseUrl = buildDocsUrl('/changelog', { includeLocale: true })
if (latestRelease.value?.version) {
const versionAnchor = formatVersionAnchor(latestRelease.value.version)
return `${baseUrl}#${versionAnchor}`
return `${changelogBaseUrl}#${versionAnchor}`
}
return baseUrl
return changelogBaseUrl
})
// Auto-hide timer
@@ -121,7 +117,10 @@ const handleLearnMore = () => {
}
const handleUpdate = () => {
window.open('https://docs.comfy.org/installation/update_comfyui', '_blank')
window.open(
buildDocsUrl('/installation/update_comfyui', { includeLocale: true }),
'_blank'
)
dismissToast()
}

View File

@@ -67,13 +67,15 @@
import { computed, onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useExternalLink } from '@/composables/useExternalLink'
import { formatVersionAnchor } from '@/utils/formatUtil'
import { renderMarkdownToHtml } from '@/utils/markdownRendererUtil'
import type { ReleaseNote } from '../common/releaseService'
import { useReleaseStore } from '../common/releaseStore'
const { locale, t } = useI18n()
const { t } = useI18n()
const { buildDocsUrl } = useExternalLink()
const releaseStore = useReleaseStore()
// Define emits
@@ -96,16 +98,12 @@ const shouldShow = computed(
// Generate changelog URL with version anchor (language-aware)
const changelogUrl = computed(() => {
const isChineseLocale = locale.value === 'zh'
const baseUrl = isChineseLocale
? 'https://docs.comfy.org/zh-CN/changelog'
: 'https://docs.comfy.org/changelog'
const changelogBaseUrl = buildDocsUrl('/changelog', { includeLocale: true })
if (latestRelease.value?.version) {
const versionAnchor = formatVersionAnchor(latestRelease.value.version)
return `${baseUrl}#${versionAnchor}`
return `${changelogBaseUrl}#${versionAnchor}`
}
return baseUrl
return changelogBaseUrl
})
const formattedContent = computed(() => {
@@ -139,11 +137,6 @@ const closePopup = async () => {
hide()
}
// const handleCTA = async () => {
// window.open('https://docs.comfy.org/installation/update_comfyui', '_blank')
// await closePopup()
// }
// Initialize on mount
onMounted(async () => {
// Fetch releases if not already loaded