Commit f69aaeab5e6e78a638601cc63c22072847b3204d

Authored by vben
1 parent bd7b53f1

chore: fix layout style

src/components/Application/src/AppLogo.vue
... ... @@ -3,7 +3,11 @@
3 3 * @Description: logo component
4 4 -->
5 5 <template>
6   - <div class="anticon" :class="[prefixCls, theme]" @click="handleGoHome">
  6 + <div
  7 + class="anticon"
  8 + :class="[prefixCls, theme, { 'collapsed-show-title': getCollapsedShowTitle }]"
  9 + @click="handleGoHome"
  10 + >
7 11 <img src="/@/assets/images/logo.png" />
8 12 <div class="ml-2 ellipsis" :class="[`${prefixCls}__title`]" v-show="showTitle">
9 13 {{ title }}
... ... @@ -35,6 +39,7 @@
35 39 },
36 40 setup() {
37 41 const { prefixCls } = useDesign('app-logo');
  42 + const { getCollapsedShowTitle } = useMenuSetting();
38 43  
39 44 const { title } = useGlobSetting();
40 45  
... ... @@ -48,6 +53,7 @@
48 53 handleGoHome,
49 54 title,
50 55 prefixCls,
  56 + getCollapsedShowTitle,
51 57 };
52 58 },
53 59 });
... ... @@ -67,6 +73,10 @@
67 73 border-bottom: 1px solid @border-color-base;
68 74 }
69 75  
  76 + &.collapsed-show-title {
  77 + padding-left: 20px;
  78 + }
  79 +
70 80 &.light &__title {
71 81 color: @primary-color;
72 82 }
... ...
src/components/Menu/src/BasicMenu.vue
... ... @@ -17,7 +17,7 @@
17 17 :item="item"
18 18 :theme="theme"
19 19 :level="1"
20   - :showTitle="!getCollapsed"
  20 + :showTitle="showTitle"
21 21 :isHorizontal="isHorizontal"
22 22 />
23 23 </template>
... ... @@ -95,12 +95,16 @@
95 95 prefixCls,
96 96 `justify-${align}`,
97 97 {
  98 + [`${prefixCls}--hide-title`]: !unref(showTitle),
  99 + [`${prefixCls}--collapsed-show-title`]: props.collapsedShowTitle,
98 100 [`${prefixCls}__second`]: !props.isHorizontal && unref(getSplit),
99 101 [`${prefixCls}__sidebar-hor`]: unref(getIsTopMenu),
100 102 },
101 103 ];
102 104 });
103 105  
  106 + const showTitle = computed(() => props.collapsedShowTitle && unref(getCollapsed));
  107 +
104 108 const getInlineCollapseOptions = computed(() => {
105 109 const isInline = props.mode === MenuModeEnum.INLINE;
106 110  
... ... @@ -164,7 +168,7 @@
164 168 getMenuClass,
165 169 handleOpenChange,
166 170 getOpenKeys,
167   - getCollapsed,
  171 + showTitle,
168 172 ...toRefs(menuState),
169 173 };
170 174 },
... ...
src/components/Menu/src/index.less
... ... @@ -48,6 +48,63 @@
48 48 opacity: 1 !important;
49 49 }
50 50  
  51 + &--hide-title {
  52 + &.ant-menu-inline-collapsed > .ant-menu-item,
  53 + &.ant-menu-inline-collapsed > .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-item,
  54 + &.ant-menu-inline-collapsed
  55 + > .ant-menu-item-group
  56 + > .ant-menu-item-group-list
  57 + > .ant-menu-submenu
  58 + > .ant-menu-submenu-title,
  59 + &.ant-menu-inline-collapsed .ant-menu-submenu-title {
  60 + padding-right: 16px !important;
  61 + padding-left: 16px !important;
  62 + }
  63 + }
  64 +
  65 + &--collapsed-show-title.ant-menu-inline-collapsed {
  66 + .@{basic-menu-prefix-cls}-item__level1 {
  67 + padding: 2px 0;
  68 + justify-content: center !important;
  69 +
  70 + &.ant-menu-item {
  71 + display: flex;
  72 + align-items: center;
  73 + height: 60px !important;
  74 + margin-top: 0 !important;
  75 + margin-bottom: 0 !important;
  76 + line-height: 60px !important;
  77 +
  78 + > span {
  79 + margin-top: 10px;
  80 + }
  81 + }
  82 + }
  83 +
  84 + & > li[role='menuitem']:not(.ant-menu-submenu),
  85 + & > li > .ant-menu-submenu-title {
  86 + display: flex;
  87 + margin-top: 10px;
  88 + font-size: 12px;
  89 + flex-direction: column;
  90 + align-items: center;
  91 + line-height: 24px;
  92 + }
  93 +
  94 + & > li > .ant-menu-submenu-title {
  95 + line-height: 24px;
  96 + }
  97 + .@{basic-menu-content-prefix-cls}-wrapper {
  98 + display: flex;
  99 + justify-content: center;
  100 + align-items: center;
  101 + flex-direction: column;
  102 + .@{basic-menu-content-prefix-cls}--show-title {
  103 + line-height: 30px;
  104 + }
  105 + }
  106 + }
  107 +
