Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
Project
Project
Details
Activity
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
project
jinfa-admin
Commits
91f4a3e7
Commit
91f4a3e7
authored
Aug 26, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增用户名显示
parent
252fcdf1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
17 deletions
+16
-17
app.tsx
src/app.tsx
+1
-5
RightContent.tsx
src/layouts/RightContent.tsx
+4
-3
index.tsx
src/pages/user/login/index.tsx
+1
-5
auth.ts
src/utils/auth.ts
+6
-2
request.ts
src/utils/request.ts
+4
-2
No files found.
src/app.tsx
View file @
91f4a3e7
...
...
@@ -54,11 +54,7 @@ export function render(oldRender:Function) {
PublicApi
.
getMemberManageLoginReget
().
then
(
res
=>
{
const
{
data
,
code
}
=
res
if
(
code
===
1000
)
{
setAuth
({
memberId
:
data
.
memberId
,
userId
:
data
.
userId
,
token
:
data
.
token
})
setAuth
(
data
)
setRouters
(
data
.
urls
)
}
else
{
removeAuth
()
...
...
src/layouts/RightContent.tsx
View file @
91f4a3e7
...
...
@@ -3,7 +3,7 @@ import { Link, history } from 'umi'
import
{
Menu
,
Dropdown
}
from
'antd'
import
{
CaretDownOutlined
}
from
'@ant-design/icons'
import
styles
from
'./index.less'
import
{
removeAuth
}
from
'@/utils/auth'
import
{
removeAuth
,
getAuth
}
from
'@/utils/auth'
const
RightContent
:
React
.
FC
<
{}
>
=
(
props
)
=>
{
...
...
@@ -22,15 +22,16 @@ const RightContent: React.FC<{}> = (props) => {
</
Menu
>
);
const
userInfo
=
getAuth
()
console
.
log
(
userInfo
)
return
<
div
className=
{
styles
.
lxLayoutRight
}
>
<
Link
to=
"/home"
className=
{
styles
.
lxLink
}
>
返回首页
</
Link
>
<
Dropdown
overlay=
{
menu
}
>
<
div
className=
{
styles
.
avatarWrap
}
>
<
div
className=
{
styles
.
avatar
}
></
div
>
<
div
className=
"ant-dropdown-link"
onClick=
{
e
=>
e
.
preventDefault
()
}
>
<
span
>
Admin
</
span
>
<
span
>
{
userInfo
?.
name
||
'未知用户'
}
</
span
>
<
CaretDownOutlined
/>
</
div
>
</
div
>
...
...
src/pages/user/login/index.tsx
View file @
91f4a3e7
...
...
@@ -81,11 +81,7 @@ class Index extends Component<{}, IndexState> {
console
.
log
(
'Received values of form: '
,
values
);
PublicApi
.
postMemberManageLogin
(
values
).
then
(
res
=>
{
const
{
data
}
=
res
setAuth
({
memberId
:
data
.
memberId
,
userId
:
data
.
userId
,
token
:
data
.
token
})
setAuth
(
data
)
setRouters
(
data
.
urls
)
window
.
location
.
href
=
'/home'
}).
catch
(
error
=>
{
...
...
src/utils/auth.ts
View file @
91f4a3e7
import
{
isDev
}
from
'@/constants'
import
{
PublicApi
}
from
'@/services/api'
import
{
GetMemberManageLoginRegetResponse
}
from
'@/services'
export
interface
AuthInfo
{
userId
:
number
,
memberId
:
number
,
token
:
string
token
:
string
,
name
:
string
,
account
:
string
,
}
export
const
setAuth
=
(
info
:
AuthInfo
)
=>
{
export
const
setAuth
=
(
info
:
GetMemberManageLoginRegetResponse
)
=>
{
window
.
localStorage
.
setItem
(
'auth'
,
JSON
.
stringify
(
info
))
}
...
...
src/utils/request.ts
View file @
91f4a3e7
...
...
@@ -56,10 +56,12 @@ const baseRequest = extend({
// 请求拦截器
baseRequest
.
interceptors
.
request
.
use
((
url
:
string
,
options
:
RequestOptionsInit
):
{
url
:
string
,
options
:
RequestOptionsInit
}
=>
{
// 判断是否有权限
const
loginAfterHeaders
=
getAuth
()
const
{
userId
,
memberId
,
token
}
=
getAuth
()
const
headers
=
{
...
options
.
headers
,
...
loginAfterHeaders
userId
,
memberId
,
token
}
return
{
// 前缀如果已经带上api, 跳过自动补前缀
...
...
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