2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2019-03-19 09:26:07 +01:00
|
|
|
<template>
|
2023-05-19 06:58:09 +02:00
|
|
|
<div ref="thumbnail" :class="$style.root">
|
2022-06-16 09:05:43 +02:00
|
|
|
<ImgWithBlurhash v-if="isThumbnailAvailable" :hash="file.blurhash" :src="file.thumbnailUrl" :alt="file.name" :title="file.name" :cover="fit !== 'contain'"/>
|
2023-09-30 21:53:52 +02:00
|
|
|
<i v-else-if="is === 'image'" class="ph-image-square ph-bold ph-lg" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'video'" class="ph-video ph-bold ph-lg" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'audio' || is === 'midi'" class="ph-file-audio ph-bold ph-lg" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'csv'" class="ph-file-text ph-bold ph-lg" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'pdf'" class="ph-file-text ph-bold ph-lg" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'textfile'" class="ph-file-text ph-bold ph-lg" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'archive'" class="ph-file-zip ph-bold ph-lg" :class="$style.icon"></i>
|
|
|
|
<i v-else class="ph-file ph-bold ph-lg" :class="$style.icon"></i>
|
2021-04-20 16:22:59 +02:00
|
|
|
|
2023-09-30 21:53:52 +02:00
|
|
|
<i v-if="isThumbnailAvailable && is === 'video'" class="ph-video ph-bold ph-lg" :class="$style.iconSub"></i>
|
2019-03-19 09:26:07 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue';
|
|
|
|
import * as Misskey from 'misskey-js';
|
2022-08-30 17:24:33 +02:00
|
|
|
import ImgWithBlurhash from '@/components/MkImgWithBlurhash.vue';
|
2019-03-19 09:26:07 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const props = defineProps<{
|
|
|
|
file: Misskey.entities.DriveFile;
|
|
|
|
fit: string;
|
|
|
|
}>();
|
2019-03-19 09:26:07 +01:00
|
|
|
|
2022-01-18 15:06:16 +01: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 ([
|
2022-06-16 09:05:43 +02:00
|
|
|
'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(archiveType => archiveType === props.file.type)) return 'archive';
|
2022-01-18 15:06:16 +01:00
|
|
|
return 'unknown';
|
|
|
|
});
|
|
|
|
|
|
|
|
const isThumbnailAvailable = computed(() => {
|
|
|
|
return props.file.thumbnailUrl
|
|
|
|
? (is.value === 'image' as const || is.value === 'video')
|
|
|
|
: false;
|
2019-03-19 09:26:07 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-05-19 06:58:09 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-02-07 12:25:49 +01:00
|
|
|
position: relative;
|
2021-12-10 02:46:29 +01:00
|
|
|
display: flex;
|
2022-06-20 10:38:49 +02:00
|
|
|
background: var(--panel);
|
2023-10-31 19:44:34 +01:00
|
|
|
border-radius: var(--radius-sm);
|
2022-07-13 14:41:06 +02:00
|
|
|
overflow: clip;
|
2023-05-19 06:58:09 +02:00
|
|
|
}
|
2019-03-19 09:26:07 +01:00
|
|
|
|
2023-05-19 06:58:09 +02:00
|
|
|
.iconSub {
|
|
|
|
position: absolute;
|
|
|
|
width: 30%;
|
|
|
|
height: auto;
|
|
|
|
margin: 0;
|
|
|
|
right: 4%;
|
|
|
|
bottom: 4%;
|
|
|
|
}
|
2019-03-19 09:26:07 +01:00
|
|
|
|
2023-05-19 06:58:09 +02:00
|
|
|
.icon {
|
|
|
|
pointer-events: none;
|
|
|
|
margin: auto;
|
|
|
|
font-size: 32px;
|
|
|
|
color: #777;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2019-03-19 09:26:07 +01:00
|
|
|
</style>
|