import React, { useMemo } from 'react'; import styles from './index.less'; import { isDisplay } from '../utils'; import ToggleButton from './ToggleButton'; import { useConfigService, usePanelService } from '../hooks'; import { AppContent } from '../AppTemplate'; function getStyle( position: string, opened: boolean, panelWidth: string | number, ) { const order = position === 'left' || position === 'top' ? -1 : 1; if (position === 'bottom' || position === 'top') { return { width: '100%', height: opened ? panelWidth : '0px', order, }; } return { order, width: !opened ? '0px' : panelWidth, }; } export default function AppPanel() { const { globalConfig } = useConfigService(); const { siderBarService } = usePanelService(); const { panel } = globalConfig; const panelWidth = useMemo(() => { return panel?.width ?? '360px'; }, [panel?.width]); return isDisplay(panel?.display) ? (
{panel?.enableToggle && ( { siderBarService.toggleOpen(); // setConfig('panel', { // open: !panel.opened, // }) }} /> )} {/* 面板内容 */}
) : ( <> ); }