mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-21 15:24:09 +00:00
don't just alias
This commit is contained in:
16
apps/desktop-ui/src/platform/distribution/types.ts
Normal file
16
apps/desktop-ui/src/platform/distribution/types.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Distribution types and compile-time constants for managing
|
||||
* multi-distribution builds (Desktop, Localhost, Cloud)
|
||||
*/
|
||||
|
||||
type Distribution = 'desktop' | 'localhost' | 'cloud'
|
||||
|
||||
declare global {
|
||||
const __DISTRIBUTION__: Distribution
|
||||
}
|
||||
|
||||
/** Current distribution - replaced at compile time */
|
||||
const DISTRIBUTION: Distribution = __DISTRIBUTION__
|
||||
|
||||
/** Distribution type checks */
|
||||
export const isDesktop = DISTRIBUTION === 'desktop'
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { ElectronAPI } from '@comfyorg/comfyui-electron-types'
|
||||
|
||||
function isElectron() {
|
||||
return 'electronAPI' in window && window.electronAPI !== undefined
|
||||
}
|
||||
import { isDesktop } from '@/platform/distribution/types'
|
||||
|
||||
export function electronAPI() {
|
||||
return (window as any).electronAPI as ElectronAPI
|
||||
@@ -12,5 +10,5 @@ export function isNativeWindow() {
|
||||
return isDesktop && !!window.navigator.windowControlsOverlay?.visible
|
||||
}
|
||||
|
||||
/** Distribution type check - desktop-ui always runs in desktop context */
|
||||
export const isDesktop = isElectron()
|
||||
// Re-export for backwards compatibility
|
||||
export { isDesktop } from '@/platform/distribution/types'
|
||||
|
||||
@@ -67,6 +67,9 @@ export default defineConfig(() => {
|
||||
minify: SHOULD_MINIFY ? ('esbuild' as const) : false,
|
||||
target: 'es2022',
|
||||
sourcemap: true
|
||||
},
|
||||
define: {
|
||||
__DISTRIBUTION__: JSON.stringify('desktop')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -17,13 +17,14 @@ import { computed, onMounted } from 'vue'
|
||||
import GlobalDialog from '@/components/dialog/GlobalDialog.vue'
|
||||
import config from '@/config'
|
||||
import { t } from '@/i18n'
|
||||
import { isDesktop } from '@/platform/distribution/types'
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useWorkspaceStore } from '@/stores/workspaceStore'
|
||||
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
|
||||
|
||||
import { electronAPI, isElectron } from './utils/envUtil'
|
||||
import { electronAPI } from './utils/envUtil'
|
||||
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const conflictDetection = useConflictDetection()
|
||||
@@ -50,7 +51,7 @@ const showContextMenu = (event: MouseEvent) => {
|
||||
onMounted(() => {
|
||||
window['__COMFYUI_FRONTEND_VERSION__'] = config.app_version
|
||||
|
||||
if (isElectron()) {
|
||||
if (isDesktop) {
|
||||
document.addEventListener('contextmenu', showContextMenu)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { isElectron } from '@/utils/envUtil'
|
||||
|
||||
/**
|
||||
* Distribution types and compile-time constants for managing
|
||||
* multi-distribution builds (Desktop, Localhost, Cloud)
|
||||
@@ -15,6 +13,6 @@ declare global {
|
||||
const DISTRIBUTION: Distribution = __DISTRIBUTION__
|
||||
|
||||
/** Distribution type checks */
|
||||
export const isDesktop = DISTRIBUTION === 'desktop' || isElectron() // TODO: replace with build var
|
||||
export const isDesktop = DISTRIBUTION === 'desktop'
|
||||
export const isCloud = DISTRIBUTION === 'cloud'
|
||||
// export const isLocalhost = DISTRIBUTION === 'localhost' || (!isDesktop && !isCloud)
|
||||
|
||||
@@ -8,11 +8,10 @@ import {
|
||||
import type { RouteLocationNormalized } from 'vue-router'
|
||||
|
||||
import { useFeatureFlags } from '@/composables/useFeatureFlags'
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
import { isCloud, isDesktop } from '@/platform/distribution/types'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
||||
import { useUserStore } from '@/stores/userStore'
|
||||
import { isElectron } from '@/utils/envUtil'
|
||||
import LayoutDefault from '@/views/layouts/LayoutDefault.vue'
|
||||
|
||||
import { installPreservedQueryTracker } from '@/platform/navigation/preservedQueryTracker'
|
||||
@@ -29,7 +28,7 @@ const isFileProtocol = window.location.protocol === 'file:'
|
||||
* to support deployments like http://mysite.com/ComfyUI/
|
||||
*/
|
||||
function getBasePath(): string {
|
||||
if (isElectron()) return '/'
|
||||
if (isDesktop) return '/'
|
||||
if (isCloud) return import.meta.env?.BASE_URL || '/'
|
||||
return window.location.pathname
|
||||
}
|
||||
@@ -156,8 +155,8 @@ if (isCloud) {
|
||||
|
||||
// Handle other protected routes
|
||||
if (!isLoggedIn) {
|
||||
// For Electron, use dialog
|
||||
if (isElectron()) {
|
||||
// For desktop, use dialog
|
||||
if (isDesktop) {
|
||||
const dialogService = useDialogService()
|
||||
const loginSuccess = await dialogService.showSignInDialog()
|
||||
return loginSuccess ? next() : next(false)
|
||||
@@ -169,7 +168,7 @@ if (isCloud) {
|
||||
|
||||
// User is logged in - check if they need onboarding (when enabled)
|
||||
// For root path, check actual user status to handle waitlisted users
|
||||
if (!isElectron() && isLoggedIn && to.path === '/') {
|
||||
if (!isDesktop && isLoggedIn && to.path === '/') {
|
||||
if (!flags.onboardingSurveyEnabled) {
|
||||
return next()
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { ElectronAPI } from '@comfyorg/comfyui-electron-types'
|
||||
|
||||
export function isElectron() {
|
||||
return 'electronAPI' in window && window.electronAPI !== undefined
|
||||
}
|
||||
import { isDesktop } from '@/platform/distribution/types'
|
||||
|
||||
export function electronAPI() {
|
||||
return (window as any).electronAPI as ElectronAPI
|
||||
@@ -13,5 +11,5 @@ export function showNativeSystemMenu() {
|
||||
}
|
||||
|
||||
export function isNativeWindow() {
|
||||
return isElectron() && !!window.navigator.windowControlsOverlay?.visible
|
||||
return isDesktop && !!window.navigator.windowControlsOverlay?.visible
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user