From a58259249083060648d3d78333dd7139542bad0c Mon Sep 17 00:00:00 2001 From: shuguang Date: Thu, 8 May 2025 21:23:59 +0800 Subject: [PATCH] fix: fix Avatar display --- src/app.tsx | 4 ++-- src/components/RightContent/AvatarDropdown.tsx | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index a61c427..a415f89 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -42,7 +42,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) = src: initialState?.currentUser?.userAvatar, title: , render: (_, avatarChildren) => { - return {avatarChildren}; + return {avatarChildren}; }, }, waterMarkProps: { @@ -111,7 +111,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) = * @doc https://umijs.org/docs/max/request#配置 */ export const request = { - + baseURL:"http://localhost:8101", withCredentials:true, ...errorConfig, diff --git a/src/components/RightContent/AvatarDropdown.tsx b/src/components/RightContent/AvatarDropdown.tsx index b0e9bc8..f64d0b3 100644 --- a/src/components/RightContent/AvatarDropdown.tsx +++ b/src/components/RightContent/AvatarDropdown.tsx @@ -38,7 +38,8 @@ const useStyles = createStyles(({ token }) => { }; }); -export const AvatarDropdown: React.FC = ({ menu, children }) => { +export const AvatarDropdown: React.FC = ({ menu,initState, children }) => { + /** * 退出登录,并且将当前的 url 保存 */ @@ -89,11 +90,13 @@ export const AvatarDropdown: React.FC = ({ menu, childre ); - if (!initialState) { - return loading; - } + // if (!initialState) { + // return loading; + // } - const { currentUser } = initialState; + const { currentUser } = initState; + + console.log('currentUser:',currentUser,initState) if (!currentUser || !currentUser.userName) { return loading; @@ -135,4 +138,4 @@ export const AvatarDropdown: React.FC = ({ menu, childre {children} ); -}; \ No newline at end of file +};