MenuIcon.vue 648 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <img class="menu-icon" :src="iconSrc" :alt="name" />
  3. </template>
  4. <script setup>
  5. import { computed } from "vue";
  6. import deviceIcon from "@/assets/layout/device.png";
  7. import leafIcon from "@/assets/layout/leaf.png";
  8. import personIcon from "@/assets/layout/person.png";
  9. const props = defineProps({
  10. name: {
  11. type: String,
  12. required: true,
  13. },
  14. });
  15. const iconMap = {
  16. device: deviceIcon,
  17. planting: leafIcon,
  18. personnel: personIcon,
  19. };
  20. const iconSrc = computed(() => iconMap[props.name] || deviceIcon);
  21. </script>
  22. <style scoped>
  23. .menu-icon {
  24. display: block;
  25. width: 18px;
  26. height: 22px;
  27. object-fit: contain;
  28. }
  29. </style>