refactor usage of isElectron to use isDesktop

This commit is contained in:
bymyself
2025-10-18 01:52:33 -07:00
committed by Christian Byrne
parent c6b528b8be
commit 3324da56c2
27 changed files with 105 additions and 99 deletions

View File

@@ -1,10 +1,10 @@
<template>
<div
ref="rootEl"
class="relative overflow-hidden h-full w-full bg-neutral-900"
class="relative h-full w-full overflow-hidden bg-neutral-900"
>
<div class="p-terminal rounded-none h-full w-full p-2">
<div ref="terminalEl" class="h-full terminal-host" />
<div class="p-terminal h-full w-full rounded-none p-2">
<div ref="terminalEl" class="terminal-host h-full" />
</div>
<Button
v-tooltip.left="{
@@ -26,6 +26,7 @@
</template>
<script setup lang="ts">
import { isDesktop } from '@frontend/platform/distribution/types'
import { useElementHover, useEventListener } from '@vueuse/core'
import type { IDisposable } from '@xterm/xterm'
import Button from 'primevue/button'
@@ -34,7 +35,7 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
import { electronAPI, isElectron } from '@/utils/envUtil'
import { electronAPI } from '@/utils/envUtil'
import { cn } from '@/utils/tailwindUtil'
const { t } = useI18n()
@@ -84,7 +85,7 @@ const showContextMenu = (event: MouseEvent) => {
electronAPI()?.showContextMenu({ type: 'text' })
}
if (isElectron()) {
if (isDesktop) {
useEventListener(terminalEl, 'contextmenu', showContextMenu)
}

View File

@@ -1,14 +1,14 @@
import { isDesktop } from '@frontend/platform/distribution/types'
import {
createRouter,
createWebHashHistory,
createWebHistory
} from 'vue-router'
import { isElectron } from '@/utils/envUtil'
import LayoutDefault from '@/views/layouts/LayoutDefault.vue'
const isFileProtocol = window.location.protocol === 'file:'
const basePath = isElectron() ? '/' : window.location.pathname
const basePath = isDesktop ? '/' : window.location.pathname
const router = createRouter({
history: isFileProtocol ? createWebHashHistory() : createWebHistory(basePath),

View File

@@ -1,13 +1 @@
import type { ElectronAPI } from '@comfyorg/comfyui-electron-types'
export function isElectron() {
return 'electronAPI' in window && window.electronAPI !== undefined
}
export function electronAPI() {
return (window as any).electronAPI as ElectronAPI
}
export function isNativeWindow() {
return isElectron() && !!window.navigator.windowControlsOverlay?.visible
}
export { electronAPI, isNativeWindow } from '@frontend/utils/envUtil'

View File

@@ -1,28 +1,29 @@
<template>
<div
class="font-sans w-screen h-screen flex flex-col"
class="flex h-screen w-screen flex-col font-sans"
:class="[
dark
? 'text-neutral-300 bg-neutral-900 dark-theme'
: 'text-neutral-900 bg-neutral-300'
? 'dark-theme bg-neutral-900 text-neutral-300'
: 'bg-neutral-300 text-neutral-900'
]"
>
<!-- Virtual top menu for native window (drag handle) -->
<div
v-show="isNativeWindow()"
ref="topMenuRef"
class="app-drag w-full h-(--comfy-topbar-height)"
class="app-drag h-(--comfy-topbar-height) w-full"
/>
<div class="grow w-full flex items-center justify-center overflow-auto">
<div class="flex w-full grow items-center justify-center overflow-auto">
<slot />
</div>
</div>
</template>
<script setup lang="ts">
import { isDesktop } from '@frontend/platform/distribution/types'
import { nextTick, onMounted, ref } from 'vue'
import { electronAPI, isElectron, isNativeWindow } from '../../utils/envUtil'
import { electronAPI, isNativeWindow } from '../../utils/envUtil'
const { dark = false } = defineProps<{
dark?: boolean
@@ -40,7 +41,7 @@ const lightTheme = {
const topMenuRef = ref<HTMLDivElement | null>(null)
onMounted(async () => {
if (isElectron()) {
if (isDesktop) {
await nextTick()
electronAPI().changeTheme({

View File

@@ -6,6 +6,7 @@
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@frontend/*": ["../../src/*"],
"@frontend-locales/*": ["../../src/locales/*"]
}
},

View File

@@ -31,6 +31,7 @@ export default defineConfig(() => {
resolve: {
alias: {
'@': path.resolve(projectRoot, 'src'),
'@frontend': path.resolve(projectRoot, '../../src'),
'@frontend-locales': path.resolve(projectRoot, '../../src/locales')
}
},