PhotoDrawer.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <a-drawer :title="state.info.file_name" placement="right" :closable="true" v-model:visible="visible" :mask="true"
  3. getContainer="#g-container" :wrap-style="{ position: 'absolute' }" wrapClassName="drawer-element-wrapper"
  4. @close="closeDrawer" width="600">
  5. <div class="info">
  6. <div>
  7. <ClockCircleOutlined /> {{ state.info.picture_time }}
  8. </div>
  9. <div>
  10. {{ state.info.size > 0 ? (state.info.size / 1024 / 1024).toFixed(1) + 'M' : '--' }}
  11. </div>
  12. <div>
  13. <div v-if="state.info.image_width && state.info.image_height">
  14. {{ state.info.image_width }}*{{ state.info.image_height }}
  15. </div>
  16. <div v-else>
  17. --
  18. </div>
  19. </div>
  20. <div>
  21. <span style="margin-right: 10px;">
  22. {{ state.info.latitude }}° N
  23. </span>
  24. <span>
  25. {{ state.info.longitude }}° E
  26. </span>
  27. </div>
  28. </div>
  29. <div class="image">
  30. <div class="image-background" v-if="state.imgLoading">
  31. <a-spin tip="加载中..." />
  32. </div>
  33. <Panoramic :src="state.info.url" v-else-if="state.info.media_type === 3" />
  34. <a-image width="100%" height="100%" style="object-fit: cover;" :src="state.info.url" :preview="false" v-else />
  35. </div>
  36. <div class="previewList">
  37. <div class="previewList-item">
  38. <img :src="state.info.thumbnail_url" />
  39. </div>
  40. </div>
  41. </a-drawer>
  42. </template>
  43. <script lang="ts" setup>
  44. import { reactive, watch } from 'vue';
  45. import { ClockCircleOutlined } from '@ant-design/icons-vue';
  46. import Panoramic from '/@/components/panoramic/index.vue';
  47. import { getWorkspaceId } from '/@/utils';
  48. import { apis } from '/@/api/custom';
  49. interface Props {
  50. visible: boolean,
  51. fileId: string,
  52. closeDrawer: () => void,
  53. };
  54. const props = withDefaults(defineProps<Props>(), {
  55. });
  56. const state = reactive({
  57. imgLoading: false,// 图片加载
  58. info: {
  59. url: '',
  60. thumbnail_url: '',// 缩略图
  61. media_type: 0,
  62. file_name: '',
  63. image_width: '',// 照片分辨率-宽度
  64. image_height: '',// 照片分辨率-高度
  65. size: 0,
  66. picture_time: '',// 拍摄时间
  67. longitude: '',// 经度
  68. latitude: '',// 纬度
  69. },
  70. })
  71. watch(() => props.fileId, async (newValue) => {
  72. if (props.visible && newValue) {
  73. const fileId = newValue.replace(/^resource__/, '');
  74. try {
  75. const res = await apis.fetchFileDetail(getWorkspaceId(), fileId);
  76. state.info = res.data;
  77. state.imgLoading = true;
  78. const img = new Image();
  79. img.src = state.info.url;
  80. img.onload = () => {
  81. state.imgLoading = false;
  82. };
  83. } catch (e) {
  84. console.error(e);
  85. }
  86. }
  87. });
  88. </script>
  89. <style lang="scss" scoped>
  90. .info {
  91. display: flex;
  92. justify-content: space-between;
  93. align-items: center;
  94. margin-bottom: 24px;
  95. }
  96. .image {
  97. width: 100%;
  98. height: 500px;
  99. &-background {
  100. width: 100%;
  101. height: 100%;
  102. padding: 100px;
  103. display: flex;
  104. justify-content: center;
  105. align-items: center;
  106. }
  107. }
  108. .previewList {
  109. width: 100%;
  110. height: 70px;
  111. display: flex;
  112. justify-content: center;
  113. margin-top: 24px;
  114. &-item {
  115. width: 80px;
  116. height: 60px;
  117. border: 2px solid $primary;
  118. border-radius: 4px;
  119. margin-bottom: 10px;
  120. cursor: pointer;
  121. img {
  122. width: 100%;
  123. height: 100%;
  124. object-fit: cover;
  125. }
  126. }
  127. }
  128. </style>