RightContent.jsx 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { Icon, Tooltip, Tag } from 'antd';
  2. import React from 'react';
  3. import { connect } from 'dva';
  4. import { formatMessage } from 'umi-plugin-react/locale';
  5. import Avatar from './AvatarDropdown';
  6. import HeaderSearch from '../HeaderSearch';
  7. import SelectLang from '../SelectLang';
  8. import styles from './index.less';
  9. const ENVTagColor = {
  10. dev: 'orange',
  11. test: 'green',
  12. pre: '#87d068',
  13. };
  14. const GlobalHeaderRight = (props) => {
  15. const { theme, layout } = props;
  16. let className = styles.right;
  17. if (theme === 'dark' && layout === 'topmenu') {
  18. className = `${styles.right} ${styles.dark}`;
  19. }
  20. return (
  21. <div className={className}>
  22. <HeaderSearch
  23. className={`${styles.action} ${styles.search}`}
  24. placeholder={formatMessage({
  25. id: 'component.globalHeader.search',
  26. })}
  27. defaultValue="umi ui"
  28. dataSource={[
  29. formatMessage({
  30. id: 'component.globalHeader.search.example1',
  31. }),
  32. formatMessage({
  33. id: 'component.globalHeader.search.example2',
  34. }),
  35. formatMessage({
  36. id: 'component.globalHeader.search.example3',
  37. }),
  38. ]}
  39. onSearch={() => {}}
  40. onPressEnter={() => {}}
  41. />
  42. <Tooltip
  43. title={formatMessage({
  44. id: 'component.globalHeader.help',
  45. })}
  46. >
  47. <a
  48. target="_blank"
  49. href="https://pro.ant.design/docs/getting-started"
  50. rel="noopener noreferrer"
  51. className={styles.action}
  52. >
  53. <Icon type="question-circle-o" />
  54. </a>
  55. </Tooltip>
  56. <Avatar />
  57. {REACT_APP_ENV && <Tag color={ENVTagColor[REACT_APP_ENV]}>{REACT_APP_ENV}</Tag>}
  58. <SelectLang className={styles.action} />
  59. </div>
  60. );
  61. };
  62. export default connect(({ settings }) => ({
  63. theme: settings.navTheme,
  64. layout: settings.layout,
  65. }))(GlobalHeaderRight);