Skip to content

Commit 6ef0923

Browse files
joaomariolagopatrickelectric
authored andcommitted
website: Fix router to use relative navigation
1 parent 7e72b2a commit 6ef0923

3 files changed

Lines changed: 31 additions & 25 deletions

File tree

website/src/components/Counter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<v-container>
3-
<v-row
3+
<v-row
44
v-for="(section, index) in sections"
55
:key="index"
66
>

website/src/layouts/default/AppBar.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44
BlueOS Store Apps
55
</v-app-bar-title>
66
<v-spacer></v-spacer>
7-
<v-btn :to="buttonRoute">{{ buttonText }}</v-btn>
7+
<v-btn @click="navigateTo">{{ buttonText }}</v-btn>
88
</v-app-bar>
99
</template>
1010

1111
<script lang="ts" setup>
1212
import { computed } from 'vue'
13-
import { useRoute } from 'vue-router'
13+
import { useRoute, useRouter } from 'vue-router'
1414
1515
const route = useRoute()
16+
const router = useRouter()
1617
17-
const buttonText = computed(() => {
18-
return route.path === '/logs' ? 'Home' : 'Logs'
19-
})
18+
const navigateTo = () => {
19+
router.push(route.path.endsWith('/logs') ? './' : './logs')
20+
}
2021
21-
const buttonRoute = computed(() => {
22-
return route.path === '/logs' ? '/' : '/logs'
22+
const buttonText = computed(() => {
23+
return route.path.endsWith('/logs') ? 'Home' : 'Logs'
2324
})
2425
</script>

website/src/router/index.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
// Composables
22
import { createRouter, createWebHistory } from 'vue-router'
3+
const DefaultLayout = () => import('@/layouts/default/Default.vue')
4+
5+
const childRoutes = [
6+
{
7+
path: 'logs',
8+
name: 'Logs',
9+
component: () => import(/* webpackChunkName: "logs" */ '@/views/Logs.vue'),
10+
},
11+
{
12+
path: '',
13+
name: 'Home',
14+
component: () => import(/* webpackChunkName: "home" */ '@/views/Home.vue'),
15+
},
16+
]
317

418
const routes = [
519
{
6-
path: '/dist|BlueOS-Extensions-Repository|',
7-
component: () => import('@/layouts/default/Default.vue'),
8-
children: [
9-
{
10-
path: '',
11-
name: 'Home',
12-
// route level code-splitting
13-
// this generates a separate chunk (about.[hash].js) for this route
14-
// which is lazy-loaded when the route is visited.
15-
component: () => import(/* webpackChunkName: "home" */ '@/views/Home.vue'),
16-
},
17-
{
18-
path: 'logs',
19-
name: 'Logs',
20-
component: () => import(/* webpackChunkName: "logs" */ '@/views/Logs.vue'),
21-
},
22-
],
20+
path: '/dist',
21+
component: DefaultLayout,
22+
children: childRoutes,
23+
},
24+
{
25+
path: '/BlueOS-Extensions-Repository',
26+
component: DefaultLayout,
27+
children: childRoutes,
2328
},
2429
]
2530

0 commit comments

Comments
 (0)