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