2019-03-19 03:26:07 -05:00
|
|
|
<template>
|
2021-11-19 04:36:12 -06:00
|
|
|
<div ref="thumbnail" class="zdjebgpv">
|
2020-10-17 06:12:00 -05:00
|
|
|
<ImgWithBlurhash v-if="isThumbnailAvailable" :hash="file.blurhash" :src="file.thumbnailUrl" :alt="file.name" :title="file.name" :style="`object-fit: ${ fit }`"/>
|
2021-04-20 09:22:59 -05:00
|
|
|
<i v-else-if="is === 'image'" class="fas fa-file-image icon"></i>
|
|
|
|
<i v-else-if="is === 'video'" class="fas fa-file-video icon"></i>
|
|
|
|
<i v-else-if="is === 'audio' || is === 'midi'" class="fas fa-music icon"></i>
|
|
|
|
<i v-else-if="is === 'csv'" class="fas fa-file-csv icon"></i>
|
|
|
|
<i v-else-if="is === 'pdf'" class="fas fa-file-pdf icon"></i>
|
|
|
|
<i v-else-if="is === 'textfile'" class="fas fa-file-alt icon"></i>
|
|
|
|
<i v-else-if="is === 'archive'" class="fas fa-file-archive icon"></i>
|
|
|
|
<i v-else class="fas fa-file icon"></i>
|
|
|
|
|
|
|
|
<i v-if="isThumbnailAvailable && is === 'video'" class="fas fa-film icon-sub"></i>
|
2019-03-19 03:26:07 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-01-18 08:06:16 -06:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue';
|
|
|
|
import * as Misskey from 'misskey-js';
|
2021-11-11 11:02:25 -06:00
|
|
|
import ImgWithBlurhash from '@/components/img-with-blurhash.vue';
|
2019-03-19 03:26:07 -05:00
|
|
|
|
2022-01-18 08:06:16 -06:00
|
|
|
const props = defineProps<{
|
|
|
|
file: Misskey.entities.DriveFile;
|
|
|
|
fit: string;
|
|
|
|
}>();
|
2019-03-19 03:26:07 -05:00
|
|
|
|
2022-01-18 08:06:16 -06:00
|
|
|
const is = computed(() => {
|
|
|
|
if (props.file.type.startsWith('image/')) return 'image';
|
|
|
|
if (props.file.type.startsWith('video/')) return 'video';
|
|
|
|
if (props.file.type === 'audio/midi') return 'midi';
|
|
|
|
if (props.file.type.startsWith('audio/')) return 'audio';
|
|
|
|
if (props.file.type.endsWith('/csv')) return 'csv';
|
|
|
|
if (props.file.type.endsWith('/pdf')) return 'pdf';
|
|
|
|
if (props.file.type.startsWith('text/')) return 'textfile';
|
|
|
|
if ([
|
|
|
|
"application/zip",
|
|
|
|
"application/x-cpio",
|
|
|
|
"application/x-bzip",
|
|
|
|
"application/x-bzip2",
|
|
|
|
"application/java-archive",
|
|
|
|
"application/x-rar-compressed",
|
|
|
|
"application/x-tar",
|
|
|
|
"application/gzip",
|
|
|
|
"application/x-7z-compressed"
|
|
|
|
].some(e => e === props.file.type)) return 'archive';
|
|
|
|
return 'unknown';
|
|
|
|
});
|
|
|
|
|
|
|
|
const isThumbnailAvailable = computed(() => {
|
|
|
|
return props.file.thumbnailUrl
|
|
|
|
? (is.value === 'image' as const || is.value === 'video')
|
|
|
|
: false;
|
2019-03-19 03:26:07 -05:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.zdjebgpv {
|
2020-02-07 05:25:49 -06:00
|
|
|
position: relative;
|
2021-12-09 19:46:29 -06:00
|
|
|
display: flex;
|
|
|
|
background: #e1e1e1;
|
|
|
|
border-radius: 8px;
|
|
|
|
overflow: clip;
|
2019-03-19 03:26:07 -05:00
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
> .icon-sub {
|
|
|
|
position: absolute;
|
|
|
|
width: 30%;
|
|
|
|
height: auto;
|
|
|
|
margin: 0;
|
|
|
|
right: 4%;
|
|
|
|
bottom: 4%;
|
|
|
|
}
|
2019-03-19 03:26:07 -05:00
|
|
|
|
2020-07-18 10:24:07 -05:00
|
|
|
> .icon {
|
|
|
|
pointer-events: none;
|
2021-12-09 19:46:29 -06:00
|
|
|
margin: auto;
|
|
|
|
font-size: 32px;
|
|
|
|
color: #777;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
2019-03-19 03:26:07 -05:00
|
|
|
</style>
|