sunlupeng 1 year ago
parent
commit
9b48607bfd
1 changed files with 24 additions and 10 deletions
  1. 24 10
      src/permission.js

+ 24 - 10
src/permission.js

@@ -17,16 +17,27 @@ function hasPermission(roles, permissionRoles) {
 const whiteList = ['/login', '/authredirect']// no redirect whitelist
 //自定义路由
 const myRoles = [
+  'answerGame', 
+  'answerList', 
+  
+  'raffleManage', 
+  'raffleList', 
+  'raffleDataList', 
+
   'goodsManage', 
   'goodsExchangeRules', 
   'goodsList', 
+
   'giftManage', 
   'giftExchangeRules', 
   'giftList', 
+
   'welfareManage', 
   'welfareList', 
+
   'exchangeManage', 
   'exchangeList',
+
   'cancelledList',
   'approvalList',
   'pasList',
@@ -37,31 +48,34 @@ const myRoles = [
   'pointRulesList', 
   'pointList', 
   'pointsDetailList',
+
   'activityManage', 
   'activityList', 
-  'activityManage', 
-  'answerGame', 
-  'answerList', 
-  'answerGame', 
-  'raffleManage', 
-  'raffleList', 
-  'raffleDataList', 
+
+  'noticeManage', 
+  'noticeList', 
+
   'ranking',
   'rankingList',
+
   'medalManage', 
   'medalList', 
-  'medalDataList', 
+  'medalDataList',
+
   'commendManage', 
   'commendList',
   'commendDataList', 
   'citeList',
   'operateCiteList',
   'ceoCiteList',
+
   'festivalManage', 
   'festivalList', 
+
   'certManage', 
   'certRules',
   'certList', 
+
   'dictManage', 
   'dictList', 
   'dictDataList', 
@@ -85,8 +99,8 @@ router.beforeEach((to, from, next) => {
       if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
         store.dispatch('GetUserInfo').then(res => {
           store.dispatch('GetUserMenus').then(res => { // 拉取user_info
-            // const roles = res.data.data // note: roles must be a array! such as: ['editor','develop']
-            const roles = myRoles;
+            const roles = res.data.data // note: roles must be a array! such as: ['editor','develop']
+            // const roles = myRoles;
             store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
               router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
               next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record