登录功能
This commit is contained in:
parent
be8df2a0da
commit
bef37b4fd3
@ -14,6 +14,7 @@ const Settings: ProLayoutProps & {
|
|||||||
contentWidth: 'Fluid',
|
contentWidth: 'Fluid',
|
||||||
fixedHeader: false,
|
fixedHeader: false,
|
||||||
fixSiderbar: true,
|
fixSiderbar: true,
|
||||||
|
splitMenus: false,
|
||||||
colorWeak: false,
|
colorWeak: false,
|
||||||
title: 'Ans智能BI',
|
title: 'Ans智能BI',
|
||||||
pwa: true,
|
pwa: true,
|
||||||
|
|||||||
10
src/app.tsx
10
src/app.tsx
@ -1,9 +1,11 @@
|
|||||||
import Footer from '@/components/Footer';
|
import Footer from '@/components/Footer';
|
||||||
import { Question } from '@/components/RightContent';
|
import { Question } from '@/components/RightContent';
|
||||||
import { LinkOutlined } from '@ant-design/icons';
|
import { LinkOutlined } from '@ant-design/icons';
|
||||||
|
import type { Settings as LayoutSettings } from '@ant-design/pro-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';
|
||||||
import { history, Link } from '@umijs/max';
|
import { history, Link } from '@umijs/max';
|
||||||
|
import defaultSettings from '../config/defaultSettings';
|
||||||
import { AvatarDropdown, AvatarName } from './components/RightContent/AvatarDropdown';
|
import { AvatarDropdown, AvatarName } from './components/RightContent/AvatarDropdown';
|
||||||
import { errorConfig } from './requestConfig';
|
import { errorConfig } from './requestConfig';
|
||||||
import { getLoginUserUsingGET } from './services/answerbi/userController';
|
import { getLoginUserUsingGET } from './services/answerbi/userController';
|
||||||
@ -14,6 +16,7 @@ const loginPath = '/user/login';
|
|||||||
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
|
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
|
||||||
* */
|
* */
|
||||||
export async function getInitialState(): Promise<{
|
export async function getInitialState(): Promise<{
|
||||||
|
settings?: Partial<LayoutSettings>;
|
||||||
currentUser?: API.LoginUserVO;
|
currentUser?: API.LoginUserVO;
|
||||||
}> {
|
}> {
|
||||||
const fetchUserInfo = async () => {
|
const fetchUserInfo = async () => {
|
||||||
@ -31,9 +34,12 @@ export async function getInitialState(): Promise<{
|
|||||||
const currentUser = await fetchUserInfo();
|
const currentUser = await fetchUserInfo();
|
||||||
return {
|
return {
|
||||||
currentUser,
|
currentUser,
|
||||||
|
settings: defaultSettings as Partial<LayoutSettings>,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {};
|
return {
|
||||||
|
settings: defaultSettings as Partial<LayoutSettings>,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProLayout 支持的api https://procomponents.ant.design/components/layout
|
// ProLayout 支持的api https://procomponents.ant.design/components/layout
|
||||||
@ -48,7 +54,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
waterMarkProps: {
|
waterMarkProps: {
|
||||||
content: initialState?.currentUser?.name,
|
content: initialState?.currentUser?.userName,
|
||||||
},
|
},
|
||||||
footerRender: () => <Footer />,
|
footerRender: () => <Footer />,
|
||||||
onPageChange: () => {
|
onPageChange: () => {
|
||||||
|
|||||||
@ -37,7 +37,7 @@ const Login: React.FC = () => {
|
|||||||
flushSync(() => {
|
flushSync(() => {
|
||||||
setInitialState((s) => ({
|
setInitialState((s) => ({
|
||||||
...s,
|
...s,
|
||||||
currentUser: userInfo,
|
currentUser: userInfo.data,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user