From b5f8aefa1901d879e0f434af0ab2e69c687c7e86 Mon Sep 17 00:00:00 2001 From: zhuzhile Date: Mon, 13 Apr 2020 14:21:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(/main.js):=20=E7=BB=99=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E9=99=90=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 5 ++++- src/router/router.js | 1 + src/store/modules/app.js | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index fb16470..c434c2f 100644 --- a/src/main.js +++ b/src/main.js @@ -43,7 +43,10 @@ new Vue({ router, store, mounted(){ - this.$store.commit('updateMenuList', appRouters); + // if(localStorage) + // 这里需要做判断是否是owner角色登录 + this.$store.commit('initMenuList', appRouters); + // this.$store.commit('updateMenuList', appRouters); }, render: h => h(App) }).$mount('#app') diff --git a/src/router/router.js b/src/router/router.js index 0de6ca5..e8db136 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -49,6 +49,7 @@ export const appRouters = [ name:'markdownEditor', title:'markdown编辑', icon:'md-brush', + access: 1, component:Home, children:[ { diff --git a/src/store/modules/app.js b/src/store/modules/app.js index fc0e842..06a12a5 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -3,6 +3,15 @@ const app = { menuList:[] }, mutations:{ + // 以游客身份登入或者尚未登录 + initMenuList(state, router){ + router.forEach(element => { + if(!element.access){ + state.menuList.push(element); + } + }); + }, + // 以管理员的角色登录 updateMenuList(state, router){ console.log("something"); console.log(router); -- GitLab