Skip to content

Commit 36c8eee

Browse files
committed
fix: fix default user
1 parent db524a8 commit 36c8eee

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • shell/app/common/components/user-info

shell/app/common/components/user-info/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ import { get } from 'lodash';
1717
import i18n from 'i18n';
1818
import { Avatar } from 'antd';
1919
import { getAvatarChars } from 'common/utils';
20+
import userStore from 'user/stores';
2021
import Ellipsis from 'common/components/ellipsis';
2122
import { AvatarSize } from 'antd/lib/avatar/SizeContext';
2223

2324
interface IPlatformUser {
2425
avatar: string;
2526
email: string;
2627
id: string;
27-
locked: boolean;
28+
locked?: boolean;
2829
name: string;
2930
nick: string;
3031
phone: string;
@@ -37,13 +38,14 @@ interface IProps {
3738
render?: (data: IPlatformUser, id?: string | number) => React.ReactNode;
3839
}
3940

40-
const defaultRender = (data: IPlatformUser, id: string | number) => {
41+
const defaultRender = (data: IPlatformUser, id?: string | number) => {
4142
return data.nick || data.name || id || i18n.t('None');
4243
};
4344

4445
const UserInfo = ({ id, render = defaultRender }: IProps) => {
4546
const userMap = useUserMap();
46-
const userInfo: IPlatformUser = get(userMap, id, {});
47+
const loginUser = userStore.useStore((s) => s.loginUser);
48+
const userInfo = get({ [loginUser.id]: loginUser as unknown as IPlatformUser, ...userMap }, id, {}) as IPlatformUser;
4749
return <>{render?.(userInfo, id)}</>;
4850
};
4951

0 commit comments

Comments
 (0)