|
@@ -1,10 +1,11 @@
|
|
|
-import { ref } from 'vue'
|
|
|
+import { ref, computed } from 'vue'
|
|
|
import { defineStore } from 'pinia'
|
|
|
import {
|
|
|
deleteSessionVar,
|
|
|
getSessionVar,
|
|
|
saveSessionVar,
|
|
|
} from "@/utils/session";
|
|
|
+
|
|
|
export const useMenuStore = defineStore('menu', () => {
|
|
|
let routeList = ref(getSessionVar("routeList") ? JSON.parse(getSessionVar("routeList")) : [])
|
|
|
// const routeList = ref([{
|
|
@@ -38,9 +39,20 @@ export const useMenuStore = defineStore('menu', () => {
|
|
|
// children: []
|
|
|
// }
|
|
|
// ])
|
|
|
+ const operationPermissions = computed(() => {
|
|
|
+ let permissions = {}
|
|
|
+ routeList.value.forEach(i => {
|
|
|
+ if (Array.isArray(i)) {
|
|
|
+ i.children.forEach(j => {
|
|
|
+ permissions[j.key] = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ return permissions
|
|
|
+ })
|
|
|
const updateRouteList = (newRoutes) => {
|
|
|
routeList.value = newRoutes; // 更新路由列表
|
|
|
};
|
|
|
- return { routeList, updateRouteList }
|
|
|
+ return { routeList, updateRouteList, operationPermissions }
|
|
|
})
|