diff --git a/src/components/Application/src/AppLogo.vue b/src/components/Application/src/AppLogo.vue index dbe73a65..cb043bfe 100644 --- a/src/components/Application/src/AppLogo.vue +++ b/src/components/Application/src/AppLogo.vue @@ -3,7 +3,11 @@ * @Description: logo component --> @@ -95,12 +95,16 @@ prefixCls, `justify-${align}`, { + [`${prefixCls}--hide-title`]: !unref(showTitle), + [`${prefixCls}--collapsed-show-title`]: props.collapsedShowTitle, [`${prefixCls}__second`]: !props.isHorizontal && unref(getSplit), [`${prefixCls}__sidebar-hor`]: unref(getIsTopMenu), }, ]; }); + const showTitle = computed(() => props.collapsedShowTitle && unref(getCollapsed)); + const getInlineCollapseOptions = computed(() => { const isInline = props.mode === MenuModeEnum.INLINE; @@ -164,7 +168,7 @@ getMenuClass, handleOpenChange, getOpenKeys, - getCollapsed, + showTitle, ...toRefs(menuState), }; }, diff --git a/src/components/Menu/src/index.less b/src/components/Menu/src/index.less index 626754cd..5cbe4288 100644 --- a/src/components/Menu/src/index.less +++ b/src/components/Menu/src/index.less @@ -48,6 +48,63 @@ opacity: 1 !important; } + &--hide-title { + &.ant-menu-inline-collapsed > .ant-menu-item, + &.ant-menu-inline-collapsed > .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-item, + &.ant-menu-inline-collapsed + > .ant-menu-item-group + > .ant-menu-item-group-list + > .ant-menu-submenu + > .ant-menu-submenu-title, + &.ant-menu-inline-collapsed .ant-menu-submenu-title { + padding-right: 16px !important; + padding-left: 16px !important; + } + } + + &--collapsed-show-title.ant-menu-inline-collapsed { + .@{basic-menu-prefix-cls}-item__level1 { + padding: 2px 0; + justify-content: center !important; + + &.ant-menu-item { + display: flex; + align-items: center; + height: 60px !important; + margin-top: 0 !important; + margin-bottom: 0 !important; + line-height: 60px !important; + + > span { + margin-top: 10px; + } + } + } + + & > li[role='menuitem']:not(.ant-menu-submenu), + & > li > .ant-menu-submenu-title { + display: flex; + margin-top: 10px; + font-size: 12px; + flex-direction: column; + align-items: center; + line-height: 24px; + } + + & > li > .ant-menu-submenu-title { + line-height: 24px; + } + .@{basic-menu-content-prefix-cls}-wrapper { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + .@{basic-menu-content-prefix-cls}--show-title { + line-height: 30px; + } + } + } + &.ant-menu-inline-collapsed > .ant-menu-item, &.ant-menu-inline-collapsed > .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-item, &.ant-menu-inline-collapsed @@ -62,6 +119,7 @@ .@{basic-menu-content-prefix-cls}-wrapper { width: 100%; + margin-top: 4px; &__icon { vertical-align: text-top; @@ -181,7 +239,20 @@ &.ant-menu-inline-collapsed { .ant-menu-submenu-selected, .ant-menu-item-selected { + position: relative; + font-weight: 500; + color: @white; background: @sider-dark-darken-bg-color !important; + + &::before { + position: absolute; + top: 0; + left: 0; + width: 3px; + height: 100%; + background: @primary-color; + content: ''; + } } } } diff --git a/src/components/Menu/src/props.ts b/src/components/Menu/src/props.ts index 2becdbd0..ca2444ab 100644 --- a/src/components/Menu/src/props.ts +++ b/src/components/Menu/src/props.ts @@ -9,7 +9,7 @@ export const basicProps = { type: Array as PropType, default: () => [], }, - + collapsedShowTitle: propTypes.bool, // 最好是4 倍数 inlineIndent: propTypes.number.def(20), // 菜单组件的mode属性 diff --git a/src/hooks/setting/useMenuSetting.ts b/src/hooks/setting/useMenuSetting.ts index 5badadb5..ae393ce6 100644 --- a/src/hooks/setting/useMenuSetting.ts +++ b/src/hooks/setting/useMenuSetting.ts @@ -45,6 +45,8 @@ const getIsSidebarType = computed(() => unref(getMenuType) === MenuTypeEnum.SIDE const getIsTopMenu = computed(() => unref(getMenuType) === MenuTypeEnum.TOP_MENU); +const getCollapsedShowTitle = computed(() => unref(getMenuSetting).collapsedShowTitle); + const getShowTopMenu = computed(() => { return unref(getMenuMode) === MenuModeEnum.HORIZONTAL || unref(getSplit); }); @@ -74,7 +76,8 @@ const getRealWidth = computed(() => { }); const getMiniWidthNumber = computed(() => { - return SIDE_BAR_MINI_WIDTH; + const { collapsedShowTitle } = unref(getMenuSetting); + return collapsedShowTitle ? SIDE_BAR_SHOW_TIT_MINI_WIDTH : SIDE_BAR_MINI_WIDTH; }); const getCalcContentWidth = computed(() => { @@ -128,6 +131,7 @@ export function useMenuSetting() { getSplit, getMenuTheme, getCanDrag, + getCollapsedShowTitle, getIsHorizontal, getIsSidebarType, getAccordion, diff --git a/src/layouts/default/index.vue b/src/layouts/default/index.vue index e3f903a3..c686c8ac 100644 --- a/src/layouts/default/index.vue +++ b/src/layouts/default/index.vue @@ -2,7 +2,11 @@ - + diff --git a/src/layouts/default/menu/index.tsx b/src/layouts/default/menu/index.tsx index 12d4a34a..3c252727 100644 --- a/src/layouts/default/menu/index.tsx +++ b/src/layouts/default/menu/index.tsx @@ -45,6 +45,7 @@ export default defineComponent({ getMenuType, getMenuTheme, getCollapsed, + getCollapsedShowTitle, getAccordion, getIsHorizontal, getIsSidebarType, @@ -130,6 +131,8 @@ export default defineComponent({ beforeClickFn={beforeMenuClickFn} isHorizontal={props.isHorizontal} type={unref(getMenuType)} + collapsedShowTitle={unref(getCollapsedShowTitle)} + showLogo={unref(getIsShowLogo)} mode={unref(getComputedMenuMode)} theme={unref(getComputedMenuTheme)} items={unref(menusRef)} diff --git a/src/layouts/default/setting/SettingDrawer.tsx b/src/layouts/default/setting/SettingDrawer.tsx index 9637801c..f78634ff 100644 --- a/src/layouts/default/setting/SettingDrawer.tsx +++ b/src/layouts/default/setting/SettingDrawer.tsx @@ -61,6 +61,7 @@ export default defineComponent({ getShowMenu, getMenuType, getTrigger, + getCollapsedShowTitle, getMenuFixed, getCollapsed, getCanDrag, @@ -176,6 +177,12 @@ export default defineComponent({ def={unref(getCollapsed)} disabled={!unref(getShowMenuRef) || unref(getIsMixSidebar)} /> + .scroll-container { - border-right: 1px solid rgb(114 114 114); + border-right: 1px solid @border-color; } } .@{prefix-cls}-menu-list { @@ -284,7 +285,7 @@ &__title { color: @white; border-bottom: none; - border-bottom: 1px solid rgb(114 114 114); + border-bottom: 1px solid @border-color; } } } diff --git a/src/locales/lang/en/layout/setting.ts b/src/locales/lang/en/layout/setting.ts index db14636c..43f69728 100644 --- a/src/locales/lang/en/layout/setting.ts +++ b/src/locales/lang/en/layout/setting.ts @@ -45,6 +45,7 @@ export default { menuSearch: 'Menu search', menuAccordion: 'Sidebar accordion', menuCollapse: 'Collapse menu', + collapseMenuDisplayName: 'Collapse menu display name', topMenuLayout: 'Top menu layout', menuCollapseButton: 'Menu collapse button', contentMode: 'Content area width', diff --git a/src/locales/lang/zh_CN/layout/setting.ts b/src/locales/lang/zh_CN/layout/setting.ts index d0154bcd..57409008 100644 --- a/src/locales/lang/zh_CN/layout/setting.ts +++ b/src/locales/lang/zh_CN/layout/setting.ts @@ -44,6 +44,7 @@ export default { menuSearch: '菜单搜索', menuAccordion: '侧边菜单手风琴模式', menuCollapse: '折叠菜单', + collapseMenuDisplayName: '折叠菜单显示名称', topMenuLayout: '顶部菜单布局', menuCollapseButton: '菜单折叠按钮', contentMode: '内容区域宽度', diff --git a/src/settings/projectSetting.ts b/src/settings/projectSetting.ts index 0124fe3e..839d43ae 100644 --- a/src/settings/projectSetting.ts +++ b/src/settings/projectSetting.ts @@ -81,6 +81,8 @@ const setting: ProjectConfig = { fixed: true, // Menu collapse collapsed: false, + // Whether to display the menu name when folding the menu + collapsedShowTitle: false, // Whether it can be dragged // Only limited to the opening of the left menu, the mouse has a drag bar on the right side of the menu canDrag: true, diff --git a/src/types/config.d.ts b/src/types/config.d.ts index 3e1e7dd8..b578a695 100644 --- a/src/types/config.d.ts +++ b/src/types/config.d.ts @@ -19,6 +19,7 @@ export interface MenuSetting { trigger: TriggerEnum; accordion: boolean; closeMixSidebarOnChange: boolean; + collapsedShowTitle: boolean; } export interface MultiTabsSetting {