2022-01-11 19:03:42 +08:00
|
|
|
<template>
|
|
|
|
<n-breadcrumb class="px-12px">
|
|
|
|
<template v-for="breadcrumb in breadcrumbs" :key="breadcrumb.key">
|
|
|
|
<n-breadcrumb-item>
|
2023-05-04 19:02:20 +08:00
|
|
|
<n-dropdown v-if="breadcrumb.hasChildren" :options="breadcrumb.options" @select="dropdownSelect">
|
2022-01-11 19:03:42 +08:00
|
|
|
<span>
|
2022-01-18 01:17:09 +08:00
|
|
|
<component
|
|
|
|
:is="breadcrumb.icon"
|
|
|
|
v-if="theme.header.crumb.showIcon"
|
|
|
|
class="inline-block align-text-bottom mr-4px text-16px"
|
|
|
|
/>
|
2023-05-13 12:58:35 +08:00
|
|
|
<span>{{ breadcrumb.i18nTitle ? t(breadcrumb.i18nTitle) : breadcrumb.label }}</span>
|
2022-01-11 19:03:42 +08:00
|
|
|
</span>
|
|
|
|
</n-dropdown>
|
|
|
|
<template v-else>
|
2022-02-23 02:27:22 +08:00
|
|
|
<component
|
|
|
|
:is="breadcrumb.icon"
|
|
|
|
v-if="theme.header.crumb.showIcon"
|
|
|
|
class="inline-block align-text-bottom mr-4px text-16px"
|
2022-04-29 19:19:10 +08:00
|
|
|
:class="{ 'text-#BBBBBB': theme.header.inverted }"
|
2022-02-23 02:27:22 +08:00
|
|
|
/>
|
2023-05-24 00:16:31 +08:00
|
|
|
<span :class="{ 'text-#BBBBBB': theme.header.inverted }">
|
|
|
|
{{ breadcrumb.i18nTitle ? t(breadcrumb.i18nTitle) : breadcrumb.label }}
|
|
|
|
</span>
|
2022-01-11 19:03:42 +08:00
|
|
|
</template>
|
|
|
|
</n-breadcrumb-item>
|
|
|
|
</template>
|
|
|
|
</n-breadcrumb>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed } from 'vue';
|
|
|
|
import { useRoute } from 'vue-router';
|
|
|
|
import { routePath } from '@/router';
|
2022-08-10 21:31:59 +08:00
|
|
|
import { useRouteStore, useThemeStore } from '@/store';
|
2022-01-11 19:03:42 +08:00
|
|
|
import { useRouterPush } from '@/composables';
|
|
|
|
import { getBreadcrumbByRouteKey } from '@/utils';
|
2023-05-13 12:58:35 +08:00
|
|
|
import { t } from '@/locales';
|
2022-01-11 19:03:42 +08:00
|
|
|
|
2022-07-10 14:02:00 +08:00
|
|
|
defineOptions({ name: 'GlobalBreadcrumb' });
|
|
|
|
|
2022-01-11 19:03:42 +08:00
|
|
|
const route = useRoute();
|
|
|
|
const theme = useThemeStore();
|
|
|
|
const routeStore = useRouteStore();
|
|
|
|
const { routerPush } = useRouterPush();
|
|
|
|
|
|
|
|
const breadcrumbs = computed(() =>
|
2022-11-08 01:14:59 +08:00
|
|
|
getBreadcrumbByRouteKey(route.name as string, routeStore.menus as App.GlobalMenuOption[], routePath('root'))
|
2022-01-11 19:03:42 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
function dropdownSelect(key: string) {
|
|
|
|
routerPush({ name: key });
|
|
|
|
}
|
|
|
|
</script>
|
2022-05-28 12:30:17 +08:00
|
|
|
|
2022-01-11 19:03:42 +08:00
|
|
|
<style scoped></style>
|