Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TOSTUMI
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Maple
TOSTUMI
Commits
ef98d001
Commit
ef98d001
authored
Nov 17, 2020
by
Sixiang_Zzb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试bug 处理
parent
0671215e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
68 deletions
+58
-68
BasicLayout.tsx
src/layouts/BasicLayout.tsx
+17
-39
SecurityLayout.tsx
src/layouts/SecurityLayout.tsx
+23
-23
user.ts
src/models/user.ts
+18
-6
No files found.
src/layouts/BasicLayout.tsx
View file @
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
);
src/layouts/SecurityLayout.tsx
View file @
ef98d001
...
...
@@ -5,7 +5,6 @@ import { stringify } from 'querystring';
import
{
ConnectState
}
from
'@/models/connect'
;
import
{
CurrentUser
}
from
'@/models/user'
;
import
{
getCookie
}
from
'@/utils/method'
;
import
{
message
}
from
'antd'
;
interface
SecurityLayoutProps
extends
ConnectProps
{
loading
?:
boolean
;
...
...
@@ -21,29 +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
,
},
});
}
else
{
message
.
error
(
'Please Re Login!'
);
history
.
push
(
'/user/login'
);
}
}
// 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
;
...
...
@@ -63,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
/>;
}
...
...
src/models/user.ts
View file @
ef98d001
...
...
@@ -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'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment