UNPKG

@antdp/basic-layouts

Version:

入口框架公共界面

99 lines 2.73 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; var _excluded = ["icon", "title", "link", "onClick"]; import { UserOutlined } from '@ant-design/icons'; import Fullscreen from '@antdp/fullscreen'; import { Avatar, Dropdown } from 'antd'; import React, { Fragment, useMemo } from 'react'; import { Link } from 'react-router-dom'; import SearchMenu from '../SearchMenus'; import { useLayouts } from './../hooks'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; var User = () => { var { topRightMenu = [], profile = {}, topRightLanguage } = useLayouts(); var { avatar, name } = profile; var rightMenu = useMemo(() => { return topRightMenu.map((item, index) => { var { icon, title, link, onClick } = item, rest = _objectWithoutPropertiesLoose(item, _excluded); if (item.divider) { return { type: 'divider' }; } if (!title) { return null; } var child = /*#__PURE__*/_jsxs(Fragment, { children: [icon && /*#__PURE__*/_jsx("span", { style: { marginRight: 5 }, children: icon }), title] }); if (link) { child = /*#__PURE__*/_jsx(Link, { to: link, children: child }); } return _extends({}, rest, { label: child, key: index, onClick }); }); }, [topRightMenu]); return /*#__PURE__*/_jsxs(React.Fragment, { children: [ANTD_MENU_SEARCH_IS_SHOW && /*#__PURE__*/_jsx("div", { style: { marginRight: 10 }, children: /*#__PURE__*/_jsx(SearchMenu, {}) }), /*#__PURE__*/_jsx(Fullscreen, {}), /*#__PURE__*/_jsx(Dropdown, { menu: { items: rightMenu }, placement: "bottomRight", trigger: ['click'], children: /*#__PURE__*/_jsxs("span", { className: "antdp-basic-layouts-header-user", children: [/*#__PURE__*/_jsx("span", { style: { marginRight: 8 }, children: avatar ? /*#__PURE__*/_jsx("img", { src: avatar }) : /*#__PURE__*/_jsx(Avatar, { size: 24, icon: /*#__PURE__*/_jsx(UserOutlined, { style: { minWidth: 'inherit', marginRight: 0 } }) }) }), /*#__PURE__*/_jsx("span", { style: { userSelect: 'none' }, children: name || ' - ' })] }) }), topRightLanguage] }); }; export default User;