mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 23:50:08 +00:00
## Summary Extracts desktop UI into apps/desktop-ui package with minimal changes. ## Changes - **What**: - Separates desktop-specific code into standalone package with independent Vite config, router, and i18n - Drastically simplifies the main app router by removing all desktop routes - Adds a some code duplication, most due to the existing design - Some duplication can be refactored to be *simpler* on either side - no need to split things by `isElectron()` - Rudimentary storybook support has been added - **Breaking**: Stacked PR for publishing must be merged before this PR makes it to stable core (but publishing _could_ be done manually) - #5915 - **Dependencies**: Takes full advantage of pnpm catalog. No additional dependencies added. ## Review Focus - Should be no changes to normal frontend operation - Scripts added to root package.json are acceptable - The duplication in this PR is copied as is, wherever possible. Any corrections or fix-ups beyond the scope of simply migrating the functionality as-is, can be addressed in later PRs. That said, if any changes are made, it instantly becomes more difficult to separate the duplicated code out into a shared utility. - Tracking issue to address concerns: #5925 ### i18n Fixing i18n is out of scope for this PR. It is a larger task that we should consider carefully and implement properly. Attempting to isolate the desktop i18n and duplicate the _current_ localisation scripts would be wasted energy.
93 lines
2.5 KiB
TypeScript
93 lines
2.5 KiB
TypeScript
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 router = createRouter({
|
|
history: isFileProtocol ? createWebHashHistory() : createWebHistory(basePath),
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
component: LayoutDefault,
|
|
children: [
|
|
{
|
|
path: '',
|
|
name: 'WelcomeView',
|
|
component: () => import('@/views/WelcomeView.vue')
|
|
},
|
|
{
|
|
path: 'welcome',
|
|
name: 'WelcomeViewAlias',
|
|
component: () => import('@/views/WelcomeView.vue')
|
|
},
|
|
{
|
|
path: 'install',
|
|
name: 'InstallView',
|
|
component: () => import('@/views/InstallView.vue')
|
|
},
|
|
{
|
|
path: 'download-git',
|
|
name: 'DownloadGitView',
|
|
component: () => import('@/views/DownloadGitView.vue')
|
|
},
|
|
{
|
|
path: 'desktop-start',
|
|
name: 'DesktopStartView',
|
|
component: () => import('@/views/DesktopStartView.vue')
|
|
},
|
|
{
|
|
path: 'desktop-update',
|
|
name: 'DesktopUpdateView',
|
|
component: () => import('@/views/DesktopUpdateView.vue')
|
|
},
|
|
{
|
|
path: 'server-start',
|
|
name: 'ServerStartView',
|
|
component: () => import('@/views/ServerStartView.vue')
|
|
},
|
|
{
|
|
path: 'manual-configuration',
|
|
name: 'ManualConfigurationView',
|
|
component: () => import('@/views/ManualConfigurationView.vue')
|
|
},
|
|
{
|
|
path: 'metrics-consent',
|
|
name: 'MetricsConsentView',
|
|
component: () => import('@/views/MetricsConsentView.vue')
|
|
},
|
|
{
|
|
path: 'maintenance',
|
|
name: 'MaintenanceView',
|
|
component: () => import('@/views/MaintenanceView.vue')
|
|
},
|
|
{
|
|
path: 'not-supported',
|
|
name: 'NotSupportedView',
|
|
component: () => import('@/views/NotSupportedView.vue')
|
|
},
|
|
{
|
|
path: 'desktop-dialog/:dialogId',
|
|
name: 'DesktopDialogView',
|
|
component: () => import('@/views/DesktopDialogView.vue')
|
|
}
|
|
]
|
|
}
|
|
],
|
|
scrollBehavior(_to, _from, savedPosition) {
|
|
if (savedPosition) {
|
|
return savedPosition
|
|
}
|
|
|
|
return { top: 0 }
|
|
}
|
|
})
|
|
|
|
export default router
|