ソースを参照

add SettingModal

visuddhinanda 2 年 前
コミット
505b140aff
1 ファイル変更7 行追加5 行削除
  1. 7 5
      dashboard/src/components/auth/Avatar.tsx

+ 7 - 5
dashboard/src/components/auth/Avatar.tsx

@@ -15,6 +15,7 @@ import {
 import { useAppSelector } from "../../hooks";
 import { useAppSelector } from "../../hooks";
 import { currentUser as _currentUser } from "../../reducers/current-user";
 import { currentUser as _currentUser } from "../../reducers/current-user";
 import { TooltipPlacement } from "antd/lib/tooltip";
 import { TooltipPlacement } from "antd/lib/tooltip";
+import SettingModal from "./setting/SettingModal";
 
 
 const { Title } = Typography;
 const { Title } = Typography;
 
 
@@ -33,7 +34,7 @@ const AvatarWidget = ({ style, placement = "bottomRight" }: IWidget) => {
     setNickName(user?.nickName);
     setNickName(user?.nickName);
   }, [user]);
   }, [user]);
 
 
-  const userCard = (
+  const UserCard = () => (
     <ProCard
     <ProCard
       style={{ maxWidth: 500, minWidth: 300 }}
       style={{ maxWidth: 500, minWidth: 300 }}
       actions={[
       actions={[
@@ -42,7 +43,7 @@ const AvatarWidget = ({ style, placement = "bottomRight" }: IWidget) => {
             id: "buttons.setting",
             id: "buttons.setting",
           })}
           })}
         >
         >
-          <SettingOutlined key="setting" />
+          <SettingModal trigger={<SettingOutlined key="setting" />} />
         </Tooltip>,
         </Tooltip>,
         <Tooltip
         <Tooltip
           title={intl.formatMessage({
           title={intl.formatMessage({
@@ -79,14 +80,15 @@ const AvatarWidget = ({ style, placement = "bottomRight" }: IWidget) => {
       </div>
       </div>
     </ProCard>
     </ProCard>
   );
   );
-  const login = <Link to="/anonymous/users/sign-in">登录</Link>;
+  const Login = () => <Link to="/anonymous/users/sign-in">登录</Link>;
   return (
   return (
     <>
     <>
-      <Popover content={user ? userCard : login} placement={placement}>
+      <Popover content={user ? <UserCard /> : <Login />} placement={placement}>
         <span style={style}>
         <span style={style}>
           <Avatar
           <Avatar
             style={{ backgroundColor: user ? "#87d068" : "gray" }}
             style={{ backgroundColor: user ? "#87d068" : "gray" }}
-            icon={<UserOutlined />}
+            icon={user?.avatar ? undefined : <UserOutlined />}
+            src={user?.avatar}
             size="small"
             size="small"
           >
           >
             {user ? nickName?.slice(0, 1) : undefined}
             {user ? nickName?.slice(0, 1) : undefined}