Commit 13acaf82 by 姜雷

Merge branch 'develop' into 'test'

白名单在store中维护 See merge request !20
parents 8b0c2a2d 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 => {
......
...@@ -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);
......
...@@ -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({
......
...@@ -8,18 +8,10 @@ const configRoutePermission = ( ...@@ -8,18 +8,10 @@ const configRoutePermission = (
router, router,
store, store,
allAasyncRouterMap, allAasyncRouterMap,
addwhiteList 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);
......
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: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment