FileIcon.vue 543 B

123456789101112131415161718192021222324252627
  1. <template>
  2. <img :src="icon_src" :alt="file_type" class="file-icon" />
  3. </template>
  4. <script setup>
  5. import { computed } from 'vue';
  6. const props = defineProps({
  7. name: String
  8. });
  9. const getExtension = (name) => {
  10. return name?.slice(name.lastIndexOf('.') + 1).toLowerCase() ?? '';
  11. };
  12. const icon_src = computed(() => {
  13. return new URL(`../../assets/ai-search/${getExtension(props.name)}.svg`, import.meta.url).href;
  14. });
  15. </script>
  16. <style scoped>
  17. .file-icon {
  18. width: 24px;
  19. height: 24px;
  20. background-color: var(--color-bg-1);
  21. }
  22. </style>