|
| 1 | +<script lang="ts" setup> |
| 2 | +import { RouterView, useRouter } from 'vue-router' |
| 3 | +
|
| 4 | +import { JeFrame } from '../src/index' |
| 5 | +import SidebarMenuItem from './components/SidebarMenuItem.vue' |
| 6 | +import { routes } from './router' |
| 7 | +
|
| 8 | +const router = useRouter() |
| 9 | +
|
| 10 | +interface MenuItem { |
| 11 | + value: string |
| 12 | + label: string |
| 13 | + link: string |
| 14 | +} |
| 15 | +
|
| 16 | +const componentsMenuItems: MenuItem[] = routes |
| 17 | + .filter(route => !route.meta?.hiddenInMenu && route.name) // 只显示有 name 的路由 |
| 18 | + .map(route => ({ |
| 19 | + value: route.name!, |
| 20 | + label: route.meta.label || route.name!, |
| 21 | + link: route.path, |
| 22 | + })) |
| 23 | +
|
| 24 | +function goTo(url: string) { |
| 25 | + router.push(url) |
| 26 | +} |
| 27 | +</script> |
| 28 | + |
| 29 | +<template> |
| 30 | + <JeFrame |
| 31 | + type="primary" |
| 32 | + flex="~ row items-start justify-start" |
| 33 | + size-full |
| 34 | + > |
| 35 | + <JeFrame |
| 36 | + type="secondary" |
| 37 | + shrink-0 |
| 38 | + h-full w="250px" p="t-20px" box-border |
| 39 | + flex="~ col items-center justify-start" gap="20px" |
| 40 | + > |
| 41 | + <span |
| 42 | + text="h1" cursor-pointer |
| 43 | + @click="goTo('/')" |
| 44 | + > |
| 45 | + JetV-ui Gallery |
| 46 | + </span> |
| 47 | + |
| 48 | + <JeFrame |
| 49 | + type="secondary" |
| 50 | + w-full p="x-0px" box-border |
| 51 | + flex="~ col items-center justify-start" |
| 52 | + overflow-auto |
| 53 | + > |
| 54 | + <div |
| 55 | + w-full p="x-10px y-5px" box-border |
| 56 | + text="default-semibold" |
| 57 | + > |
| 58 | + Concepts |
| 59 | + </div> |
| 60 | + <SidebarMenuItem value="introduction" label="Introduction" link="/introduction" /> |
| 61 | + <SidebarMenuItem value="installation" label="Installation" link="/installation" /> |
| 62 | + |
| 63 | + <div |
| 64 | + w-full p="x-10px t-10px b-5px" box-border |
| 65 | + text="default-semibold" |
| 66 | + > |
| 67 | + Components |
| 68 | + </div> |
| 69 | + <SidebarMenuItem |
| 70 | + v-for="item in componentsMenuItems" |
| 71 | + :key="item.value" |
| 72 | + :value="item.value" |
| 73 | + :label="item.label" |
| 74 | + :link="item.link" |
| 75 | + /> |
| 76 | + </JeFrame> |
| 77 | + </JeFrame> |
| 78 | + |
| 79 | + <div grow h-full p="x-10px" box-border> |
| 80 | + <RouterView /> |
| 81 | + </div> |
| 82 | + </JeFrame> |
| 83 | +</template> |
| 84 | + |
| 85 | +<style lang="scss" scoped> |
| 86 | +.menu-item.active { |
| 87 | + @apply light:bg-$blue-11 dark:bg-$blue-2; |
| 88 | +} |
| 89 | +</style> |
0 commit comments