Commit cc175906 authored by cellee's avatar cellee

Merge branch 'final' of http://120.77.240.215:9701/Maple/tostumi.git into final

parents fe7ae761 ef98d001
......@@ -42,6 +42,7 @@ export interface BasicLayoutProps extends ProLayoutProps {
};
settings: Settings;
dispatch: Dispatch;
login: { userName?: string; password?: string };
}
export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
breadcrumbNameMap: {
......@@ -61,32 +62,6 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
return Authorized.check(item.authority, localItem, null) as MenuDataItem;
});
const defaultFooterDom = (
<DefaultFooter
copyright={`${new Date().getFullYear()} 蚂蚁金服体验技术部出品`}
links={[
{
key: 'Ant Design Pro',
title: 'Ant Design Pro',
href: 'https://pro.ant.design',
blankTarget: true,
},
{
key: 'github',
title: <GithubOutlined />,
href: 'https://github.com/ant-design/ant-design-pro',
blankTarget: true,
},
{
key: 'Ant Design',
title: 'Ant Design',
href: 'https://ant.design',
blankTarget: true,
},
]}
/>
);
const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const {
dispatch,
......@@ -95,23 +70,25 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
location = {
pathname: '/',
},
login,
} = props;
/**
* constructor
*/
useEffect(() => {
console.log(login);
if (dispatch) {
console.log('Maple');
dispatch({
type: 'user/fetchCurrent',
playload: {
userName: login.userName,
password: login.password,
},
});
}
}, []);
// useEffect(() => {
// if (dispatch) {
// console.log("Maple")
// dispatch({
// type: 'user/fetchCurrent',
// playload: {
// userName: "admin",
// password: "admin",
// }
// });
// }
// }, []);
/**
* init variables
*/
......@@ -198,7 +175,8 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
);
};
export default connect(({ global, settings }: ConnectState) => ({
export default connect(({ global, settings, login }: ConnectState) => ({
collapsed: global.collapsed,
settings,
login,
}))(BasicLayout);
import React from 'react';
import { PageLoading } from '@ant-design/pro-layout';
import { Redirect, connect, ConnectProps, StateType } from 'umi';
import { Redirect, connect, ConnectProps, StateType, history } from 'umi';
import { stringify } from 'querystring';
import { ConnectState } from '@/models/connect';
import { CurrentUser } from '@/models/user';
import login from '@/pages/user/login';
import { getCookie } from '@/utils/method';
interface SecurityLayoutProps extends ConnectProps {
......@@ -21,26 +20,30 @@ interface SecurityLayoutState {
class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayoutState> {
state: SecurityLayoutState = {
isReady: false,
token: 'abc123',
token: '',
};
componentDidMount() {
this.setState({
isReady: true,
});
const { dispatch, login } = this.props;
console.log('安全登录中');
console.log(login);
if (dispatch && !!login?.userName && !!login?.password) {
dispatch({
type: 'user/fetchCurrent',
playload: {
userName: login.userName,
password: login.password,
},
});
}
}
// componentDidMount() {
// console.log('componentDidMount触发了23333333');
// this.setState({
// isReady: true,
// });
// const { dispatch, login } = this.props;
// console.log('安全登录中');
// console.log(login);
// if (dispatch && !!login?.userName && !!login?.password) {
// dispatch({
// type: 'user/fetchCurrent',
// playload: {
// userName: login.userName,
// password: login.password,
// },
// });
// } else {
// history.push('/user/login');
// }
// }
render() {
const { isReady, token } = this.state;
......@@ -60,7 +63,7 @@ class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayout
redirect: window.location.href,
});
if ((!isLogin && loading) || !isReady) {
if (!isLogin && loading) {
// console.log("页面加载")
return <PageLoading />;
}
......
......@@ -48,13 +48,25 @@ const UserModel: UserModelType = {
},
*fetchCurrent({ playload }, { call, put }) {
// console.log("response")
const response = yield call(queryCurrent, playload);
// console.log(response)
yield put({
type: 'saveCurrentUser',
payload: response,
});
const userInfo = JSON.parse(localStorage.getItem('userInfo') || 'null');
console.log('存储用户信息');
console.log(userInfo);
if (!userInfo) {
const response = yield call(queryCurrent, playload);
console.log(response);
localStorage.setItem('userInfo', JSON.stringify(response));
yield put({
type: 'saveCurrentUser',
payload: response,
});
} else {
yield put({
type: 'saveCurrentUser',
payload: userInfo,
});
}
},
*deleteCurrent({ playload }, { call, put }) {
yield put({
type: 'deleteCurrentUser',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment