2019-03-19 08:26:07 +00:00
|
|
|
<template>
|
2020-07-18 15:24:07 +00:00
|
|
|
<div class="zdjebgpv" ref="thumbnail">
|
2020-10-17 11:12:00 +00:00
|
|
|
<ImgWithBlurhash v-if="isThumbnailAvailable" :hash="file.blurhash" :src="file.thumbnailUrl" :alt="file.name" :title="file.name" :style="`object-fit: ${ fit }`"/>
|
2021-04-20 14:22:59 +00: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 08:26:07 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2021-04-16 03:06:54 +00:00
|
|
|
import ImgWithBlurhash from '@client/components/img-with-blurhash.vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import { ColdDeviceStorage } from '@client/store';
|
2019-03-19 08:26:07 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-07-18 15:24:07 +00:00
|
|
|
components: {
|
|
|
|
ImgWithBlurhash
|
|
|
|
},
|
2019-03-19 08:26:07 +00:00
|
|
|
props: {
|
|
|
|
file: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
fit: {
|
|
|
|
type: String,
|
2019-09-01 20:42:30 +00:00
|
|
|
required: false,
|
|
|
|
default: 'cover'
|
2019-03-19 08:26:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isContextmenuShowing: false,
|
|
|
|
isDragging: false,
|
|
|
|
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
is(): 'image' | 'video' | 'midi' | 'audio' | 'csv' | 'pdf' | 'textfile' | 'archive' | 'unknown' {
|
|
|
|
if (this.file.type.startsWith('image/')) return 'image';
|
|
|
|
if (this.file.type.startsWith('video/')) return 'video';
|
|
|
|
if (this.file.type === 'audio/midi') return 'midi';
|
|
|
|
if (this.file.type.startsWith('audio/')) return 'audio';
|
|
|
|
if (this.file.type.endsWith('/csv')) return 'csv';
|
|
|
|
if (this.file.type.endsWith('/pdf')) return 'pdf';
|
|
|
|
if (this.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 === this.file.type)) return 'archive';
|
|
|
|
return 'unknown';
|
|
|
|
},
|
|
|
|
isThumbnailAvailable(): boolean {
|
2019-03-19 14:35:22 +00:00
|
|
|
return this.file.thumbnailUrl
|
2019-04-14 08:12:04 +00:00
|
|
|
? (this.is === 'image' || this.is === 'video')
|
2019-03-19 14:35:22 +00:00
|
|
|
: false;
|
2019-03-19 08:26:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
const audioTag = this.$refs.volumectrl as HTMLAudioElement;
|
2020-12-19 01:55:52 +00:00
|
|
|
if (audioTag) audioTag.volume = ColdDeviceStorage.get('mediaVolume');
|
2019-03-19 08:26:07 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
volumechange() {
|
|
|
|
const audioTag = this.$refs.volumectrl as HTMLAudioElement;
|
2020-12-19 01:55:52 +00:00
|
|
|
ColdDeviceStorage.set('mediaVolume', audioTag.volume);
|
2019-03-19 08:26:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.zdjebgpv {
|
2020-02-07 11:25:49 +00:00
|
|
|
position: relative;
|
2019-03-19 08:26:07 +00:00
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
> .icon-sub {
|
|
|
|
position: absolute;
|
|
|
|
width: 30%;
|
|
|
|
height: auto;
|
|
|
|
margin: 0;
|
|
|
|
right: 4%;
|
|
|
|
bottom: 4%;
|
|
|
|
}
|
2019-03-19 08:26:07 +00:00
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
> * {
|
|
|
|
margin: auto;
|
|
|
|
}
|
2019-04-05 15:51:31 +00:00
|
|
|
|
2020-07-18 15:24:07 +00:00
|
|
|
> .icon {
|
|
|
|
pointer-events: none;
|
|
|
|
height: 65%;
|
|
|
|
width: 65%;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-19 08:26:07 +00:00
|
|
|
</style>
|