Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcdj-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
4b4f5d50
authored
2022-11-17 15:52:22 +0800
by
任超
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:获取用户信息
1 parent
5e04abed
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
21 deletions
src/api/user.js
src/components/NoticeBar/index.vue
src/permission.js
src/store/modules/user.js
src/api/user.js
View file @
4b4f5d5
import
request
from
'@/utils/request'
import
SERVER
from
'./config'
// export function getMenuInfo () {
// return request({
// url: SERVER.SERVERAPI + '/rest/user/getUserMenus',
// method: 'get',
// })
// }
// 获取用户信息
export
function
getUserInfo
()
{
return
request
({
url
:
SERVER
.
SERVERAPI
+
'/rest/user/getUserInfo'
,
method
:
'get'
,
})
}
// 获取菜单信息
export
function
getMenuInfo
()
{
return
request
({
url
:
SERVER
.
SERVERAPI
+
'/rest/user/getUserAuthorizationMenus'
,
...
...
src/components/NoticeBar/index.vue
View file @
4b4f5d5
...
...
@@ -103,8 +103,8 @@ export default {
display
:
flex
;
align-items
:
center
;
width
:
100%
;
line-height
:
32
px
;
height
:
32
px
;
height
:
28
px
;
line-height
:
28
px
;
background
:
rgba
(
0
,
0
,
0
,
0.1
);
.icon
{
...
...
src/permission.js
View file @
4b4f5d5
...
...
@@ -5,7 +5,6 @@ import NProgress from 'nprogress' // progress bar
import
'nprogress/nprogress.css'
// progress bar style
import
getPageTitle
from
'@/utils/get-page-title'
import
Cookies
from
'js-cookie'
NProgress
.
configure
({
showSpinner
:
false
})
// NProgress Configuration
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
...
...
@@ -22,6 +21,8 @@ router.beforeEach(async (to, from, next) => {
}
else
{
const
{
result
:
getMenuData
}
=
await
getMenuInfo
()
const
accessRoutes
=
await
store
.
dispatch
(
'permission/generateRoutes'
,
getMenuData
)
// 获取用户信息
await
store
.
dispatch
(
'user/getUserInfo'
)
router
.
addRoutes
([...
accessRoutes
,
{
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
}])
const
routeTo
=
Cookies
.
get
(
'routerTo'
)
console
.
log
(
routeTo
)
...
...
@@ -32,7 +33,6 @@ router.beforeEach(async (to, from, next) => {
}
}
NProgress
.
done
()
})
router
.
afterEach
(
to
=>
{
// 解决刷新页面报404问题
...
...
src/store/modules/user.js
View file @
4b4f5d5
import
store
from
'../index'
import
router
,
{
resetRouter
}
from
'@/router'
import
Cookies
from
'js-cookie'
;
import
{
getUserInfo
}
from
'@/api/user'
const
state
=
{
name
:
Cookies
.
get
(
'username'
)
,
name
:
''
,
avatar
:
'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
,
userInfo
:
null
}
const
mutations
=
{
SET_NAME
:
(
state
,
name
)
=>
{
state
.
name
=
name
},
SET_AVATAR
:
(
state
,
avatar
)
=>
{
state
.
avatar
=
avatar
},
SET_USERINFO
:
(
state
,
userInfo
)
=>
{
state
.
userInfo
=
userInfo
}
}
const
actions
=
{
getUserInfo
({
commit
})
{
return
new
Promise
(
async
(
resolve
)
=>
{
let
{
result
:
res
}
=
await
getUserInfo
()
commit
(
'SET_NAME'
,
res
.
loginName
)
resolve
(
true
)
})
},
}
export
default
{
namespaced
:
true
,
...
...
Please
register
or
sign in
to post a comment