RightContent.tsx 2.11 KB
Newer Older
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
1
import { ConnectProps, ConnectState } from '@/models/connect';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
2
import { Icon, Tooltip } from 'antd';
3
import Avatar from './AvatarDropdown';
jim's avatar
jim committed
4
import HeaderSearch from '../HeaderSearch';
5
import React from 'react';
6
import SelectLang from '../SelectLang';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
7
import { connect } from 'dva';
8 9
import { formatMessage } from 'umi-plugin-react/locale';
import styles from './index.less';
duanledexianxianxian's avatar
duanledexianxianxian committed
10
import NoticeIconView from './NoticeIconView';
ι™ˆεΈ…'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
          <Icon type="question-circle-o" />
        </a>
      </Tooltip>
duanledexianxianxian's avatar
duanledexianxianxian committed
65 66
      <NoticeIconView />
      <Avatar menu />
67 68 69 70
      <SelectLang className={styles.action} />
    </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);