Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dcxy-system
Project
Overview
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
姜雷
dcxy-system
Commits
49f97a05
Commit
49f97a05
authored
Apr 22, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
白名单在store中维护
parent
d55ca3aa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
13 deletions
+36
-13
App.vue
src/App.vue
+3
-3
develop.js
src/dev-local/develop.js
+12
-0
main.js
src/lib/main.js
+11
-1
permission.js
src/lib/permission.js
+1
-9
index.js
src/store/modules/app/index.js
+9
-0
No files found.
src/App.vue
View file @
49f97a05
...
@@ -50,8 +50,7 @@
...
@@ -50,8 +50,7 @@
import
UserBox
from
'./containers/layout/components/UserBox'
;
import
UserBox
from
'./containers/layout/components/UserBox'
;
import
IconMenus
from
'./containers/layout/IconMenu/IconMenu'
;
import
IconMenus
from
'./containers/layout/IconMenu/IconMenu'
;
import
CollectMenu
from
'./containers/layout/Collect/Collect'
;
import
CollectMenu
from
'./containers/layout/Collect/Collect'
;
import
{
mapGetters
}
from
'vuex'
;
const
whiteList
=
process
.
env
.
VUE_APP_WHITE_LIST
.
split
(
','
);
// 不重定向白名单
export
default
{
export
default
{
name
:
'App'
,
name
:
'App'
,
...
@@ -76,6 +75,7 @@ export default {
...
@@ -76,6 +75,7 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'whiteList'
]),
dashboardVisiable
()
{
dashboardVisiable
()
{
return
this
.
$route
.
name
===
'dashboard'
;
return
this
.
$route
.
name
===
'dashboard'
;
},
},
...
@@ -100,7 +100,7 @@ export default {
...
@@ -100,7 +100,7 @@ export default {
methods
:
{
methods
:
{
showComponents
(
store
)
{
showComponents
(
store
)
{
this
.
isInnerPage
=
this
.
isInnerPage
=
whiteList
.
indexOf
(
this
.
$route
.
path
)
!==
-
1
?
false
:
true
;
this
.
whiteList
.
indexOf
(
this
.
$route
.
path
)
!==
-
1
?
false
:
true
;
if
(
store
)
{
if
(
store
)
{
store
.
install
(
this
.
$store
);
store
.
install
(
this
.
$store
);
this
.
$nextTick
(
vm
=>
{
this
.
$nextTick
(
vm
=>
{
...
...
src/dev-local/develop.js
View file @
49f97a05
...
@@ -12,6 +12,18 @@ setTimeout(() => {
...
@@ -12,6 +12,18 @@ setTimeout(() => {
System
.
createSystem
({
System
.
createSystem
({
basePath
:
process
.
env
.
VUE_APP_BASE_URL
,
basePath
:
process
.
env
.
VUE_APP_BASE_URL
,
routers
:
allAasyncRouterMap
,
routers
:
allAasyncRouterMap
,
constantRouter
:
[
{
path
:
'/asd'
,
name
:
'asd'
,
component
:
{
render
(
h
)
{
return
<
div
>
asdasdasd
<
/div>
;
},
},
},
],
whiteList
:
'/asd'
,
routeFilter
:
(
routes
,
allRoute
)
=>
{
routeFilter
:
(
routes
,
allRoute
)
=>
{
if
(
allRoute
&&
allRoute
.
length
)
{
if
(
allRoute
&&
allRoute
.
length
)
{
let
addRoute
=
System
.
utils
.
route
.
formatRouteLink
(
allRoute
);
let
addRoute
=
System
.
utils
.
route
.
formatRouteLink
(
allRoute
);
...
...
src/lib/main.js
View file @
49f97a05
...
@@ -42,7 +42,17 @@ class SystemShell {
...
@@ -42,7 +42,17 @@ class SystemShell {
});
});
routeStore
.
install
(
store
);
routeStore
.
install
(
store
);
extendCom
(
Vue
);
extendCom
(
Vue
);
configRoutePermission
(
router
,
store
,
routers
,
whiteList
);
const
allWhiteList
=
whiteList
&&
typeof
whiteList
===
'string'
?
[
...
process
.
env
.
VUE_APP_WHITE_LIST
.
split
(
','
),
...
whiteList
.
split
(
','
),
]
:
process
.
env
.
VUE_APP_WHITE_LIST
.
split
(
','
);
// 不重定向白名单
console
.
log
(
allWhiteList
);
store
.
dispatch
(
'getWhiteList'
,
allWhiteList
);
configRoutePermission
(
router
,
store
,
routers
,
allWhiteList
);
Vue
.
config
.
productionTip
=
false
;
Vue
.
config
.
productionTip
=
false
;
let
app
=
new
Vue
({
let
app
=
new
Vue
({
...
...
src/lib/permission.js
View file @
49f97a05
...
@@ -8,18 +8,10 @@ const configRoutePermission = (
...
@@ -8,18 +8,10 @@ const configRoutePermission = (
router
,
router
,
store
,
store
,
allAasyncRouterMap
,
allAasyncRouterMap
,
add
whiteList
whiteList
)
=>
{
)
=>
{
NProgress
.
configure
({
showSpinner
:
false
});
// NProgress Configuration
NProgress
.
configure
({
showSpinner
:
false
});
// NProgress Configuration
const
whiteList
=
addwhiteList
&&
typeof
addwhiteList
===
'string'
?
[
...
process
.
env
.
VUE_APP_WHITE_LIST
.
split
(
','
),
...
addwhiteList
.
split
(
','
),
]
:
process
.
env
.
VUE_APP_WHITE_LIST
.
split
(
','
);
// 不重定向白名单
const
getRouteAdd
=
()
=>
{
const
getRouteAdd
=
()
=>
{
let
allRoute
=
store
.
getters
.
asyncRoutes
;
let
allRoute
=
store
.
getters
.
asyncRoutes
;
let
asyncRouters
=
getAuthRoute
(
allAasyncRouterMap
,
allRoute
);
let
asyncRouters
=
getAuthRoute
(
allAasyncRouterMap
,
allRoute
);
...
...
src/store/modules/app/index.js
View file @
49f97a05
import
sidebar
from
'./sidebar'
;
import
sidebar
from
'./sidebar'
;
import
collect
from
'./collect'
;
import
collect
from
'./collect'
;
import
{
FETCH_START
,
FETCH_DONE
}
from
'./mutation-types'
;
import
{
FETCH_START
,
FETCH_DONE
}
from
'./mutation-types'
;
const
GET_WHITE_LIST
=
'GET_WHITE_LIST'
;
let
fetchCount
=
0
;
let
fetchCount
=
0
;
const
state
=
()
=>
({
const
state
=
()
=>
({
loading
:
false
,
loading
:
false
,
whiteList
:
[],
});
});
const
getters
=
{
const
getters
=
{
loading
:
state
=>
state
.
loading
,
loading
:
state
=>
state
.
loading
,
whiteList
:
state
=>
state
.
whiteList
,
};
};
const
actions
=
{
const
actions
=
{
...
@@ -18,6 +21,9 @@ const actions = {
...
@@ -18,6 +21,9 @@ const actions = {
fetchDone
({
commit
},
notLoading
)
{
fetchDone
({
commit
},
notLoading
)
{
commit
(
FETCH_DONE
,
notLoading
);
commit
(
FETCH_DONE
,
notLoading
);
},
},
getWhiteList
({
commit
},
list
)
{
commit
(
GET_WHITE_LIST
,
list
);
},
};
};
const
mutations
=
{
const
mutations
=
{
[
FETCH_START
](
state
,
notLoading
)
{
[
FETCH_START
](
state
,
notLoading
)
{
...
@@ -34,6 +40,9 @@ const mutations = {
...
@@ -34,6 +40,9 @@ const mutations = {
state
.
loading
=
false
;
state
.
loading
=
false
;
}
}
},
},
[
GET_WHITE_LIST
](
state
,
list
)
{
state
.
whiteList
=
[...
state
.
whiteList
,
...
list
];
},
};
};
export
default
{
export
default
{
modules
:
{
modules
:
{
...
...
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