index.jsx 1.44 KB
Newer Older
wuhao's avatar
wuhao committed
1 2 3 4 5 6 7
import { Space } from "antd";
import { QuestionCircleOutlined } from "@ant-design/icons";
import React from "react";
import { useModel, SelectLang } from "umi";
import Avatar from "./AvatarDropdown";
import HeaderSearch from "../HeaderSearch";
import styles from "./index.less";
wuhao's avatar
wuhao committed
8
import { MenuUnfoldOutlined, MenuFoldOutlined } from '@ant-design/icons'
wuhao's avatar
wuhao committed
9 10

const GlobalHeaderRight = () => {
wuhao's avatar
wuhao committed
11 12
  const { initialState, setInitialState } = useModel("@@initialState");
  const { collapsed } = initialState;
wuhao's avatar
wuhao committed
13 14 15 16 17 18 19 20 21 22 23 24 25
  if (!initialState || !initialState.settings) {
    return null;
  }

  const { navTheme, layout } = initialState.settings;
  let className = styles.right;

  if ((navTheme === "dark" && layout === "top") || layout === "mix") {
    className = `${styles.right}  ${styles.dark}`;
  }

  return (
    <Space className={className}>
wuhao's avatar
wuhao committed
26 27 28 29 30
      <div
        style={{ color: "#000", fontSize: 20, paddingLeft: 12 }}
        onClick={() => { }}
      >
        {collapsed ? (
wuhao's avatar
wuhao committed
31
          <MenuUnfoldOutlined
wuhao's avatar
wuhao committed
32 33 34 35 36 37
            style={{ cursor: "pointer" }}
            onClick={() => {
              setInitialState(s => ({ ...s, collapsed: !collapsed }));
            }}
          />
        ) : (
wuhao's avatar
wuhao committed
38
          <MenuFoldOutlined
wuhao's avatar
wuhao committed
39 40 41 42 43 44 45
            style={{ cursor: "pointer" }}
            onClick={() => {
              setInitialState(s => ({ ...s, collapsed: !collapsed }));
            }}
          />
        )}
      </div>
wuhao's avatar
wuhao committed
46 47 48 49 50 51
      <Avatar />
    </Space>
  );
};

export default GlobalHeaderRight;