diff --git a/src/router.ts b/src/router.ts index 56a61cf9f..dd69f0953 100644 --- a/src/router.ts +++ b/src/router.ts @@ -1,8 +1,15 @@ -import { createRouter, createWebHistory } from 'vue-router' +import { + createRouter, + createWebHashHistory, + createWebHistory +} from 'vue-router' import LayoutDefault from '@/views/layouts/LayoutDefault.vue' +import { isElectron } from './utils/envUtil' + +const isFileProtocol = () => window.location.protocol === 'file:' const router = createRouter({ - history: createWebHistory(window.location.pathname), + history: isFileProtocol() ? createWebHashHistory() : createWebHistory(), routes: [ { path: '/', @@ -10,7 +17,21 @@ const router = createRouter({ children: [ { path: '', + name: 'GraphView', component: () => import('@/views/GraphView.vue') + }, + { + path: 'server-start', + name: 'ServerStartView', + component: () => import('@/views/ServerStartView.vue'), + beforeEnter: async (to, from, next) => { + // Only allow access to this page in electron environment + if (isElectron()) { + next() + } else { + next('/') + } + } } ] } diff --git a/src/utils/envUtil.ts b/src/utils/envUtil.ts new file mode 100644 index 000000000..4386dccd8 --- /dev/null +++ b/src/utils/envUtil.ts @@ -0,0 +1,3 @@ +export function isElectron() { + return 'electronAPI' in window && window['electronAPI'] !== undefined +} diff --git a/src/views/ServerStartView.vue b/src/views/ServerStartView.vue new file mode 100644 index 000000000..c35fbf094 --- /dev/null +++ b/src/views/ServerStartView.vue @@ -0,0 +1,17 @@ + + + + + + {{ $t('loading') }}{{ counter }} + + + +