feat(components): 增加面包屑导航

This commit is contained in:
‘chen.home’ 2022-08-11 01:04:16 +08:00
parent a9a9358c67
commit a56b084426
6 changed files with 37 additions and 11 deletions

View File

@ -12,7 +12,7 @@ const themeOverrides: GlobalThemeOverrides = {} || json;
<template> <template>
<n-loading-bar-provider> <n-loading-bar-provider>
<n-config-provider <n-config-provider
wh-full class="wh-full"
:theme="null" :theme="null"
:locale="locale" :locale="locale"
:date-locale="dateLocale" :date-locale="dateLocale"

View File

@ -11,7 +11,6 @@
> >
<Logo :collapsed="collapsed" /> <Logo :collapsed="collapsed" />
<n-menu <n-menu
:value="activeKey"
:collapsed="collapsed" :collapsed="collapsed"
:collapsed-width="64" :collapsed-width="64"
:collapsed-icon-size="24" :collapsed-icon-size="24"
@ -22,10 +21,20 @@
</n-layout-sider> </n-layout-sider>
<n-layout class="h-full bg-hex-f3f4f6" :native-scrollbar="false"> <n-layout class="h-full bg-hex-f3f4f6" :native-scrollbar="false">
<n-layout-header bordered class="text-2xl h-60px flex-y-center"> <n-layout-header bordered class="h-60px flex-y-center">
<div class="hover:bg-hex-F3F4F6 h-full px-2 flex-center cursor-pointer"> <div class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-2 flex-center cursor-pointer">
<Icon icon="icon-park-outline:mindmap-list" /> <Icon icon="carbon:list" class="inline-block" width="18" />
</div> </div>
<n-breadcrumb>
<n-breadcrumb-item v-for="(item, index) in routes" :key="index">
<Icon :icon="item.meta.icon" class="inline-block" width="18" />
{{ item.meta.title }}
</n-breadcrumb-item>
<n-breadcrumb-item v-for="(item, index) in routes" :key="index">
<Icon :icon="item.meta.icon" class="inline-block" width="18" />
{{ item.meta.title }}
</n-breadcrumb-item>
</n-breadcrumb>
</n-layout-header> </n-layout-header>
<div class="p-16px"> <div class="p-16px">
<n-layout-content> <n-layout-content>
@ -50,7 +59,7 @@ const collapsed = ref(false);
function renderIcon(icon: string) { function renderIcon(icon: string) {
return () => h(Icon, { icon }); return () => h(Icon, { icon });
} }
const activeKey = ref(''); // const activeKey = ref('');
const handleClickMenu = (key: string, _item: MenuOption) => { const handleClickMenu = (key: string, _item: MenuOption) => {
router.push(key); router.push(key);
}; };
@ -108,6 +117,12 @@ const menuOptions: MenuOption[] = [
], ],
}, },
]; ];
import { computed } from 'vue';
const routes = computed(() => {
return router.currentRoute.value.matched.filter((item) => {
return item.meta.title;
});
});
</script> </script>
<style lang="scss" scoped></style> <style scoped></style>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="h-60px text-2xl flex-center"> <div class="h-60px text-2xl flex-center">
<SvgIcon name="logo" class="w-9 h-9" /> <SvgIcon name="logo" class="w-9 h-9" />
<span v-show="!props.collapsed" class="font-bold mx-5">{{ props.title }}</span> <span v-show="!props.collapsed" class="mx-5">{{ props.title }}</span>
</div> </div>
</template> </template>

View File

@ -14,16 +14,28 @@ const routes: RouteRecordRaw[] = [
path: '/test1', path: '/test1',
name: 'test1', name: 'test1',
component: () => import('~/src/views/test/test1.vue'), component: () => import('~/src/views/test/test1.vue'),
meta: {
title: '测试1',
icon: 'icon-park-outline:game-three',
},
}, },
{ {
path: '/test2', path: '/test2',
name: 'test2', name: 'test2',
component: () => import('~/src/views/test/test2.vue'), component: () => import('~/src/views/test/test2.vue'),
meta: {
title: '测试2',
icon: 'carbon:aperture',
},
}, },
{ {
path: '/test3', path: '/test3',
name: 'test3', name: 'test3',
component: () => import('~/src/views/test/test3.vue'), component: () => import('~/src/views/test/test3.vue'),
meta: {
title: '测试3',
icon: 'carbon:breaking-change',
},
}, },
], ],
}, },

View File

@ -5,8 +5,8 @@
</n-carousel> </n-carousel>
<div flex-1 flex-center> <div flex-1 flex-center>
<div b-rd-2 bg-white w-md h-xl shadow-lg p-5xl> <div b-rd-2 bg-white w-md h-xl shadow-lg p-5xl>
<n-h1> <n-h1 c-blue>
<Icon icon="icon-park:ad-product" inline-block /> <Icon icon="icon-park-outline:plastic-surgery" inline-block />
Ench Admin Ench Admin
</n-h1> </n-h1>
<n-p depth="3">高效简约可能对你有点帮助</n-p> <n-p depth="3">高效简约可能对你有点帮助</n-p>

View File

@ -20,7 +20,6 @@ import { ref } from 'vue';
const msg = ref(); const msg = ref();
const pinter = () => { const pinter = () => {
msg.value = import.meta.env; msg.value = import.meta.env;
console.log('打印环境配置', import.meta.env);
}; };
const get = () => { const get = () => {
fetachGet().then((res) => { fetachGet().then((res) => {