import { SiderMenuProps } from '@/components/SiderMenu'; import React, { Component } from 'react'; import Link from 'umi/link'; import RightContent, { GlobalHeaderRightProps } from '../GlobalHeader/RightContent'; import BaseMenu from '../SiderMenu/BaseMenu'; import { getFlatMenuKeys } from '../SiderMenu/SiderMenuUtils'; import styles from './index.less'; import defaultSettings, { ContentWidth } from '../../../config/defaultSettings'; export interface TopNavHeaderProps extends SiderMenuProps, GlobalHeaderRightProps { contentWidth?: ContentWidth; } interface TopNavHeaderState { maxWidth?: number; } export default class TopNavHeader extends Component { static getDerivedStateFromProps(props: TopNavHeaderProps) { return { maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 280 - 165 - 40, }; } state: TopNavHeaderState = {}; maim: HTMLDivElement | null = null; render() { const { theme, contentWidth, menuData, logo } = this.props; const { maxWidth } = this.state; const flatMenuKeys = getFlatMenuKeys(menuData); return (
(this.maim = ref)} className={`${styles.main} ${contentWidth === 'Fixed' ? styles.wide : ''}`} >
); } }