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

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

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

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

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