Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sean King
admin-fe
Commits
29d28c32
Commit
29d28c32
authored
7 years ago
by
Pan
Browse files
Options
Downloads
Patches
Plain Diff
fix bug in vuex of strict model
parent
62cb24c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/store/modules/app.js
+10
-3
10 additions, 3 deletions
src/store/modules/app.js
src/store/modules/permission.js
+3
-2
3 additions, 2 deletions
src/store/modules/permission.js
src/utils/index.js
+18
-0
18 additions, 0 deletions
src/utils/index.js
with
31 additions
and
5 deletions
src/store/modules/app.js
+
10
−
3
View file @
29d28c32
import
Cookies
from
'
js-cookie
'
;
const
app
=
{
state
:
{
sidebar
:
{
...
...
@@ -19,11 +20,17 @@ const app = {
state
.
sidebar
.
opened
=
!
state
.
sidebar
.
opened
;
},
ADD_VISITED_VIEWS
:
(
state
,
view
)
=>
{
if
(
state
.
visitedViews
.
includes
(
view
))
return
state
.
visitedViews
.
push
(
view
)
if
(
state
.
visitedViews
.
some
(
v
=>
v
.
path
===
view
.
path
))
return
state
.
visitedViews
.
push
(
{
name
:
view
.
name
,
path
:
view
.
path
}
)
},
DEL_VISITED_VIEWS
:
(
state
,
view
)
=>
{
const
index
=
state
.
visitedViews
.
indexOf
(
view
)
let
index
for
(
const
[
i
,
v
]
of
state
.
visitedViews
.
entries
())
{
if
(
v
.
path
===
view
.
path
)
{
index
=
i
break
}
}
state
.
visitedViews
.
splice
(
index
,
1
)
}
},
...
...
This diff is collapsed.
Click to expand it.
src/store/modules/permission.js
+
3
−
2
View file @
29d28c32
import
{
asyncRouterMap
,
constantRouterMap
}
from
'
src/router
'
;
import
{
deepClone
}
from
'
utils
'
/**
* 通过meta.role判断是否与当前用户权限匹配
...
...
@@ -38,8 +39,8 @@ const permission = {
},
mutations
:
{
SET_ROUTERS
:
(
state
,
routers
)
=>
{
state
.
addRouters
=
routers
;
state
.
routers
=
constantRouterMap
.
concat
(
routers
)
;
state
.
addRouters
=
deepClone
(
routers
)
state
.
routers
=
deepClone
(
constantRouterMap
.
concat
(
routers
)
)
}
},
actions
:
{
...
...
This diff is collapsed.
Click to expand it.
src/utils/index.js
+
18
−
0
View file @
29d28c32
...
...
@@ -250,3 +250,21 @@
};
}
export
function
deepClone
(
source
)
{
if
(
!
source
&&
typeof
source
!==
'
object
'
)
{
throw
new
Error
(
'
error arguments
'
,
'
shallowClone
'
);
}
const
targetObj
=
source
.
constructor
===
Array
?
[]
:
{};
for
(
const
keys
in
source
)
{
if
(
source
.
hasOwnProperty
(
keys
))
{
if
(
source
[
keys
]
&&
typeof
source
[
keys
]
===
'
object
'
)
{
targetObj
[
keys
]
=
source
[
keys
].
constructor
===
Array
?
[]
:
{};
targetObj
[
keys
]
=
deepClone
(
source
[
keys
]);
}
else
{
targetObj
[
keys
]
=
source
[
keys
];
}
}
}
return
targetObj
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment