Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-platform-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
qa-platform-ui
Commits
a47950c9
Commit
a47950c9
authored
Jun 29, 2021
by
晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vuex使用
parent
ed3541a1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
27 deletions
+61
-27
header.js
src/store/modules/header.js
+0
-1
user.js
src/store/modules/user.js
+43
-0
store.js
src/store/store.js
+3
-1
Aside.vue
src/views/layout/leftAside/Aside.vue
+15
-25
No files found.
src/store/modules/header.js
View file @
a47950c9
...
@@ -60,7 +60,6 @@ const mutations = {
...
@@ -60,7 +60,6 @@ const mutations = {
const
actions
=
{
const
actions
=
{
setNavs
(
context
,
nav
)
{
setNavs
(
context
,
nav
)
{
console
.
log
(
'
setNav----
'
,
nav
)
context
.
commit
(
'
setNav
'
,
nav
)
context
.
commit
(
'
setNav
'
,
nav
)
}
}
}
}
...
...
src/store/modules/user.js
0 → 100644
View file @
a47950c9
const
state
=
{
userId
:
'
123
'
,
username
:
''
,
menuList
:
[],
roleIds
:
[],
permissionCodeList
:
[]
}
const
mutations
=
{
SET_USER
:
(
state
,
userInfo
)
=>
{
state
.
userId
=
userInfo
.
id
state
.
username
=
userInfo
.
username
state
.
menuList
=
userInfo
.
menuList
state
.
roleIds
=
userInfo
.
roleIds
state
.
permissionCodeList
=
userInfo
.
permissionCodeList
},
RESET_USER
:
state
=>
{
state
.
userId
=
''
state
.
username
=
''
state
.
menuList
=
[]
state
.
roleIds
=
[]
state
.
permissionCodeList
=
[]
}
}
const
getters
=
{
UserId
:
state
=>
{
return
state
.
userId
}
}
const
actions
=
{
userMsg
(
context
,
userInfo
)
{
console
.
log
(
'
用户信息
'
,
userInfo
)
context
.
commit
(
'
SET_USER
'
,
userInfo
)
}
}
export
default
{
namespaced
:
true
,
state
,
getters
,
mutations
,
actions
}
src/store/store.js
View file @
a47950c9
import
Vue
from
'
vue
'
import
Vue
from
'
vue
'
import
Vuex
from
'
vuex
'
import
Vuex
from
'
vuex
'
import
header
from
'
./modules/header
'
import
header
from
'
./modules/header
'
import
user
from
'
./modules/user
'
Vue
.
use
(
Vuex
)
Vue
.
use
(
Vuex
)
export
default
new
Vuex
.
Store
({
export
default
new
Vuex
.
Store
({
modules
:
{
modules
:
{
header
header
,
user
}
}
})
})
src/views/layout/leftAside/Aside.vue
View file @
a47950c9
...
@@ -32,11 +32,8 @@
...
@@ -32,11 +32,8 @@
<
script
>
<
script
>
import
{
mapGetters
}
from
'
vuex
'
import
{
mapGetters
}
from
'
vuex
'
import
menu
from
'
./menu.json
'
import
menu
from
'
./menu.json
'
<<<<<<<
HEAD
import
{
getUserDetail
}
from
'
@/api/getLogin/
'
=======
import
{
getUserDetail
}
from
'
@/api/Login/
'
import
{
getUserDetail
}
from
'
@/api/Login/
'
>>>>>>>
188783
e41eb96a84e9f795823cfef2abfb4f1a2b
export
default
{
export
default
{
name
:
'
Aside
'
,
name
:
'
Aside
'
,
data
()
{
data
()
{
...
@@ -50,11 +47,7 @@ export default {
...
@@ -50,11 +47,7 @@ export default {
},
},
methods
:
{
methods
:
{
getNav
()
{
getNav
()
{
<<<<<<<
HEAD
this
.
nav
=
menu
.
menu
=======
const
tempNav
=
menu
.
menu
const
tempNav
=
menu
.
menu
>>>>>>>
188783
e41eb96a84e9f795823cfef2abfb4f1a2b
// 循环判断新列表里的是数据是否在旧列表里出现
// 循环判断新列表里的是数据是否在旧列表里出现
tempNav
.
forEach
((
element
)
=>
{
tempNav
.
forEach
((
element
)
=>
{
var
temp
=
{}
var
temp
=
{}
...
@@ -64,13 +57,15 @@ export default {
...
@@ -64,13 +57,15 @@ export default {
temp
[
'
child
'
]
=
[]
temp
[
'
child
'
]
=
[]
element
.
child
.
forEach
((
children
)
=>
{
element
.
child
.
forEach
((
children
)
=>
{
var
flag
=
false
var
flag
=
false
this
.
menuList
.
forEach
((
menu
)
=>
{
if
(
this
.
menuList
.
length
>
0
)
{
if
(
menu
===
children
.
path
)
{
this
.
menuList
.
forEach
((
menu
)
=>
{
flag
=
true
if
(
menu
===
children
.
path
)
{
flag
=
true
}
})
if
(
flag
===
true
)
{
temp
[
'
child
'
].
push
(
children
)
}
}
})
if
(
flag
===
true
)
{
temp
[
'
child
'
].
push
(
children
)
}
}
})
})
// 判断子菜单是否为空,为空不添加
// 判断子菜单是否为空,为空不添加
...
@@ -79,12 +74,7 @@ export default {
...
@@ -79,12 +74,7 @@ export default {
}
}
})
})
this
.
$store
.
dispatch
(
'
header/setNavs
'
,
{
this
.
$store
.
dispatch
(
'
header/setNavs
'
,
{
<<<<<<<
HEAD
// nav: this.nav
nav
:
[]
=======
nav
:
this
.
nav
nav
:
this
.
nav
>>>>>>>
188783
e41eb96a84e9f795823cfef2abfb4f1a2b
})
})
},
},
...
@@ -101,12 +91,12 @@ export default {
...
@@ -101,12 +91,12 @@ export default {
window
.
sessionStorage
.
setItem
(
'
activePath
'
,
activePath
)
window
.
sessionStorage
.
setItem
(
'
activePath
'
,
activePath
)
},
},
// 获取用户详细信息
// 获取用户详细信息
<<<<<<<
HEAD
async
getUserDetail
()
{
=======
getUserDetail
()
{
getUserDetail
()
{
>>>>>>>
188783
e41eb96a84e9f795823cfef2abfb4f1a2b
getUserDetail
().
then
((
resp
)
=>
{
getUserDetail
().
then
((
resp
)
=>
{
this
.
$store
.
dispatch
(
'
user/userMsg
'
,
{
userInfo
:
resp
.
data
.
data
})
console
.
log
(
this
.
getUserId
)
this
.
menuList
=
resp
.
data
.
data
.
menuList
this
.
menuList
=
resp
.
data
.
data
.
menuList
this
.
getNav
()
this
.
getNav
()
})
})
...
@@ -118,13 +108,13 @@ export default {
...
@@ -118,13 +108,13 @@ export default {
return
this
.
$route
.
path
return
this
.
$route
.
path
},
},
...
mapGetters
({
...
mapGetters
({
getCollapseState
:
'
header/CollapseState
'
getCollapseState
:
'
header/CollapseState
'
,
getUserId
:
'
user/UserId
'
})
})
},
},
created
()
{
created
()
{
this
.
activePath
=
window
.
sessionStorage
.
getItem
(
'
activePath
'
)
this
.
activePath
=
window
.
sessionStorage
.
getItem
(
'
activePath
'
)
this
.
getUserDetail
()
this
.
getUserDetail
()
// this.getNav()
}
}
}
}
</
script
>
</
script
>
...
...
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