Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

feat: 左侧混合菜单模式 #34

Merged
merged 36 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8679c3b
perf: Header样式调整
hormers Nov 17, 2022
e743d6a
feat: 新增IconWrapper,El组件
hormers Nov 18, 2022
f98e36c
perf: LayoutHeader,LayoutSider样式调整,适配dark模式
hormers Nov 18, 2022
3b9f71e
perf: 固定头部
hormers Nov 18, 2022
99a192e
Merge branch 'jinmao88:master' into master
hormers Nov 18, 2022
4dbef38
Merge branch 'jinmao88:master' into master
hormers Nov 22, 2022
c02e223
wip: 项目配置
hormers Nov 22, 2022
3625ed3
Merge remote-tracking branch 'origin/master'
hormers Nov 22, 2022
28171ca
Merge remote-tracking branch 'origin/master'
hormers Nov 23, 2022
6022047
fix: 修复menuSetting属性设置错误
hormers Nov 23, 2022
4bc7772
wip: 项目配置组件
hormers Nov 23, 2022
efed8cb
feat: 项目配置组件,配置主题,界面布局属性
hormers Nov 24, 2022
27e53c5
feat: 增加拷贝,重置,清空缓存方法
hormers Nov 24, 2022
a04c694
Merge branch 'jinmao88:master' into master
hormers Nov 24, 2022
44aa7a0
fix: 项目配置项错误问题
hormers Nov 25, 2022
1cb3549
fix: useMenuSearch报错
hormers Nov 25, 2022
f72abbc
Merge branch 'jinmao88:master' into master
hormers Nov 26, 2022
048de0c
perf: 登录表单适配Dark模式
hormers Nov 26, 2022
af95179
Merge branch 'jinmao88:master' into master
hormers Nov 26, 2022
0cbf300
Merge branch 'jinmao88:master' into master
hormers Nov 26, 2022
48fb1e3
Merge branch 'jinmao88:master' into master
hormers Nov 27, 2022
4e41a49
Merge branch 'jinmao88:master' into master
hormers Dec 3, 2022
bc5d674
wip: 锁屏
hormers Dec 4, 2022
0b6ade4
wip: 自动锁屏
hormers Dec 5, 2022
6528bc1
Merge branch 'jinmao88:master' into master
hormers Dec 16, 2022
a0b9753
fix: 修复 run dev 报错
hormers Dec 16, 2022
16702e9
feat: 锁屏
hormers Dec 16, 2022
522adfc
Merge branch 'jinmao88:master' into master
hormers Dec 18, 2022
870a5d8
perf: 顶部菜单混合模式logo样式
hormers Dec 20, 2022
2423327
wip: 左侧混合菜单模式
hormers Dec 20, 2022
b99fafe
Merge branch 'jinmao88:master' into master
hormers Dec 21, 2022
44655a4
wip: 左侧混合菜单
hormers Dec 26, 2022
497370d
feat: 左侧混合菜单模式
hormers Dec 27, 2022
bf6eaff
Merge branch 'vbenjs:master' into master
hormers Dec 27, 2022
d914c47
Merge remote-tracking branch 'origin/master'
hormers Dec 27, 2022
57299d6
fix: 优化交互体验
hormers Dec 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/admin/src/init-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import { localeList } from '@vben/locale/src/config'
import { useRootSetting } from '@/hooks/setting/useRootSetting'
import { useTransitionSetting } from '@/hooks/setting/useTransitionSetting'
import { useHeaderSetting } from '@/hooks/setting/useHeaderSetting'
import { getAllParentPath, getMenus } from '@/router'
import {
getAllParentPath,
getChildrenMenus,
getCurrentParentPath,
getMenus,
getShallowMenus
} from '@/router'
import { useDesign } from '@/hooks/web/useDesign'
import { useAppInject } from '@/hooks/web/use-app-inject'
import { useTabs } from '@/hooks/useTabs'
Expand Down Expand Up @@ -81,6 +87,9 @@ async function initPackages() {
return {
useRootSetting,
getMenus,
getCurrentParentPath,
getShallowMenus,
getChildrenMenus,
getAllParentPath,
useHeaderSetting,
useDesign,
Expand Down
1 change: 1 addition & 0 deletions apps/admin/src/layout/components/logo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function goHome() {
transition: all 0.2s ease;
height: 48px;
background: transparent;
box-sizing: border-box;

&__title {
font-size: 16px;
Expand Down
6 changes: 6 additions & 0 deletions packages/layouts/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export interface ContextOptions {
usePromise: (fn: Function, config?: unknown) => unknown
useDesign: (scope: string) => unknown
getMenus: () => Promise<any>
getCurrentParentPath: (currentPath: string) => Promise<any>
getShallowMenus: () => Promise<any>
getChildrenMenus: (parentPath: string) => Promise<any>
getAllParentPath: (menu, path) => string[]
Logo: VNode | null
}
Expand All @@ -43,6 +46,9 @@ export let context: ContextOptions = {
useTabs: () => undefined,
useDesign: (scope: string) => undefined,
getMenus: async () => ({}),
getCurrentParentPath: async (currentPath: string) => ({}),
getShallowMenus: async () => ({}),
getChildrenMenus: async (parentPath: string) => ({}),
getAllParentPath: (menu, path) => [],
Logo: null,
}
Expand Down
3 changes: 2 additions & 1 deletion packages/layouts/src/components/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const {
getShowNotice,
} = useHeaderSetting()
const { getSettingButtonPosition, getShowSettingButton } = useRootSetting()
const { getMenuType } = useMenuSetting()
const { getMenuType, getMenuWidth } = useMenuSetting()
const shadowColor = computed(() =>
isDark.value ? 'rgb(255, 255, 255, 0.09)' : 'rgb(239, 239, 245)',
)
Expand Down Expand Up @@ -64,6 +64,7 @@ const getShowSetting = computed(() => {
getMenuType === MenuTypeEnum.TOP_MENU ||
getMenuType === MenuTypeEnum.MIX
"
:style="{width: getMenuWidth + 'px', maxWidth: getMenuWidth + 'px'}"
/>
<slot name="breadcrumb">
<LayoutBreadcrumb
Expand Down
111 changes: 111 additions & 0 deletions packages/layouts/src/components/menu/mix-menu.vue
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>
Loading