RightContent.tsx 2.2 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';
duanledexianxianxian's avatar
duanledexianxianxian committed
11
import DefaultSettings from 'config/defaultSettings';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
12

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

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

23 24 25
  if (theme === 'dark' && layout === 'topmenu') {
    className = `${styles.right}  ${styles.dark}`;
  }
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
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 61
  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
62
        >
63 64 65
          <Icon type="question-circle-o" />
        </a>
      </Tooltip>
duanledexianxianxian's avatar
duanledexianxianxian committed
66 67
      <NoticeIconView />
      <Avatar menu />
duanledexianxianxian's avatar
duanledexianxianxian committed
68
      <SelectLang className={styles.action} locales={DefaultSettings.locales} />
69 70 71
    </div>
  );
};
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
72

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