diff --git a/global.d.ts b/global.d.ts index a9361846e..6489feb8e 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,3 +1,15 @@ declare const __COMFYUI_FRONTEND_VERSION__: string declare const __SENTRY_ENABLED__: boolean declare const __SENTRY_DSN__: string + +interface Navigator { + /** + * Used by the electron API. This is a WICG non-standard API, but is guaranteed to exist in Electron. + * It is `undefined` in Firefox and older browsers. + * @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/windowControlsOverlay + */ + windowControlsOverlay?: { + /** When `true`, the window is using custom window style. */ + visible: boolean + } +} diff --git a/src/components/topbar/TopMenubar.vue b/src/components/topbar/TopMenubar.vue index f039c7e93..d0b089117 100644 --- a/src/components/topbar/TopMenubar.vue +++ b/src/components/topbar/TopMenubar.vue @@ -33,7 +33,7 @@
@@ -50,7 +50,12 @@ import WorkflowTabs from '@/components/topbar/WorkflowTabs.vue' import { app } from '@/scripts/app' import { useSettingStore } from '@/stores/settingStore' import { useWorkspaceStore } from '@/stores/workspaceStore' -import { electronAPI, isElectron, showNativeMenu } from '@/utils/envUtil' +import { + electronAPI, + isElectron, + isNativeWindow, + showNativeMenu +} from '@/utils/envUtil' const workspaceState = useWorkspaceStore() const settingStore = useSettingStore() @@ -64,10 +69,6 @@ const teleportTarget = computed(() => ? '.comfyui-body-top' : '.comfyui-body-bottom' ) -const isNativeWindow = computed( - () => - isElectron() && settingStore.get('Comfy-Desktop.WindowStyle') === 'custom' -) const showTopMenu = computed( () => betaMenuEnabled.value && !workspaceState.focusMode ) diff --git a/src/utils/envUtil.ts b/src/utils/envUtil.ts index d7a86c206..59641e537 100644 --- a/src/utils/envUtil.ts +++ b/src/utils/envUtil.ts @@ -14,3 +14,7 @@ export function electronAPI() { export function showNativeMenu(event: MouseEvent) { electronAPI()?.showContextMenu(event as ElectronContextMenuOptions) } + +export function isNativeWindow() { + return isElectron() && !!window.navigator.windowControlsOverlay?.visible +} diff --git a/src/views/templates/BaseViewTemplate.vue b/src/views/templates/BaseViewTemplate.vue index f9d6bf6ea..653279b0d 100644 --- a/src/views/templates/BaseViewTemplate.vue +++ b/src/views/templates/BaseViewTemplate.vue @@ -9,7 +9,7 @@ > @@ -24,7 +24,7 @@