RightContent.tsx 2.3 KB

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