2019-03-19 10:26:07 +02:00
|
|
|
<template>
|
2020-07-18 18:24:07 +03:00
|
|
|
<div class="zdjebgpv" ref="thumbnail">
|
2020-10-17 14:12:00 +03:00
|
|
|
<ImgWithBlurhash v-if="isThumbnailAvailable" :hash="file.blurhash" :src="file.thumbnailUrl" :alt="file.name" :title="file.name" :style="`object-fit: ${ fit }`"/>
|
|
|
|
<Fa :icon="faFileImage" class="icon" v-else-if="is === 'image'"/>
|
|
|
|
<Fa :icon="faFileVideo" class="icon" v-else-if="is === 'video'"/>
|
|
|
|
<Fa :icon="faMusic" class="icon" v-else-if="is === 'audio' || is === 'midi'"/>
|
|
|
|
<Fa :icon="faFileCsv" class="icon" v-else-if="is === 'csv'"/>
|
|
|
|
<Fa :icon="faFilePdf" class="icon" v-else-if="is === 'pdf'"/>
|
|
|
|
<Fa :icon="faFileAlt" class="icon" v-else-if="is === 'textfile'"/>
|
|
|
|
<Fa :icon="faFileArchive" class="icon" v-else-if="is === 'archive'"/>
|
|
|
|
<Fa :icon="faFile" class="icon" v-else/>
|
|
|
|
<Fa :icon="faFilm" class="icon-sub" v-if="isThumbnailAvailable && is === 'video'"/>
|
2019-03-19 10:26:07 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2019-03-19 10:26:07 +02:00
|
|
|
import {
|
|
|
|
faFile,
|
|
|
|
faFileAlt,
|
|
|
|
faFileImage,
|
|
|
|
faMusic,
|
|
|
|
faFileVideo,
|
|
|
|
faFileCsv,
|
|
|
|
faFilePdf,
|
|
|
|
faFileArchive,
|
|
|
|
faFilm
|
|
|
|
} from '@fortawesome/free-solid-svg-icons';
|
2020-07-18 18:24:07 +03:00
|
|
|
import ImgWithBlurhash from './img-with-blurhash.vue';
|
2019-03-19 10:26:07 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2020-07-18 18:24:07 +03:00
|
|
|
components: {
|
|
|
|
ImgWithBlurhash
|
|
|
|
},
|
2019-03-19 10:26:07 +02:00
|
|
|
props: {
|
|
|
|
file: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
fit: {
|
|
|
|
type: String,
|
2019-09-01 23:42:30 +03:00
|
|
|
required: false,
|
|
|
|
default: 'cover'
|
2019-03-19 10:26:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isContextmenuShowing: false,
|
|
|
|
isDragging: false,
|
|
|
|
|
|
|
|
faFile,
|
|
|
|
faFileAlt,
|
|
|
|
faFileImage,
|
|
|
|
faMusic,
|
|
|
|
faFileVideo,
|
|
|
|
faFileCsv,
|
|
|
|
faFilePdf,
|
|
|
|
faFileArchive,
|
|
|
|
faFilm
|
|
|
|
};
|
|
|
|
},
|
|
|
|
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 16:35:22 +02:00
|
|
|
return this.file.thumbnailUrl
|
2019-04-14 11:12:04 +03:00
|
|
|
? (this.is === 'image' || this.is === 'video')
|
2019-03-19 16:35:22 +02:00
|
|
|
: false;
|
2019-03-19 10:26:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
const audioTag = this.$refs.volumectrl as HTMLAudioElement;
|
|
|
|
if (audioTag) audioTag.volume = this.$store.state.device.mediaVolume;
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
volumechange() {
|
|
|
|
const audioTag = this.$refs.volumectrl as HTMLAudioElement;
|
|
|
|
this.$store.commit('device/set', { key: 'mediaVolume', value: audioTag.volume });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.zdjebgpv {
|
2020-02-07 13:25:49 +02:00
|
|
|
position: relative;
|
2019-03-19 10:26:07 +02:00
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
> .icon-sub {
|
|
|
|
position: absolute;
|
|
|
|
width: 30%;
|
|
|
|
height: auto;
|
|
|
|
margin: 0;
|
|
|
|
right: 4%;
|
|
|
|
bottom: 4%;
|
|
|
|
}
|
2019-03-19 10:26:07 +02:00
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
> * {
|
|
|
|
margin: auto;
|
|
|
|
}
|
2019-04-05 18:51:31 +03:00
|
|
|
|
2020-07-18 18:24:07 +03:00
|
|
|
> .icon {
|
|
|
|
pointer-events: none;
|
|
|
|
height: 65%;
|
|
|
|
width: 65%;
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
}
|
2019-03-19 10:26:07 +02:00
|
|
|
</style>
|