RightContent.js 2.2 KB
Newer Older
张烨's avatar
张烨 committed
1
import React, { useContext, useState } from 'react';
2
import { RouteContext } from '@ant-design/pro-layout';
张烨's avatar
张烨 committed
3 4 5
import { Breadcrumb } from 'antd';
import check from '@/components/Authorized/CheckPermissions';
import { Link } from 'react-router-dom';
dengxiaofeng's avatar
dengxiaofeng committed
6
import HeaderSearch from '../HeaderSearch';
Maofei94's avatar
Maofei94 committed
7
import Colophon from '../Colophon';
dengxiaofeng's avatar
dengxiaofeng committed
8
import Avatar from './AvatarDropdown';
dengxiaofeng's avatar
dengxiaofeng committed
9
import styles from './index.less';
dengxiaofeng's avatar
dengxiaofeng committed
10

张烨's avatar
张烨 committed
11 12 13 14 15 16 17
const routesOptions = route => {
  const buildOption = routeConfig => ({
    label: <Link to={routeConfig.path}>{routeConfig.name}</Link>,
    value: routeConfig.name,
  });
  return route.routes
    .map(r => {
张烨's avatar
张烨 committed
18
      if (r.hideMenu) return null;
张烨's avatar
张烨 committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
      if (r.authority) {
        if (r.routes) {
          return routesOptions(r);
        }
        return check(r.authority, buildOption(r), null);
      }
      if (r.routes) {
        return routesOptions(r);
      }
      return buildOption(r);
    })
    .flat()
    .filter(Boolean);
};

dengxiaofeng's avatar
dengxiaofeng committed
34 35
const GlobalHeaderRight = props => {
  const { theme, layout } = props;
dengxiaofeng's avatar
dengxiaofeng committed
36
  let className = styles.right;
37
  const value = useContext(RouteContext);
张烨's avatar
张烨 committed
38

dengxiaofeng's avatar
dengxiaofeng committed
39
  if (theme === 'dark' && layout === 'top') {
dengxiaofeng's avatar
dengxiaofeng committed
40
    className = `${styles.right}  ${styles.dark}`;
dengxiaofeng's avatar
dengxiaofeng committed
41 42 43 44
  }

  return (
    <div className={className}>
45 46 47
      {/* <span className={styles.left}>{value.title}</span> */}
      <Breadcrumb {...value.breadcrumb} className={styles.lineHeight} />
      <div style={{ flex: 1 }} />
Maofei94's avatar
Maofei94 committed
48
      <Colophon />
49 50 51 52 53 54 55 56 57 58
      <div style={{ margin: '0 10px' }}>
        <a
          target="_blank"
          href={`${window.location.origin}/cityoms3/4.0.html`}
          rel="noopener noreferer"
        >
          运维平台4.0
        </a>
      </div>
      {/* <HeaderSearch
59
        className={`${styles.action} ${styles.search} ${styles.toRight}`}
dengxiaofeng's avatar
dengxiaofeng committed
60
        placeholder="站内搜索"
dengxiaofeng's avatar
dengxiaofeng committed
61
        defaultValue=""
张烨's avatar
张烨 committed
62 63
        filterOption={(inputValue, option) =>
          option.value.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1
64
        }
张烨's avatar
张烨 committed
65
        options={[...routesOptions(value.route)]}
66
      /> */}
张烨's avatar
张烨 committed
67
      {/* <NoticeIcon className={`${styles.action} ${styles.toRight}`} /> */}
68
      <Avatar className={styles.toRight} />
dengxiaofeng's avatar
dengxiaofeng committed
69 70 71 72 73 74
      {/* <SelectLang className={styles.action} /> */}
    </div>
  );
};

export default GlobalHeaderRight;