This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* perf: Header样式调整 * feat: 新增IconWrapper,El组件 * perf: LayoutHeader,LayoutSider样式调整,适配dark模式 * perf: 固定头部 * wip: 项目配置 * fix: 修复menuSetting属性设置错误 * wip: 项目配置组件 * feat: 项目配置组件,配置主题,界面布局属性 * feat: 增加拷贝,重置,清空缓存方法 * fix: 项目配置项错误问题 * fix: useMenuSearch报错 * perf: 登录表单适配Dark模式 * wip: 锁屏 * wip: 自动锁屏 * fix: 修复 run dev 报错 * feat: 锁屏 * perf: 顶部菜单混合模式logo样式 * wip: 左侧混合菜单模式 * wip: 左侧混合菜单 * feat: 左侧混合菜单模式 * fix: 优化交互体验
- Loading branch information
Showing
15 changed files
with
2,121 additions
and
3,759 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<script lang="ts" setup> | ||
import {ref, h, unref, nextTick, computed} from 'vue' | ||
import { createNamespace, mapTree } from '@vben/utils' | ||
import { VbenIconify } from '@vben/vbencomponents' | ||
import { context } from '../../../bridge' | ||
const { listenerRouteChange } = context | ||
import { | ||
RouteLocationNormalizedLoaded, | ||
RouterLink, | ||
useRouter, | ||
} from 'vue-router' | ||
import { useI18n } from '@vben/locale' | ||
import { REDIRECT_NAME } from '@vben/constants' | ||
const props = defineProps({ | ||
list: { | ||
type: Array, | ||
default: ()=>[], | ||
}, | ||
}) | ||
const { bem } = createNamespace('layout-menu') | ||
// const collapsed = ref(false) | ||
const { t } = useI18n() | ||
const { currentRoute } = useRouter() | ||
const menuRef = ref(null) | ||
const activeKey = ref() | ||
// 定位菜单选择 与 当前路由匹配 | ||
const showOption = () => { | ||
nextTick(() => { | ||
if (!menuRef.value) return | ||
menuRef.value.Ref.showOption() | ||
}) | ||
} | ||
const menuList = computed(()=>{ | ||
return mapTree(props.list, { conversion: (menu) => routerToMenu(menu) }) | ||
}) | ||
listenerRouteChange((route) => { | ||
if (route.name === REDIRECT_NAME) return | ||
const currentActiveMenu = route.meta?.currentActiveMenu as string | ||
handleMenuChange(route) | ||
if (currentActiveMenu) { | ||
activeKey.value = currentActiveMenu | ||
} | ||
showOption() | ||
}) | ||
async function handleMenuChange(route?: RouteLocationNormalizedLoaded) { | ||
const menu = route || unref(currentRoute) | ||
activeKey.value = menu.name | ||
} | ||
// 路由格式化 | ||
const routerToMenu = (item: RouteRecordItem) => { | ||
const { name, children, meta, icon } = item | ||
const title = t(meta.title as string) | ||
return { | ||
label: () => { | ||
if (children) { | ||
return title | ||
} | ||
return h( | ||
RouterLink, | ||
{ | ||
to: { | ||
name, | ||
}, | ||
}, | ||
{ default: () => title }, | ||
) | ||
}, | ||
key: name, | ||
icon: renderIcon(icon), | ||
} | ||
} | ||
function renderIcon(icon: string) { | ||
return () => h(VbenIconify, { icon }) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div :class="bem()"> | ||
<VbenScrollbar :class="bem('scrollbar')"> | ||
<VbenMenu | ||
v-model:value="activeKey" | ||
:options="menuList" | ||
:collapsed-width="48" | ||
:collapsed="false" | ||
:collapsed-icon-size="22" | ||
:indent="18" | ||
:root-indent="18" | ||
ref="menuRef" | ||
/> | ||
</VbenScrollbar> | ||
</div> | ||
</template> | ||
|
||
<style lang="less" scoped> | ||
.layout-menu { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
&__scrollbar { | ||
flex: 1; | ||
flex-basis: auto; | ||
} | ||
} | ||
</style> |
Oops, something went wrong.