Browse Source

左侧菜单优化

develop
fuguobin 1 year ago
parent
commit
3545b5a269
  1. 4
      src/layout/components/Sidebar/SidebarItem.vue
  2. 15
      src/styles/sidebar.scss
  3. 4
      src/types/auto-imports.d.ts

4
src/layout/components/Sidebar/SidebarItem.vue

@ -1,5 +1,5 @@
<template> <template>
<div v-if="!item.meta || !item.meta.hidden"> <div class="menuItem" v-if="!item.meta || !item.meta.hidden">
<!-- 只包含一个子路由节点的路由 --> <!-- 只包含一个子路由节点的路由 -->
<template v-if="hasOneShowingChild(item.children, item) && <template v-if="hasOneShowingChild(item.children, item) &&
(!onlyOneChild.children || onlyOneChild.noShowingChildren) (!onlyOneChild.children || onlyOneChild.noShowingChildren)
@ -12,7 +12,7 @@
:icon-class="onlyOneChild.meta.icon" :icon-class="onlyOneChild.meta.icon"
/> />
<template #title> <template #title>
{{ translateRouteTitleI18n(onlyOneChild.meta.title) }} <span>{{ translateRouteTitleI18n(onlyOneChild.meta.title) }}</span>
</template> </template>
</el-menu-item> </el-menu-item>
</app-link> </app-link>

15
src/styles/sidebar.scss

@ -49,6 +49,7 @@
.svg-icon { .svg-icon {
display: inline-flex;
margin-right: 16px; margin-right: 16px;
} }
@ -61,6 +62,20 @@
border: none; border: none;
height: 100%; height: 100%;
width: 100% !important; width: 100% !important;
.menuItem {
.el-menu-item,.el-sub-menu__title {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
span {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
}
} }
// menu hover // menu hover

4
src/types/auto-imports.d.ts

@ -5,8 +5,6 @@ declare global {
const ElForm: typeof import('element-plus/es')['ElForm'] const ElForm: typeof import('element-plus/es')['ElForm']
const ElMessage: typeof import('element-plus/es')['ElMessage'] const ElMessage: typeof import('element-plus/es')['ElMessage']
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox'] const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
const ElNotification: typeof import('element-plus/es')['ElNotification']
const NEllipsis: typeof import('naive-ui')['NEllipsis']
const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
const computed: typeof import('vue')['computed'] const computed: typeof import('vue')['computed']
@ -276,8 +274,6 @@ declare module 'vue' {
readonly ElForm: UnwrapRef<typeof import('element-plus/es')['ElForm']> readonly ElForm: UnwrapRef<typeof import('element-plus/es')['ElForm']>
readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']> readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']>
readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']> readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']>
readonly ElNotification: UnwrapRef<typeof import('element-plus/es')['ElNotification']>
readonly NEllipsis: UnwrapRef<typeof import('naive-ui')['NEllipsis']>
readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']> readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']> readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>
readonly computed: UnwrapRef<typeof import('vue')['computed']> readonly computed: UnwrapRef<typeof import('vue')['computed']>

Loading…
Cancel
Save