Commit 13acaf82 by 姜雷

Merge branch 'develop' into 'test'

白名单在store中维护 See merge request !20
parents 8b0c2a2d 49f97a05
......@@ -50,8 +50,7 @@
import UserBox from './containers/layout/components/UserBox';
import IconMenus from './containers/layout/IconMenu/IconMenu';
import CollectMenu from './containers/layout/Collect/Collect';
const whiteList = process.env.VUE_APP_WHITE_LIST.split(','); // 不重定向白名单
import { mapGetters } from 'vuex';
export default {
name: 'App',
......@@ -76,6 +75,7 @@ export default {
};
},
computed: {
...mapGetters(['whiteList']),
dashboardVisiable() {
return this.$route.name === 'dashboard';
},
......@@ -100,7 +100,7 @@ export default {
methods: {
showComponents(store) {
this.isInnerPage =
whiteList.indexOf(this.$route.path) !== -1 ? false : true;
this.whiteList.indexOf(this.$route.path) !== -1 ? false : true;
if (store) {
store.install(this.$store);
this.$nextTick(vm => {
......
......@@ -12,6 +12,18 @@ setTimeout(() => {
System.createSystem({
basePath: process.env.VUE_APP_BASE_URL,
routers: allAasyncRouterMap,
constantRouter: [
{
path: '/asd',
name: 'asd',
component: {
render(h) {
return <div>asdasdasd</div>;
},
},
},
],
whiteList: '/asd',
routeFilter: (routes, allRoute) => {
if (allRoute && allRoute.length) {
let addRoute = System.utils.route.formatRouteLink(allRoute);
......
......@@ -42,7 +42,17 @@ class SystemShell {
});
routeStore.install(store);
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;
let app = new Vue({
......
......@@ -8,18 +8,10 @@ const configRoutePermission = (
router,
store,
allAasyncRouterMap,
addwhiteList
whiteList
) => {
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 = () => {
let allRoute = store.getters.asyncRoutes;
let asyncRouters = getAuthRoute(allAasyncRouterMap, allRoute);
......
import sidebar from './sidebar';
import collect from './collect';
import { FETCH_START, FETCH_DONE } from './mutation-types';
const GET_WHITE_LIST = 'GET_WHITE_LIST';
let fetchCount = 0;
const state = () => ({
loading: false,
whiteList: [],
});
const getters = {
loading: state => state.loading,
whiteList: state => state.whiteList,
};
const actions = {
......@@ -18,6 +21,9 @@ const actions = {
fetchDone({ commit }, notLoading) {
commit(FETCH_DONE, notLoading);
},
getWhiteList({ commit }, list) {
commit(GET_WHITE_LIST, list);
},
};
const mutations = {
[FETCH_START](state, notLoading) {
......@@ -34,6 +40,9 @@ const mutations = {
state.loading = false;
}
},
[GET_WHITE_LIST](state, list) {
state.whiteList = [...state.whiteList, ...list];
},
};
export default {
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