Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

wren 1 anno fa
parent
commit
c0b69bb308

+ 8 - 0
front/admin-front/src/api/user.js

@@ -104,3 +104,11 @@ export function updatePassword(params) {
     data: params
   })
 }
+
+//获取当前用户的菜单ID数组
+export function getUserRights() {
+  return request({
+    url:  'uc/menu/current/user/menu',
+    method: 'get',
+  })
+}

+ 78 - 3
front/admin-front/src/layout/components/Sidebar/index.vue

@@ -53,6 +53,7 @@ import Logo from "./Logo";
 import SidebarItem from "./SidebarItem";
 import variables from "@/styles/variables.scss";
 import Hamburger from "@/components/Hamburger";
+import {getUserRights} from "@/api/user";
 
 export default {
   components: {
@@ -60,13 +61,20 @@ export default {
     Logo,
     Hamburger,
   },
+  data(){
+    return {
+      routes:[]
+    }
+  },
   computed: {
     ...mapGetters(["sidebar"]),
-    routes() {
-      return this.$router.options.routes;
-    },
+    // routes() {
+    //   console.log(this.$router.options.routes);
+    //   return this.$router.options.routes;
+    // },
     activeMenu() {
       const route = this.$route;
+
       const { meta, path } = route;
       // if set path, the sidebar will highlight the path you set
       if (meta.activeMenu) {
@@ -84,10 +92,77 @@ export default {
       return !this.sidebar.opened;
     },
   },
+  beforeMount() {
+    this.getRightsInfo()
+  },
+
   methods: {
     toggleSideBar() {
       this.$store.dispatch("app/toggleSideBar");
     },
+    // 690f84fec2374880b922d62e614245ea	数据看板
+    // 2caf11b463de4eeeaaa1f42c7f443270	用户管理
+    // 5501cc476bc14e63ae6de0e8515d1f99	系统参数
+    // c05b49809dbe45f6a18695b7aef4558b	任务管理
+    // 0c78a0fff4bd47bd9fef257f03f6410a	项目管理
+    // 4bf360eec98e432992019426ed430800	地址管理
+
+    // a9b295e9bbcc4a8580b8932589612442	编辑任务
+    // c3b727c313e24e21b720ccbbc229395f	新增任务
+    getRightsInfo() {
+      let Arr = ['690f84fec2374880b922d62e614245ea','2caf11b463de4eeeaaa1f42c7f443270',
+      '5501cc476bc14e63ae6de0e8515d1f99','c05b49809dbe45f6a18695b7aef4558b','0c78a0fff4bd47bd9fef257f03f6410a',
+      '4bf360eec98e432992019426ed430800','a9b295e9bbcc4a8580b8932589612442','c3b727c313e24e21b720ccbbc229395f']
+      getUserRights().then(res=>{
+        console.log(res);
+        console.log(this.$router.options.routes);
+        let showRoutes = this.$router.options.routes
+        Arr.forEach((item,index)=>{
+          let result = res.includes(item)
+          if(!result){
+            if(index === 0) {
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 1){
+              let inx = showRoutes.findIndex(el=>{
+               return el.path === '/user'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 2){
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/sys-param'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 3){
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/autoplay'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 4){
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/airdrop'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 5){
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/address'
+              })
+              showRoutes.splice(inx,1)
+            }
+          }else {
+            if (index === 6){
+              this.$store.commit('changeEditTask')
+            }else if (index === 7){
+              this.$store.commit('changeAddTask')
+            }
+          }
+        })
+        this.routes = showRoutes
+      })
+    },
+
   },
 };
 </script>

+ 13 - 1
front/admin-front/src/store/index.js

@@ -13,7 +13,19 @@ const store = new Vuex.Store({
     settings,
     user
   },
-  getters
+  getters,
+  state:{
+    editTask:false,
+    addTask:false
+  },
+  mutations: {
+    changeEditTask (state) {
+      state.editTask = true
+    },
+    changeAddTask (state) {
+      state.addTask = true
+    }
+  }
 })
 
 export default store

+ 2 - 2
front/admin-front/src/views/autoplay/index.vue

@@ -4,7 +4,7 @@
       <div class="title">
         任务列表
       </div>
-      <div class="add">
+      <div class="add" v-if="$store.state.addTask">
         <div class="button" @click="addTaskDetails">
           <img src="../../assets/airdrop/add.svg" alt="add">
           添加任务
@@ -110,7 +110,7 @@
               </div>
             </div>
           </div>
-          <div class="drawerAddress-container-head-right">
+          <div class="drawerAddress-container-head-right" v-if="$store.state.editTask">
             <div class="complete" @click="modifyTask">
               <img src="../../assets/address/done_all.svg" alt="done_all">
               完成