123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- import { HandlerEnum } from './enum';
- import { updateHeaderBgColor, updateSidebarBgColor } from '@/logics/theme/updateBackground';
- import { updateColorWeak } from '@/logics/theme/updateColorWeak';
- import { updateGrayMode } from '@/logics/theme/updateGrayMode';
- import { useAppStore } from '@/store/modules/app';
- import { ProjectConfig } from '#/config';
- import { updateDarkTheme } from '@/logics/theme/dark';
- import { useRootSetting } from '@/hooks/setting/useRootSetting';
- export function baseHandler(event: HandlerEnum, value: any) {
- const appStore = useAppStore();
- const config = handler(event, value);
- appStore.setProjectConfig(config);
- if (event === HandlerEnum.CHANGE_THEME) {
- updateHeaderBgColor();
- updateSidebarBgColor();
- }
- }
- export function handler(event: HandlerEnum, value: any): DeepPartial<ProjectConfig> {
- const appStore = useAppStore();
- const { getThemeColor, getDarkMode } = useRootSetting();
- switch (event) {
- case HandlerEnum.CHANGE_LAYOUT:
- const { mode, type, split } = value;
- const splitOpt = split === undefined ? { split } : {};
- return {
- menuSetting: {
- mode,
- type,
- collapsed: false,
- show: true,
- hidden: false,
- ...splitOpt,
- },
- };
- case HandlerEnum.CHANGE_THEME_COLOR:
- if (getThemeColor.value === value) {
- return {};
- }
- return { themeColor: value };
- case HandlerEnum.CHANGE_THEME:
- if (getDarkMode.value === value) {
- return {};
- }
- updateDarkTheme(value);
- return {};
- case HandlerEnum.MENU_HAS_DRAG:
- return { menuSetting: { canDrag: value } };
- case HandlerEnum.MENU_ACCORDION:
- return { menuSetting: { accordion: value } };
- case HandlerEnum.MENU_TRIGGER:
- return { menuSetting: { trigger: value } };
- case HandlerEnum.MENU_TOP_ALIGN:
- return { menuSetting: { topMenuAlign: value } };
- case HandlerEnum.MENU_COLLAPSED:
- return { menuSetting: { collapsed: value } };
- case HandlerEnum.MENU_WIDTH:
- return { menuSetting: { menuWidth: value } };
- case HandlerEnum.MENU_SHOW_SIDEBAR:
- return { menuSetting: { show: value } };
- case HandlerEnum.MENU_COLLAPSED_SHOW_TITLE:
- return { menuSetting: { collapsedShowTitle: value } };
- case HandlerEnum.MENU_THEME:
- updateSidebarBgColor(value);
- return { menuSetting: { bgColor: value } };
- case HandlerEnum.MENU_SPLIT:
- return { menuSetting: { split: value } };
- case HandlerEnum.MENU_CLOSE_MIX_SIDEBAR_ON_CHANGE:
- return { menuSetting: { closeMixSidebarOnChange: value } };
- case HandlerEnum.MENU_FIXED:
- return { menuSetting: { fixed: value } };
- case HandlerEnum.MENU_TRIGGER_MIX_SIDEBAR:
- return { menuSetting: { mixSideTrigger: value } };
- case HandlerEnum.MENU_FIXED_MIX_SIDEBAR:
- return { menuSetting: { mixSideFixed: value } };
- // ============transition==================
- case HandlerEnum.OPEN_PAGE_LOADING:
- appStore.setPageLoading(false);
- return { transitionSetting: { openPageLoading: value } };
- case HandlerEnum.ROUTER_TRANSITION:
- return { transitionSetting: { basicTransition: value } };
- case HandlerEnum.OPEN_ROUTE_TRANSITION:
- return { transitionSetting: { enable: value } };
- case HandlerEnum.OPEN_PROGRESS:
- return { transitionSetting: { openNProgress: value } };
- // ============root==================
- case HandlerEnum.LOCK_TIME:
- return { lockTime: value };
- case HandlerEnum.FULL_CONTENT:
- return { fullContent: value };
- case HandlerEnum.CONTENT_MODE:
- return { contentMode: value };
- case HandlerEnum.SHOW_BREADCRUMB:
- return { showBreadCrumb: value };
- case HandlerEnum.SHOW_BREADCRUMB_ICON:
- return { showBreadCrumbIcon: value };
- case HandlerEnum.GRAY_MODE:
- updateGrayMode(value);
- return { grayMode: value };
- case HandlerEnum.SHOW_FOOTER:
- return { showFooter: value };
- case HandlerEnum.COLOR_WEAK:
- updateColorWeak(value);
- return { colorWeak: value };
- case HandlerEnum.SHOW_LOGO:
- return { showLogo: value };
- // ============tabs==================
- case HandlerEnum.TABS_SHOW_QUICK:
- return { multiTabsSetting: { showQuick: value } };
- case HandlerEnum.TABS_SHOW:
- return { multiTabsSetting: { show: value } };
- case HandlerEnum.TABS_SHOW_REDO:
- return { multiTabsSetting: { showRedo: value } };
- case HandlerEnum.TABS_SHOW_FOLD:
- return { multiTabsSetting: { showFold: value } };
- case HandlerEnum.TABS_AUTO_COLLAPSE:
- return { multiTabsSetting: { autoCollapse: value } };
- // ============header==================
- case HandlerEnum.HEADER_THEME:
- updateHeaderBgColor(value);
- return { headerSetting: { bgColor: value } };
- case HandlerEnum.HEADER_SEARCH:
- return { headerSetting: { showSearch: value } };
- case HandlerEnum.HEADER_FIXED:
- return { headerSetting: { fixed: value } };
- case HandlerEnum.HEADER_SHOW:
- return { headerSetting: { show: value } };
- default:
- return {};
- }
- }
|