Commit ef98d001 authored by Sixiang_Zzb's avatar Sixiang_Zzb

测试bug 处理

parent 0671215e
...@@ -42,6 +42,7 @@ export interface BasicLayoutProps extends ProLayoutProps { ...@@ -42,6 +42,7 @@ export interface BasicLayoutProps extends ProLayoutProps {
}; };
settings: Settings; settings: Settings;
dispatch: Dispatch; dispatch: Dispatch;
login: { userName?: string; password?: string };
} }
export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & { export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
breadcrumbNameMap: { breadcrumbNameMap: {
...@@ -61,32 +62,6 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] => ...@@ -61,32 +62,6 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
return Authorized.check(item.authority, localItem, null) as 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 BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const { const {
dispatch, dispatch,
...@@ -95,23 +70,25 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => { ...@@ -95,23 +70,25 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
location = { location = {
pathname: '/', pathname: '/',
}, },
login,
} = props; } = props;
/** /**
* constructor * 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 * init variables
*/ */
...@@ -198,7 +175,8 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => { ...@@ -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, collapsed: global.collapsed,
settings, settings,
login,
}))(BasicLayout); }))(BasicLayout);
...@@ -5,7 +5,6 @@ import { stringify } from 'querystring'; ...@@ -5,7 +5,6 @@ import { stringify } from 'querystring';
import { ConnectState } from '@/models/connect'; import { ConnectState } from '@/models/connect';
import { CurrentUser } from '@/models/user'; import { CurrentUser } from '@/models/user';
import { getCookie } from '@/utils/method'; import { getCookie } from '@/utils/method';
import { message } from 'antd';
interface SecurityLayoutProps extends ConnectProps { interface SecurityLayoutProps extends ConnectProps {
loading?: boolean; loading?: boolean;
...@@ -21,29 +20,30 @@ interface SecurityLayoutState { ...@@ -21,29 +20,30 @@ interface SecurityLayoutState {
class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayoutState> { class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayoutState> {
state: SecurityLayoutState = { state: SecurityLayoutState = {
isReady: false, isReady: false,
token: 'abc123', token: '',
}; };
componentDidMount() { // componentDidMount() {
this.setState({ // console.log('componentDidMount触发了23333333');
isReady: true,
}); // this.setState({
const { dispatch, login } = this.props; // isReady: true,
console.log('安全登录中'); // });
console.log(login); // const { dispatch, login } = this.props;
if (dispatch && !!login?.userName && !!login?.password) { // console.log('安全登录中');
dispatch({ // console.log(login);
type: 'user/fetchCurrent', // if (dispatch && !!login?.userName && !!login?.password) {
playload: { // dispatch({
userName: login.userName, // type: 'user/fetchCurrent',
password: login.password, // playload: {
}, // userName: login.userName,
}); // password: login.password,
} else { // },
message.error('Please Re Login!'); // });
history.push('/user/login'); // } else {
} // history.push('/user/login');
} // }
// }
render() { render() {
const { isReady, token } = this.state; const { isReady, token } = this.state;
...@@ -63,7 +63,7 @@ class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayout ...@@ -63,7 +63,7 @@ class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayout
redirect: window.location.href, redirect: window.location.href,
}); });
if ((!isLogin && loading) || !isReady) { if (!isLogin && loading) {
// console.log("页面加载") // console.log("页面加载")
return <PageLoading />; return <PageLoading />;
} }
......
...@@ -48,13 +48,25 @@ const UserModel: UserModelType = { ...@@ -48,13 +48,25 @@ const UserModel: UserModelType = {
}, },
*fetchCurrent({ playload }, { call, put }) { *fetchCurrent({ playload }, { call, put }) {
// console.log("response") // console.log("response")
const userInfo = JSON.parse(localStorage.getItem('userInfo') || 'null');
console.log('存储用户信息');
console.log(userInfo);
if (!userInfo) {
const response = yield call(queryCurrent, playload); const response = yield call(queryCurrent, playload);
// console.log(response) console.log(response);
localStorage.setItem('userInfo', JSON.stringify(response));
yield put({ yield put({
type: 'saveCurrentUser', type: 'saveCurrentUser',
payload: response, payload: response,
}); });
} else {
yield put({
type: 'saveCurrentUser',
payload: userInfo,
});
}
}, },
*deleteCurrent({ playload }, { call, put }) { *deleteCurrent({ playload }, { call, put }) {
yield put({ yield put({
type: 'deleteCurrentUser', 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