RightContent.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { Tooltip, Tag } from 'antd';
  2. import type { Settings as ProSettings } from '@ant-design/pro-layout';
  3. import { QuestionCircleOutlined } from '@ant-design/icons';
  4. import React from 'react';
  5. import type { ConnectProps } from 'umi';
  6. import { connect, SelectLang } from 'umi';
  7. import type { ConnectState } from '@/models/connect';
  8. import Avatar from './AvatarDropdown';
  9. import HeaderSearch from '../HeaderSearch';
  10. import styles from './index.less';
  11. export type GlobalHeaderRightProps = {
  12. theme?: ProSettings['navTheme'] | 'realDark';
  13. } & Partial<ConnectProps> &
  14. Partial<ProSettings>;
  15. const ENVTagColor = {
  16. dev: 'orange',
  17. test: 'green',
  18. pre: '#87d068',
  19. };
  20. const GlobalHeaderRight: React.SFC<GlobalHeaderRightProps> = (props) => {
  21. const { theme, layout } = props;
  22. let className = styles.right;
  23. if (theme === 'dark' && layout === 'top') {
  24. className = `${styles.right} ${styles.dark}`;
  25. }
  26. return (
  27. <div className={className}>
  28. <HeaderSearch
  29. className={`${styles.action} ${styles.search}`}
  30. placeholder="Site Search"
  31. defaultValue="umi ui"
  32. options={[
  33. { label: <a href="https://umijs.org/zh/guide/umi-ui.html">umi ui</a>, value: 'umi ui' },
  34. {
  35. label: <a href="next.ant.design">Ant Design</a>,
  36. value: 'Ant Design',
  37. },
  38. {
  39. label: <a href="https://protable.ant.design/">Pro Table</a>,
  40. value: 'Pro Table',
  41. },
  42. {
  43. label: <a href="https://prolayout.ant.design/">Pro Layout</a>,
  44. value: 'Pro Layout',
  45. },
  46. ]}
  47. // onSearch={value => {
  48. // //console.log('input', value);
  49. // }}
  50. />
  51. <Tooltip title="Use documentation">
  52. <a
  53. style={{
  54. color: 'inherit',
  55. }}
  56. target="_blank"
  57. href="https://pro.ant.design/docs/getting-started"
  58. rel="noopener noreferrer"
  59. className={styles.action}
  60. >
  61. <QuestionCircleOutlined />
  62. </a>
  63. </Tooltip>
  64. <Avatar />
  65. {REACT_APP_ENV && (
  66. <span>
  67. <Tag color={ENVTagColor[REACT_APP_ENV]}>{REACT_APP_ENV}</Tag>
  68. </span>
  69. )}
  70. <SelectLang className={styles.action} />
  71. </div>
  72. );
  73. };
  74. export default connect(({ settings }: ConnectState) => ({
  75. theme: settings.navTheme,
  76. layout: settings.layout,
  77. }))(GlobalHeaderRight);