51 108 &.ant-menu-inline-collapsed > .ant-menu-item,
52 109 &.ant-menu-inline-collapsed > .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-item,
53 110 &.ant-menu-inline-collapsed
... ... @@ -62,6 +119,7 @@
62 119  
63 120 .@{basic-menu-content-prefix-cls}-wrapper {
64 121 width: 100%;
  122 + margin-top: 4px;
65 123  
66 124 &__icon {
67 125 vertical-align: text-top;
... ... @@ -181,7 +239,20 @@
181 239 &.ant-menu-inline-collapsed {
182 240 .ant-menu-submenu-selected,
183 241 .ant-menu-item-selected {
  242 + position: relative;
  243 + font-weight: 500;
  244 + color: @white;
184 245 background: @sider-dark-darken-bg-color !important;
  246 +
  247 + &::before {
  248 + position: absolute;
  249 + top: 0;
  250 + left: 0;
  251 + width: 3px;
  252 + height: 100%;
  253 + background: @primary-color;
  254 + content: '';
  255 + }
185 256 }
186 257 }
187 258 }
... ...
src/components/Menu/src/props.ts
... ... @@ -9,7 +9,7 @@ export const basicProps = {
9 9 type: Array as PropType<Menu[]>,
10 10 default: () => [],
11 11 },
12   -
  12 + collapsedShowTitle: propTypes.bool,
13 13 // 最好是4 倍数
14 14 inlineIndent: propTypes.number.def(20),
15 15 // 菜单组件的mode属性
... ...
src/hooks/setting/useMenuSetting.ts
... ... @@ -45,6 +45,8 @@ const getIsSidebarType = computed(() =&gt; unref(getMenuType) === MenuTypeEnum.SIDE
45 45  
46 46 const getIsTopMenu = computed(() => unref(getMenuType) === MenuTypeEnum.TOP_MENU);
47 47  
  48 +const getCollapsedShowTitle = computed(() => unref(getMenuSetting).collapsedShowTitle);
  49 +
48 50 const getShowTopMenu = computed(() => {
49 51 return unref(getMenuMode) === MenuModeEnum.HORIZONTAL || unref(getSplit);
50 52 });
... ... @@ -74,7 +76,8 @@ const getRealWidth = computed(() =&gt; {
74 76 });
75 77  
76 78 const getMiniWidthNumber = computed(() => {
77   - return SIDE_BAR_MINI_WIDTH;
  79 + const { collapsedShowTitle } = unref(getMenuSetting);
  80 + return collapsedShowTitle ? SIDE_BAR_SHOW_TIT_MINI_WIDTH : SIDE_BAR_MINI_WIDTH;
78 81 });
79 82  
80 83 const getCalcContentWidth = computed(() => {
... ... @@ -128,6 +131,7 @@ export function useMenuSetting() {
128 131 getSplit,
129 132 getMenuTheme,
130 133 getCanDrag,
  134 + getCollapsedShowTitle,
131 135 getIsHorizontal,
132 136 getIsSidebarType,
133 137 getAccordion,
... ...
src/layouts/default/index.vue
... ... @@ -2,7 +2,11 @@
2 2 <Layout :class="prefixCls">
3 3 <LayoutFeatures />
4 4 <LayoutHeader fixed v-if="getShowFullHeaderRef" />
5   - <Layout class="ant-layout-has-sider">
  5 + <Layout
  6 + :class="{
  7 + 'ant-layout-has-sider': getIsMixSidebar,
  8 + }"
  9 + >
6 10 <LayoutSideBar v-if="getShowSidebar || getIsMobile" />
7 11 <Layout :class="`${prefixCls}__main`">
8 12 <LayoutMultipleHeader />
... ...
src/layouts/default/menu/index.tsx
... ... @@ -45,6 +45,7 @@ export default defineComponent({
45 45 getMenuType,
46 46 getMenuTheme,
47 47 getCollapsed,
  48 + getCollapsedShowTitle,
48 49 getAccordion,
49 50 getIsHorizontal,
50 51 getIsSidebarType,
... ... @@ -130,6 +131,8 @@ export default defineComponent({
130 131 beforeClickFn={beforeMenuClickFn}
131 132 isHorizontal={props.isHorizontal}
132 133 type={unref(getMenuType)}
  134 + collapsedShowTitle={unref(getCollapsedShowTitle)}
  135 + showLogo={unref(getIsShowLogo)}
133 136 mode={unref(getComputedMenuMode)}
134 137 theme={unref(getComputedMenuTheme)}
135 138 items={unref(menusRef)}
... ...
src/layouts/default/setting/SettingDrawer.tsx
... ... @@ -61,6 +61,7 @@ export default defineComponent({
61 61 getShowMenu,
62 62 getMenuType,
63 63 getTrigger,
  64 + getCollapsedShowTitle,
64 65 getMenuFixed,
65 66 getCollapsed,
66 67 getCanDrag,
... ... @@ -176,6 +177,12 @@ export default defineComponent({
176 177 def={unref(getCollapsed)}
177 178 disabled={!unref(getShowMenuRef) || unref(getIsMixSidebar)}
178 179 />
  180 + <SwitchItem
  181 + title={t('layout.setting.collapseMenuDisplayName')}
  182 + event={HandlerEnum.MENU_COLLAPSED_SHOW_TITLE}
  183 + def={unref(getCollapsedShowTitle)}
  184 + disabled={!unref(getShowMenuRef) || !unref(getCollapsed)}
  185 + />
179 186  
180 187 <SwitchItem
181 188 title={t('layout.setting.fixedHeader')}
... ...
src/layouts/default/setting/handler.ts
... ... @@ -51,12 +51,16 @@ export function handler(event: HandlerEnum, value: any): DeepPartial&lt;ProjectConf
51 51 case HandlerEnum.MENU_SHOW_SIDEBAR:
52 52 return { menuSetting: { show: value } };
53 53  
  54 + case HandlerEnum.MENU_COLLAPSED_SHOW_TITLE:
  55 + return { menuSetting: { collapsedShowTitle: value } };
  56 +
54 57 case HandlerEnum.MENU_THEME:
55 58 updateSidebarBgColor(value);
56 59 return { menuSetting: { bgColor: value } };
57 60  
58 61 case HandlerEnum.MENU_SPLIT:
59   - return { menuSetting: { split: value } };
  62 + return { menuSetting: { split: value, collapsedShowTitle: true } };
  63 +
60 64 case HandlerEnum.MENU_CLOSE_MIX_SIDEBAR_ON_CHANGE:
61 65 return { menuSetting: { closeMixSidebarOnChange: value } };
62 66  
... ...
src/layouts/default/sider/MixSider.vue
... ... @@ -267,15 +267,16 @@
267 267 }
268 268 }
269 269 }
  270 + @border-color: @sider-dark-lighten-1-bg-color;
270 271  
271 272 &.dark {
272 273 &.open {
273 274 .@{prefix-cls}-logo {
274   - border-bottom: 1px solid rgb(114 114 114);
  275 + border-bottom: 1px solid @border-color;
275 276 }
276 277  
277 278 > .scroll-container {
278   - border-right: 1px solid rgb(114 114 114);
  279 + border-right: 1px solid @border-color;
279 280 }
280 281 }
281 282 .@{prefix-cls}-menu-list {
... ... @@ -284,7 +285,7 @@
284 285 &__title {
285 286 color: @white;
286 287 border-bottom: none;
287   - border-bottom: 1px solid rgb(114 114 114);
  288 + border-bottom: 1px solid @border-color;
288 289 }
289 290 }
290 291 }
... ...
src/locales/lang/en/layout/setting.ts
... ... @@ -45,6 +45,7 @@ export default {
45 45 menuSearch: 'Menu search',
46 46 menuAccordion: 'Sidebar accordion',
47 47 menuCollapse: 'Collapse menu',
  48 + collapseMenuDisplayName: 'Collapse menu display name',
48 49 topMenuLayout: 'Top menu layout',
49 50 menuCollapseButton: 'Menu collapse button',
50 51 contentMode: 'Content area width',
... ...
src/locales/lang/zh_CN/layout/setting.ts
... ... @@ -44,6 +44,7 @@ export default {
44 44 menuSearch: '菜单搜索',
45 45 menuAccordion: '侧边菜单手风琴模式',
46 46 menuCollapse: '折叠菜单',
  47 + collapseMenuDisplayName: '折叠菜单显示名称',
47 48 topMenuLayout: '顶部菜单布局',
48 49 menuCollapseButton: '菜单折叠按钮',
49 50 contentMode: '内容区域宽度',
... ...
src/settings/projectSetting.ts
... ... @@ -81,6 +81,8 @@ const setting: ProjectConfig = {
81 81 fixed: true,
82 82 // Menu collapse
83 83 collapsed: false,
  84 + // Whether to display the menu name when folding the menu
  85 + collapsedShowTitle: false,
84 86 // Whether it can be dragged
85 87 // Only limited to the opening of the left menu, the mouse has a drag bar on the right side of the menu
86 88 canDrag: true,
... ...
src/types/config.d.ts
... ... @@ -19,6 +19,7 @@ export interface MenuSetting {
19 19 trigger: TriggerEnum;
20 20 accordion: boolean;
21 21 closeMixSidebarOnChange: boolean;
  22 + collapsedShowTitle: boolean;
22 23 }
23 24  
24 25 export interface MultiTabsSetting {
... ...