RightContent.tsx 2.23 KB
Newer Older
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
1
import { ConnectProps, ConnectState } from '@/models/connect';
2
import React, { Component } from 'react';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
3 4
import { Icon, Tooltip } from 'antd';
import { formatMessage } from 'umi-plugin-react/locale';
jim's avatar
jim committed
5
import HeaderSearch from '../HeaderSearch';
6
import SelectLang from '../SelectLang';
jim's avatar
jim committed
7
import styles from './index.less';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
8
import Avatar from './AvatarDropdown';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
9
import { connect } from 'dva';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
10

何乐's avatar
何乐 committed
11 12
export type SiderTheme = 'light' | 'dark';
export interface GlobalHeaderRightProps extends ConnectProps {
13
  theme?: SiderTheme;
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
14
  layout: 'sidemenu' | 'topmenu';
15
}
何乐's avatar
何乐 committed
16

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
17
class GlobalHeaderRight extends Component<GlobalHeaderRightProps> {
jim's avatar
jim committed
18
  render() {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
19
    const { theme, layout } = this.props;
jim's avatar
jim committed
20
    let className = styles.right;
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
21 22

    if (theme === 'dark' && layout === 'topmenu') {
jim's avatar
jim committed
23
      className = `${styles.right}  ${styles.dark}`;
jim's avatar
jim committed
24
    }
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
25

jim's avatar
jim committed
26
    return (
jim's avatar
jim committed
27
      <div className={className}>
jim's avatar
jim committed
28 29
        <HeaderSearch
          className={`${styles.action} ${styles.search}`}
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
30 31 32
          placeholder={formatMessage({
            id: 'component.globalHeader.search',
          })}
33
          dataSource={[
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
34 35 36 37 38 39 40 41 42
            formatMessage({
              id: 'component.globalHeader.search.example1',
            }),
            formatMessage({
              id: 'component.globalHeader.search.example2',
            }),
            formatMessage({
              id: 'component.globalHeader.search.example3',
            }),
43
          ]}
jim's avatar
jim committed
44
          onSearch={value => {
何乐's avatar
何乐 committed
45
            console.log('input', value); // tslint:disable-line no-console
jim's avatar
jim committed
46
          }}
jim's avatar
jim committed
47
          onPressEnter={value => {
何乐's avatar
何乐 committed
48
            console.log('enter', value); // tslint:disable-line no-console
jim's avatar
jim committed
49 50
          }}
        />
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
51 52 53 54 55
        <Tooltip
          title={formatMessage({
            id: 'component.globalHeader.help',
          })}
        >
jim's avatar
jim committed
56 57
          <a
            target="_blank"
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
58
            href="https://pro.ant.design/docs/getting-started"
jim's avatar
jim committed
59 60 61 62 63 64
            rel="noopener noreferrer"
            className={styles.action}
          >
            <Icon type="question-circle-o" />
          </a>
        </Tooltip>
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
65
        <Avatar />
66
        <SelectLang className={styles.action} />
jim's avatar
jim committed
67 68 69 70
      </div>
    );
  }
}
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
71

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
72 73 74
export default connect(({ settings }: ConnectState) => ({
  theme: settings.navTheme,
  layout: settings.layout,
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
75
}))(GlobalHeaderRight);