RightContent.tsx 2.04 KB
Newer Older
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
1
import { ConnectProps, ConnectState } from '@/models/connect';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
2
import { Icon, Tooltip } from 'antd';
3 4

import Avatar from './AvatarDropdown';
jim's avatar
jim committed
5
import HeaderSearch from '../HeaderSearch';
6
import React from 'react';
7
import SelectLang from '../SelectLang';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
8
import { connect } from 'dva';
9 10
import { formatMessage } from 'umi-plugin-react/locale';
import styles from './index.less';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
11

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

18 19 20
const GlobalHeaderRight: React.SFC<GlobalHeaderRightProps> = props => {
  const { theme, layout } = props;
  let className = styles.right;
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
21

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

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