Skip to content

Commit

Permalink
[Electron] Add electron-specific setup page (#1444)
Browse files Browse the repository at this point in the history
* Add dummy server start view

* Do external nav

* nit

* nit

* nit

* nit
  • Loading branch information
huchenlei authored Nov 7, 2024
1 parent ea08832 commit 5e4439b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
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: '/',
component: LayoutDefault,
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('/')
}
}
}
]
}
Expand Down
3 changes: 3 additions & 0 deletions src/utils/envUtil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function isElectron() {
return 'electronAPI' in window && window['electronAPI'] !== undefined
}
17 changes: 17 additions & 0 deletions src/views/ServerStartView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- This is a dummy page built for electron app only. -->
<!-- Replace this page with the electron side logic on installation & log streaming. -->
<template>
<div
class="absolute inset-0 flex flex-col items-center justify-center h-screen bg-surface-0"
>
<ProgressSpinner class="w-16 h-16 mb-4" />
<div class="text-xl">{{ $t('loading') }}{{ counter }}</div>
</div>
</template>

<script setup lang="ts">
import ProgressSpinner from 'primevue/progressspinner'
import { useInterval } from '@vueuse/core'

const counter = useInterval(1000)
</script>

0 comments on commit 5e4439b

Please sign in to comment.