| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <template>
- <v-breadcrumbs
- :items="items"
- />
- </template>
- <script setup lang="ts">
- import {useRouter, useRuntimeConfig} from "#app";
- import {computed, ComputedRef} from "@vue/reactivity";
- import {AnyJson} from "~/types/data";
- import {useI18n} from "vue-i18n";
- import Url from "~/services/utils/url";
- const runtimeConfig = useRuntimeConfig()
- const i18n = useI18n()
- const router = useRouter()
- const items: ComputedRef<Array<AnyJson>> = computed(() => {
- const crumbs:Array<AnyJson> = []
- crumbs.push({
- title: i18n.t('welcome'),
- href: runtimeConfig.baseUrlAdminLegacy
- })
- const pathPart: Array<string> = Url.split(router.currentRoute.value.path)
- let path: string = ''
- pathPart.forEach((part) => {
- path = `${path}/${part}`
- const match = router.resolve(path)
- if (match.name !== null) {
- crumbs.push({
- title: !parseInt(part, 10) ? i18n.t(part + '_breadcrumbs') : i18n.t('item'),
- exact: true,
- to: path
- })
- }
- })
- console.log(crumbs)
- return crumbs
- })
- </script>
|