Files
ComfyUI_frontend/src/router.ts
Chenlei Hu d1e019589d [Electron] ComfyUI Desktop install wizard (#1503)
* Basic prototype

* Welcome screen animation

* nit

* Refactor structure

* Fix mocking

* Add tooltips

* i18n

* Add next button

* nit

* Stepper navigate

* Extract

* More i18n

* More i18n

* Polish MigrationPicker

* Polish settings step

* Add more i18n

* nit

* nit
2024-11-10 19:56:01 -05:00

68 lines
1.5 KiB
TypeScript

import {
createRouter,
createWebHashHistory,
createWebHistory,
NavigationGuardNext,
RouteLocationNormalized
} from 'vue-router'
import LayoutDefault from '@/views/layouts/LayoutDefault.vue'
import { isElectron } from './utils/envUtil'
const isFileProtocol = () => window.location.protocol === 'file:'
const guardElectronAccess = (
to: RouteLocationNormalized,
from: RouteLocationNormalized,
next: NavigationGuardNext
) => {
if (isElectron()) {
next()
} else {
next('/')
}
}
const router = createRouter({
history: isFileProtocol() ? createWebHashHistory() : createWebHistory(),
routes: [
{
path: '/',
component: LayoutDefault,
children: [
{
path: '',
name: 'GraphView',
component: () => import('@/views/GraphView.vue')
},
{
path: 'server-start',
name: 'ServerStartView',
component: () => import('@/views/ServerStartView.vue'),
beforeEnter: guardElectronAccess
},
{
path: 'install',
name: 'InstallView',
component: () => import('@/views/InstallView.vue'),
beforeEnter: guardElectronAccess
},
{
path: 'welcome',
name: 'WelcomeView',
component: () => import('@/views/WelcomeView.vue'),
beforeEnter: guardElectronAccess
}
]
}
],
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { top: 0 }
}
}
})
export default router