fix: fix Avatar display

This commit is contained in:
shuguang 2025-05-08 21:23:59 +08:00
parent 9b0db2cd2f
commit a582592490
2 changed files with 11 additions and 8 deletions

View File

@ -42,7 +42,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
src: initialState?.currentUser?.userAvatar, src: initialState?.currentUser?.userAvatar,
title: <AvatarName />, title: <AvatarName />,
render: (_, avatarChildren) => { render: (_, avatarChildren) => {
return <AvatarDropdown>{avatarChildren}</AvatarDropdown>; return <AvatarDropdown initState={initialState}>{avatarChildren}</AvatarDropdown>;
}, },
}, },
waterMarkProps: { waterMarkProps: {

View File

@ -38,7 +38,8 @@ const useStyles = createStyles(({ token }) => {
}; };
}); });
export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu, children }) => { export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu,initState, children }) => {
/** /**
* 退 url * 退 url
*/ */
@ -89,11 +90,13 @@ export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu, childre
</span> </span>
); );
if (!initialState) { // if (!initialState) {
return loading; // return loading;
} // }
const { currentUser } = initialState; const { currentUser } = initState;
console.log('currentUser:',currentUser,initState)
if (!currentUser || !currentUser.userName) { if (!currentUser || !currentUser.userName) {
return loading; return loading;