2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
2024-02-13 09:59:27 -06:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 00:31:52 -05:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2019-03-19 03:26:07 -05:00
|
|
|
<template>
|
2024-09-15 03:50:25 -05:00
|
|
|
<div
|
|
|
|
ref="thumbnail"
|
|
|
|
:class="[
|
|
|
|
$style.root,
|
|
|
|
{ [$style.sensitiveHighlight]: highlightWhenSensitive && file.isSensitive },
|
|
|
|
]"
|
|
|
|
>
|
2022-06-16 02:05:43 -05:00
|
|
|
<ImgWithBlurhash v-if="isThumbnailAvailable" :hash="file.blurhash" :src="file.thumbnailUrl" :alt="file.name" :title="file.name" :cover="fit !== 'contain'"/>
|
2023-05-18 23:58:09 -05:00
|
|
|
<i v-else-if="is === 'image'" class="ti ti-photo" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'video'" class="ti ti-video" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'audio' || is === 'midi'" class="ti ti-file-music" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'csv'" class="ti ti-file-text" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'pdf'" class="ti ti-file-text" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'textfile'" class="ti ti-file-text" :class="$style.icon"></i>
|
|
|
|
<i v-else-if="is === 'archive'" class="ti ti-file-zip" :class="$style.icon"></i>
|
|
|
|
<i v-else class="ti ti-file" :class="$style.icon"></i>
|
2021-04-20 09:22:59 -05:00
|
|
|
|
2023-05-18 23:58:09 -05:00
|
|
|
<i v-if="isThumbnailAvailable && is === 'video'" class="ti ti-video" :class="$style.iconSub"></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';
|
2022-08-30 10:24:33 -05:00
|
|
|
import ImgWithBlurhash from '@/components/MkImgWithBlurhash.vue';
|
2019-03-19 03:26:07 -05:00
|
|
|
|
2022-01-18 08:06:16 -06:00
|
|
|
const props = defineProps<{
|
|
|
|
file: Misskey.entities.DriveFile;
|
2024-07-30 05:48:16 -05:00
|
|
|
fit: 'cover' | 'contain';
|
2024-09-15 03:50:25 -05:00
|
|
|
highlightWhenSensitive?: boolean;
|
2022-01-18 08:06:16 -06:00
|
|
|
}>();
|
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 ([
|
2022-06-16 02:05:43 -05: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 08:06:16 -06:00
|
|
|
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>
|
|
|
|
|
2023-05-18 23:58:09 -05:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-02-07 05:25:49 -06:00
|
|
|
position: relative;
|
2021-12-09 19:46:29 -06:00
|
|
|
display: flex;
|
2022-06-20 03:38:49 -05:00
|
|
|
background: var(--panel);
|
2021-12-09 19:46:29 -06:00
|
|
|
border-radius: 8px;
|
2022-07-13 07:41:06 -05:00
|
|
|
overflow: clip;
|
2023-05-18 23:58:09 -05:00
|
|
|
}
|
2019-03-19 03:26:07 -05:00
|
|
|
|
2024-09-15 03:50:25 -05:00
|
|
|
.sensitiveHighlight::after {
|
|
|
|
content: "";
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
pointer-events: none;
|
|
|
|
border-radius: inherit;
|
|
|
|
box-shadow: inset 0 0 0 4px var(--warn);
|
|
|
|
}
|
|
|
|
|
2023-05-18 23:58:09 -05:00
|
|
|
.iconSub {
|
|
|
|
position: absolute;
|
|
|
|
width: 30%;
|
|
|
|
height: auto;
|
|
|
|
margin: 0;
|
|
|
|
right: 4%;
|
|
|
|
bottom: 4%;
|
|
|
|
}
|
2019-03-19 03:26:07 -05:00
|
|
|
|
2023-05-18 23:58:09 -05:00
|
|
|
.icon {
|
|
|
|
pointer-events: none;
|
|
|
|
margin: auto;
|
|
|
|
font-size: 32px;
|
|
|
|
color: #777;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
2019-03-19 03:26:07 -05:00
|
|
|
</style>
|