"src/layouts/UserLayout.tsx" did not exist on "14bed53b07350a27e56a28c24fac05fe92d5308a"
index.js 1.55 KB
Newer Older
jim's avatar
jim committed
1
import React, { PureComponent } from 'react';
zinkey's avatar
zinkey committed
2
import Link from 'umi/link';
jim's avatar
jim committed
3
import RightContent from '../GlobalHeader/RightContent';
Erwin Zhang's avatar
Erwin Zhang committed
4
import BaseMenu from '../SiderMenu/BaseMenu';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
5
import { getFlatMenuKeys } from '../SiderMenu/SiderMenuUtils';
jim's avatar
jim committed
6
import styles from './index.less';
Yu's avatar
Yu committed
7
import { title } from '../../defaultSettings';
jim's avatar
jim committed
8 9

export default class TopNavHeader extends PureComponent {
afc163's avatar
afc163 committed
10 11 12
  state = {
    maxWidth: undefined,
  };
13 14 15

  static getDerivedStateFromProps(props) {
    return {
afc163's avatar
afc163 committed
16
      maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 280 - 165 - 40,
17 18 19
    };
  }

jim's avatar
jim committed
20
  render() {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
21
    const { theme, contentWidth, menuData, logo } = this.props;
22
    const { maxWidth } = this.state;
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
23
    const flatMenuKeys = getFlatMenuKeys(menuData);
jim's avatar
jim committed
24
    return (
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
25
      <div className={`${styles.head} ${theme === 'light' ? styles.light : ''}`}>
26 27 28 29
        <div
          ref={ref => {
            this.maim = ref;
          }}
afc163's avatar
afc163 committed
30
          className={`${styles.main} ${contentWidth === 'Fixed' ? styles.wide : ''}`}
31
        >
jim's avatar
jim committed
32
          <div className={styles.left}>
33
            <div className={styles.logo} key="logo" id="logo">
jim's avatar
jim committed
34
              <Link to="/">
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
35
                <img src={logo} alt="logo" />
Yu's avatar
Yu committed
36
                <h1>{title}</h1>
jim's avatar
jim committed
37 38
              </Link>
            </div>
39 40 41 42 43
            <div
              style={{
                maxWidth,
              }}
            >
44
              <BaseMenu {...this.props} flatMenuKeys={flatMenuKeys} className={styles.menu} />
45
            </div>
jim's avatar
jim committed
46
          </div>
47
          <RightContent {...this.props} />
jim's avatar
jim committed
48 49 50 51 52
        </div>
      </div>
    );
  }
}