chore: FIX
This commit is contained in:
parent
9b0db2cd2f
commit
f35bf3978e
16
src/app.tsx
16
src/app.tsx
@ -1,3 +1,4 @@
|
|||||||
|
import React from 'react';
|
||||||
import { AvatarDropdown, AvatarName, Footer, Question } from '@/components';
|
import { AvatarDropdown, AvatarName, Footer, Question } from '@/components';
|
||||||
import { SettingDrawer } from '@ant-design/pro-components';
|
import { SettingDrawer } from '@ant-design/pro-components';
|
||||||
import type { RunTimeLayoutConfig } from '@umijs/max';
|
import type { RunTimeLayoutConfig } from '@umijs/max';
|
||||||
@ -36,13 +37,26 @@ export async function getInitialState(): Promise<{
|
|||||||
|
|
||||||
|
|
||||||
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
|
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
|
||||||
|
|
||||||
|
const [data,setData]=React.useState("")
|
||||||
|
|
||||||
|
const fetchData=(async ()=>{
|
||||||
|
const res = await getLoginUserUsingGet();
|
||||||
|
console.log('data',res)
|
||||||
|
setData(res)
|
||||||
|
})
|
||||||
|
|
||||||
|
React.useEffect(()=>{
|
||||||
|
fetchData()
|
||||||
|
},[])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
actionsRender: () => [<Question key="doc" />],
|
actionsRender: () => [<Question key="doc" />],
|
||||||
avatarProps: {
|
avatarProps: {
|
||||||
src: initialState?.currentUser?.userAvatar,
|
src: initialState?.currentUser?.userAvatar,
|
||||||
title: <AvatarName />,
|
title: <AvatarName />,
|
||||||
render: (_, avatarChildren) => {
|
render: (_, avatarChildren) => {
|
||||||
return <AvatarDropdown>{avatarChildren}</AvatarDropdown>;
|
return <AvatarDropdown currentUser={data}>{avatarChildren}</AvatarDropdown>;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
waterMarkProps: {
|
waterMarkProps: {
|
||||||
|
@ -16,6 +16,7 @@ export type GlobalHeaderRightProps = {
|
|||||||
|
|
||||||
export const AvatarName = () => {
|
export const AvatarName = () => {
|
||||||
const { initialState } = useModel('@@initialState');
|
const { initialState } = useModel('@@initialState');
|
||||||
|
console.log('initialState',initialState)
|
||||||
const { currentUser } = initialState || {};
|
const { currentUser } = initialState || {};
|
||||||
return <span className="anticon">{currentUser?.userName}</span>;
|
return <span className="anticon">{currentUser?.userName}</span>;
|
||||||
};
|
};
|
||||||
@ -38,7 +39,7 @@ const useStyles = createStyles(({ token }) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu, children }) => {
|
export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu, children,currentUser }) => {
|
||||||
/**
|
/**
|
||||||
* 退出登录,并且将当前的 url 保存
|
* 退出登录,并且将当前的 url 保存
|
||||||
*/
|
*/
|
||||||
@ -93,7 +94,7 @@ export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu, childre
|
|||||||
return loading;
|
return loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { currentUser } = initialState;
|
// const { currentUser } = initialState;
|
||||||
|
|
||||||
if (!currentUser || !currentUser.userName) {
|
if (!currentUser || !currentUser.userName) {
|
||||||
return loading;
|
return loading;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user