useAuthButtons.ts 595 B

12345678910111213141516171819202122
  1. import { computed } from "vue";
  2. import { useRoute } from "vue-router";
  3. import { useAuthStore } from "@/stores/modules/auth";
  4. /**
  5. * @description 页面按钮权限
  6. * */
  7. export const useAuthButtons = () => {
  8. const route = useRoute();
  9. const authStore = useAuthStore();
  10. const authButtons = authStore.authButtonListGet[route.name as string] || [];
  11. const BUTTONS = computed(() => {
  12. let currentPageAuthButton: { [key: string]: boolean } = {};
  13. authButtons.forEach(item => (currentPageAuthButton[item] = true));
  14. return currentPageAuthButton;
  15. });
  16. return {
  17. BUTTONS
  18. };
  19. };