Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VueElementTemplate
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
JIRA
JIRA
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
HireTest
VueElementTemplate
Commits
29d28c32
Commit
29d28c32
authored
7 years ago
by
Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug in vuex of strict model
parent
62cb24c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
5 deletions
+31
-5
app.js
src/store/modules/app.js
+10
-3
permission.js
src/store/modules/permission.js
+3
-2
index.js
src/utils/index.js
+18
-0
No files found.
src/store/modules/app.js
View file @
29d28c32
import
Cookies
from
'js-cookie'
;
import
Cookies
from
'js-cookie'
;
const
app
=
{
const
app
=
{
state
:
{
state
:
{
sidebar
:
{
sidebar
:
{
...
@@ -19,11 +20,17 @@ const app = {
...
@@ -19,11 +20,17 @@ const app = {
state
.
sidebar
.
opened
=
!
state
.
sidebar
.
opened
;
state
.
sidebar
.
opened
=
!
state
.
sidebar
.
opened
;
},
},
ADD_VISITED_VIEWS
:
(
state
,
view
)
=>
{
ADD_VISITED_VIEWS
:
(
state
,
view
)
=>
{
if
(
state
.
visitedViews
.
includes
(
view
))
return
if
(
state
.
visitedViews
.
some
(
v
=>
v
.
path
===
view
.
path
))
return
state
.
visitedViews
.
push
(
view
)
state
.
visitedViews
.
push
(
{
name
:
view
.
name
,
path
:
view
.
path
}
)
},
},
DEL_VISITED_VIEWS
:
(
state
,
view
)
=>
{
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
)
state
.
visitedViews
.
splice
(
index
,
1
)
}
}
},
},
...
...
This diff is collapsed.
Click to expand it.
src/store/modules/permission.js
View file @
29d28c32
import
{
asyncRouterMap
,
constantRouterMap
}
from
'src/router'
;
import
{
asyncRouterMap
,
constantRouterMap
}
from
'src/router'
;
import
{
deepClone
}
from
'utils'
/**
/**
* 通过meta.role判断是否与当前用户权限匹配
* 通过meta.role判断是否与当前用户权限匹配
...
@@ -38,8 +39,8 @@ const permission = {
...
@@ -38,8 +39,8 @@ const permission = {
},
},
mutations
:
{
mutations
:
{
SET_ROUTERS
:
(
state
,
routers
)
=>
{
SET_ROUTERS
:
(
state
,
routers
)
=>
{
state
.
addRouters
=
routers
;
state
.
addRouters
=
deepClone
(
routers
)
state
.
routers
=
constantRouterMap
.
concat
(
routers
);
state
.
routers
=
deepClone
(
constantRouterMap
.
concat
(
routers
))
}
}
},
},
actions
:
{
actions
:
{
...
...
This diff is collapsed.
Click to expand it.
src/utils/index.js
View file @
29d28c32
...
@@ -250,3 +250,21 @@
...
@@ -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.
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