YY 2 years ago
parent
commit
9ce4a29fb6
1 changed files with 29 additions and 6 deletions
  1. 29 6
      src/components/admin-frame/parts/Sidebar.vue

+ 29 - 6
src/components/admin-frame/parts/Sidebar.vue

@@ -60,17 +60,40 @@ import store from '@/stores/counter'
 import type { Ref } from 'vue'
 import { ref, onMounted, watch } from 'vue'
 import { useRoute } from 'vue-router'
-// import { RoleStore } from '@common/src/stores/admin/role' //模块
-// import type { IQueryResult } from '@/util/types.util'
-// const role = RoleStore()
+import { ModuleStore } from '@common/src/stores/system/module' //模块
+import { RoleStore } from '@common/src/stores/system/role' //模块
+import type { IQueryResult } from '@/util/types.util' //
+const module = ModuleStore()
+const role = RoleStore()
 const route = useRoute()
 let onRoutes = route.path
-let user: Ref<any> = ref(store.state.user)
+let user: Ref<any> = ref({})
 const styleInfo: Ref<any> = ref(menuInfo.info)
 let items: Ref<any> = ref(admin)
-onMounted(async () => {})
+onMounted(async () => {
+  user.value = store.state.user
+})
 
-const getMenu = async () => {}
+const getMenu = async () => {
+  let name = import.meta.env.VITE_APP_ROUTER
+  const res: IQueryResult = await module.query({ name: name, is_use: '0' })
+  if (res && res.errcode == '0') {
+    if (res.total > 0) {
+      let moduleInfo = res.data[0]
+      let roleInfo: IQueryResult = await role.um()
+      if (roleInfo.errcode == '0') {
+        if (roleInfo.data) {
+          let menus = roleInfo.data[moduleInfo._id]
+          if (menus && menus.length > 0) {
+            items.value = menus
+          }
+        }
+      }
+    }
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' })
+  }
+}
 
 watch(
   user,