Skip to content

Commit

Permalink
perf(menu): mixSideTrigger setting (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan authored Jan 2, 2021
1 parent af55511 commit e821f4c
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/enums/menuEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ export enum TopMenuAlignEnum {
START = 'start',
END = 'end',
}

export enum MixSidebarTriggerEnum {
HOVER = 'hover',
CLICK = 'click',
}
10 changes: 10 additions & 0 deletions src/layouts/default/setting/SettingDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
getMenuTriggerOptions,
routerTransitionOptions,
menuTypeList,
mixSidebarTriggerOptions,
} from './enum';

import { HEADER_PRESET_BG_COLOR_LIST, SIDE_BAR_BG_COLOR_LIST } from '/@/settings/colorSetting';
Expand Down Expand Up @@ -73,6 +74,7 @@ export default defineComponent({
getSplit,
getIsMixSidebar,
getCloseMixSidebarOnChange,
getMixSideTrigger,
} = useMenuSetting();

const {
Expand Down Expand Up @@ -115,6 +117,14 @@ export default defineComponent({
def={unref(getCloseMixSidebarOnChange)}
disabled={!unref(getIsMixSidebar)}
/>

<SelectItem
title={t('layout.setting.mixSidebarTrigger')}
event={HandlerEnum.MENU_TRIGGER_MIX_SIDEBAR}
def={unref(getMixSideTrigger)}
options={mixSidebarTriggerOptions}
disabled={!unref(getIsMixSidebar)}
/>
</>
);
}
Expand Down
20 changes: 19 additions & 1 deletion src/layouts/default/setting/enum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ContentEnum, RouterTransitionEnum } from '/@/enums/appEnum';
import { MenuModeEnum, MenuTypeEnum, TopMenuAlignEnum, TriggerEnum } from '/@/enums/menuEnum';
import {
MenuModeEnum,
MenuTypeEnum,
TopMenuAlignEnum,
TriggerEnum,
MixSidebarTriggerEnum,
} from '/@/enums/menuEnum';

import { useI18n } from '/@/hooks/web/useI18n';

Expand All @@ -20,6 +26,7 @@ export enum HandlerEnum {
MENU_SPLIT,
MENU_FIXED,
MENU_CLOSE_MIX_SIDEBAR_ON_CHANGE,
MENU_TRIGGER_MIX_SIDEBAR,

// header
HEADER_SHOW,
Expand Down Expand Up @@ -132,3 +139,14 @@ export const menuTypeList = [
type: MenuTypeEnum.MIX_SIDEBAR,
},
];

export const mixSidebarTriggerOptions = [
{
value: MixSidebarTriggerEnum.HOVER,
label: t('layout.setting.triggerHover'),
},
{
value: MixSidebarTriggerEnum.CLICK,
label: t('layout.setting.triggerClick'),
},
];
3 changes: 3 additions & 0 deletions src/layouts/default/setting/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export function handler(event: HandlerEnum, value: any): DeepPartial<ProjectConf
case HandlerEnum.MENU_FIXED:
return { menuSetting: { fixed: value } };

case HandlerEnum.MENU_TRIGGER_MIX_SIDEBAR:
return { menuSetting: { mixSideTrigger: value } };

// ============transition==================
case HandlerEnum.OPEN_PAGE_LOADING:
appStore.commitPageLoadingState(false);
Expand Down
4 changes: 4 additions & 0 deletions src/locales/lang/en/layout/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@ export default {

fixedHeader: 'Fixed header',
fixedSideBar: 'Fixed Sidebar',

mixSidebarTrigger: 'Mixed menu Trigger',
triggerHover: 'Hover',
triggerClick: 'Click',
};
4 changes: 4 additions & 0 deletions src/locales/lang/zh_CN/layout/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ export default {

fixedHeader: '固定header',
fixedSideBar: '固定Sidebar',

mixSidebarTrigger: '混合菜单触发方式',
triggerHover: '悬停',
triggerClick: '点击',
};
4 changes: 2 additions & 2 deletions src/settings/projectSetting.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ProjectConfig } from '/@/types/config';

import { MenuTypeEnum, MenuModeEnum, TriggerEnum } from '/@/enums/menuEnum';
import { MenuTypeEnum, MenuModeEnum, TriggerEnum, MixSidebarTriggerEnum } from '/@/enums/menuEnum';
import { CacheTypeEnum } from '/@/enums/cacheEnum';
import { ContentEnum, PermissionModeEnum, ThemeEnum, RouterTransitionEnum } from '/@/enums/appEnum';
import { primaryColor } from '../../build/config/lessModifyVars';
Expand Down Expand Up @@ -109,7 +109,7 @@ const setting: ProjectConfig = {
// Switch page to close menu
closeMixSidebarOnChange: false,
// Module opening method ‘click’ |'hover'
mixSideTrigger: 'click',
mixSideTrigger: MixSidebarTriggerEnum.CLICK,
},

// Multi-label
Expand Down
4 changes: 2 additions & 2 deletions src/types/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MenuTypeEnum, MenuModeEnum, TriggerEnum } from '/@/enums/menuEnum';
import { MenuTypeEnum, MenuModeEnum, TriggerEnum, MixSidebarTriggerEnum } from '/@/enums/menuEnum';
import { ContentEnum, PermissionModeEnum, ThemeEnum, RouterTransitionEnum } from '/@/enums/appEnum';
import { CacheTypeEnum } from '/@/enums/cacheEnum';
import type { LocaleType } from '/@/locales/types';
Expand All @@ -20,7 +20,7 @@ export interface MenuSetting {
accordion: boolean;
closeMixSidebarOnChange: boolean;
collapsedShowTitle: boolean;
mixSideTrigger: 'click' | 'hover';
mixSideTrigger: MixSidebarTriggerEnum;
}

export interface MultiTabsSetting {
Expand Down

0 comments on commit e821f4c

Please sign in to comment.