mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
Fix CI timeout by reverting to navigator-based platform detection
The systemStatsStore approach was causing CI timeouts because it added Pinia store initialization overhead during page load. Reverting getDesktopGuideUrl to use navigator.platform directly resolves the i18n collection timeout that started with our URL centralization.
This commit is contained in:
@@ -128,7 +128,6 @@ import { type ReleaseNote } from '@/services/releaseService'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
import { useReleaseStore } from '@/stores/releaseStore'
|
||||
import { useSettingStore } from '@/stores/settingStore'
|
||||
import { useSystemStatsStore } from '@/stores/systemStatsStore'
|
||||
import { electronAPI, isElectron } from '@/utils/envUtil'
|
||||
import { formatVersionAnchor } from '@/utils/formatUtil'
|
||||
|
||||
@@ -200,11 +199,7 @@ const menuItems = computed<MenuItem[]>(() => {
|
||||
type: 'item',
|
||||
label: t('helpCenter.desktopUserGuide'),
|
||||
action: () => {
|
||||
// Access systemStats lazily only when action is triggered
|
||||
const systemStats = useSystemStatsStore()
|
||||
openExternalLink(
|
||||
getDesktopGuideUrl(locale.value, systemStats.systemStats?.system?.os)
|
||||
)
|
||||
openExternalLink(getDesktopGuideUrl(locale.value))
|
||||
emit('close')
|
||||
}
|
||||
},
|
||||
@@ -462,7 +457,7 @@ const getChangelogUrl = (): string => {
|
||||
|
||||
// Lifecycle
|
||||
onMounted(async () => {
|
||||
if (!hasReleases.value) {
|
||||
if (showVersionUpdates.value && !hasReleases.value) {
|
||||
await releaseStore.fetchReleases()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -80,23 +80,13 @@ export const DEVELOPER_TOOLS = {
|
||||
}
|
||||
|
||||
// Platform and locale-aware desktop guide URL generator
|
||||
export const getDesktopGuideUrl = (
|
||||
locale: string,
|
||||
systemStatsOs?: string
|
||||
): string => {
|
||||
export const getDesktopGuideUrl = (locale: string): string => {
|
||||
const isChineseLocale = locale === 'zh'
|
||||
const isMacOS =
|
||||
typeof navigator !== 'undefined' &&
|
||||
navigator.platform.toUpperCase().indexOf('MAC') >= 0
|
||||
|
||||
let platform = 'windows' // default
|
||||
|
||||
if (systemStatsOs) {
|
||||
const os = systemStatsOs.toLowerCase()
|
||||
if (os.includes('darwin') || os.includes('mac')) {
|
||||
platform = 'macos'
|
||||
} else if (os.includes('windows')) {
|
||||
platform = 'windows'
|
||||
}
|
||||
}
|
||||
|
||||
const platform = isMacOS ? 'macos' : 'windows'
|
||||
const baseUrl = isChineseLocale
|
||||
? `https://docs.${COMFY_BASE_DOMAIN}/zh-CN/installation/desktop`
|
||||
: `https://docs.${COMFY_BASE_DOMAIN}/installation/desktop`
|
||||
|
||||
@@ -5,7 +5,6 @@ import { getDesktopGuideUrl } from '@/constants/urls'
|
||||
import { i18n, t } from '@/i18n'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useSystemStatsStore } from '@/stores/systemStatsStore'
|
||||
import { useToastStore } from '@/stores/toastStore'
|
||||
import { useWorkflowStore } from '@/stores/workflowStore'
|
||||
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
|
||||
@@ -161,14 +160,7 @@ import { checkMirrorReachable } from '@/utils/networkUtil'
|
||||
label: 'Desktop User Guide',
|
||||
icon: 'pi pi-book',
|
||||
function() {
|
||||
const systemStatsStore = useSystemStatsStore()
|
||||
window.open(
|
||||
getDesktopGuideUrl(
|
||||
i18n.global.locale.value,
|
||||
systemStatsStore.systemStats?.system?.os
|
||||
),
|
||||
'_blank'
|
||||
)
|
||||
window.open(getDesktopGuideUrl(i18n.global.locale.value), '_blank')
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -102,35 +102,64 @@ describe('URL Constants', () => {
|
||||
})
|
||||
|
||||
it('should generate platform and locale-aware desktop guide URLs', () => {
|
||||
// Test default (no OS provided) - should default to Windows
|
||||
const defaultUrl = getDesktopGuideUrl('en')
|
||||
expect(defaultUrl).toBe(
|
||||
'https://docs.comfy.org/installation/desktop/windows'
|
||||
)
|
||||
// Mock navigator for testing
|
||||
const originalNavigator = global.navigator
|
||||
|
||||
// Test with systemStats OS parameter - macOS
|
||||
const macUrl = getDesktopGuideUrl('en', 'Darwin 23.1.0')
|
||||
expect(macUrl).toBe('https://docs.comfy.org/installation/desktop/macos')
|
||||
// Test Windows platform
|
||||
Object.defineProperty(global, 'navigator', {
|
||||
value: { platform: 'Win32' },
|
||||
writable: true
|
||||
})
|
||||
|
||||
// Test with systemStats OS parameter - Windows
|
||||
const winUrl = getDesktopGuideUrl('en', 'Windows 10')
|
||||
const winUrl = getDesktopGuideUrl('en')
|
||||
expect(winUrl).toBe('https://docs.comfy.org/installation/desktop/windows')
|
||||
|
||||
// Test Chinese locale with systemStats
|
||||
const zhMacUrl = getDesktopGuideUrl('zh', 'macOS 14.0')
|
||||
// Test macOS platform
|
||||
Object.defineProperty(global, 'navigator', {
|
||||
value: { platform: 'MacIntel' },
|
||||
writable: true
|
||||
})
|
||||
|
||||
const macUrl = getDesktopGuideUrl('en')
|
||||
expect(macUrl).toBe('https://docs.comfy.org/installation/desktop/macos')
|
||||
|
||||
// Test Chinese locale with macOS
|
||||
const zhMacUrl = getDesktopGuideUrl('zh')
|
||||
expect(zhMacUrl).toBe(
|
||||
'https://docs.comfy.org/zh-CN/installation/desktop/macos'
|
||||
)
|
||||
|
||||
// Test Chinese locale defaults to Windows
|
||||
const zhDefaultUrl = getDesktopGuideUrl('zh')
|
||||
expect(zhDefaultUrl).toBe(
|
||||
// Test Chinese locale with Windows
|
||||
Object.defineProperty(global, 'navigator', {
|
||||
value: { platform: 'Win32' },
|
||||
writable: true
|
||||
})
|
||||
|
||||
const zhWinUrl = getDesktopGuideUrl('zh')
|
||||
expect(zhWinUrl).toBe(
|
||||
'https://docs.comfy.org/zh-CN/installation/desktop/windows'
|
||||
)
|
||||
|
||||
// Test other locales default to English
|
||||
const frUrl = getDesktopGuideUrl('fr', 'Windows 11')
|
||||
const frUrl = getDesktopGuideUrl('fr')
|
||||
expect(frUrl).toBe('https://docs.comfy.org/installation/desktop/windows')
|
||||
|
||||
// Test environment without navigator
|
||||
Object.defineProperty(global, 'navigator', {
|
||||
value: undefined,
|
||||
writable: true
|
||||
})
|
||||
|
||||
const noNavUrl = getDesktopGuideUrl('en')
|
||||
expect(noNavUrl).toBe(
|
||||
'https://docs.comfy.org/installation/desktop/windows'
|
||||
)
|
||||
|
||||
// Restore original navigator
|
||||
Object.defineProperty(global, 'navigator', {
|
||||
value: originalNavigator,
|
||||
writable: true
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user