refactor: update breadcrumb;

;
This commit is contained in:
Łukasz Holeczek
2021-10-12 00:31:49 +02:00
parent dbe35e8cc2
commit d37e594628
2 changed files with 49 additions and 47 deletions
+46
View File
@@ -0,0 +1,46 @@
<template>
<CBreadcrumb class="d-md-down-none me-auto mb-0">
<CBreadcrumbItem
v-for="item in breadcrumbs"
:href="item.active ? '' : item.path"
:active="item.active"
:key="item"
>
{{ item.name }}
</CBreadcrumbItem>
</CBreadcrumb>
</template>
<script>
import { onMounted, ref } from 'vue'
import router from '@/router'
export default {
name: 'AppBreadcrumb',
setup() {
const breadcrumbs = ref()
const getBreadcrumbs = () => {
return router.currentRoute.value.matched.map((route) => {
return {
active: route.path === router.currentRoute.value.fullPath,
name: route.name,
path: `${router.options.history.base}${route.path}`,
}
})
}
router.afterEach(() => {
breadcrumbs.value = getBreadcrumbs()
})
onMounted(() => {
breadcrumbs.value = getBreadcrumbs()
})
return {
breadcrumbs,
}
},
}
</script>