FileNameDisplay.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="file-name-display" :class="{ 'file-name-pdf': is_pdf, 'file-name-others': !is_pdf }">
  3. <span class="file-name-icon"><img :src="img_src" /></span>
  4. <span class="file-name-label">{{ file_name }}</span>
  5. </div>
  6. </template>
  7. <script setup>
  8. import icon_excel from './files/excel.svg';
  9. import icon_word from './files/word-01.svg';
  10. import icon_pdf from './files/pdf.44344347.svg';
  11. const props = defineProps({
  12. file_name: String,
  13. file_id: String
  14. });
  15. /**
  16. * 文件后缀名
  17. */
  18. const file_endfix = (function () {
  19. const arr = props.file_name.split('.');
  20. const str = arr[arr.length - 1];
  21. return str;
  22. })();
  23. const is_pdf = file_endfix === 'pdf';
  24. const icon_map = {
  25. docx: icon_word,
  26. doc: icon_word,
  27. pdf: icon_pdf
  28. };
  29. const img_src = icon_map[file_endfix];
  30. </script>
  31. <style scoped>
  32. .file-name-display {
  33. display: flex;
  34. justify-content: flex-start;
  35. align-items: center;
  36. }
  37. .file-name-pdf {
  38. cursor: pointer;
  39. }
  40. .file-name-others {
  41. cursor: default;
  42. }
  43. .file-name-icon {
  44. display: inline-block;
  45. margin-right: 3px;
  46. /* height: 22px; */
  47. width: 16px;
  48. flex-shrink: 0;
  49. }
  50. .file-name-icon img {
  51. width: 100%;
  52. }
  53. .file-name-label {
  54. color: blue;
  55. display: -webkit-box;
  56. -webkit-box-orient: vertical;
  57. -webkit-line-clamp: 1; /* 这里设置显示的行数 */
  58. line-clamp: 1;
  59. overflow: hidden;
  60. }
  61. </style>