components/drive-file-thumbnail.vue
This commit is contained in:
parent
2f128bcd3c
commit
e67b06cc4e
1 changed files with 33 additions and 62 deletions
|
@ -14,71 +14,42 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
import * as Misskey from 'misskey-js';
|
||||||
import ImgWithBlurhash from '@/components/img-with-blurhash.vue';
|
import ImgWithBlurhash from '@/components/img-with-blurhash.vue';
|
||||||
import { ColdDeviceStorage } from '@/store';
|
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps<{
|
||||||
components: {
|
file: Misskey.entities.DriveFile;
|
||||||
ImgWithBlurhash
|
fit: string;
|
||||||
},
|
}>();
|
||||||
props: {
|
|
||||||
file: {
|
|
||||||
type: Object,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
fit: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: 'cover'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
isContextmenuShowing: false,
|
|
||||||
isDragging: false,
|
|
||||||
|
|
||||||
};
|
const is = computed(() => {
|
||||||
},
|
if (props.file.type.startsWith('image/')) return 'image';
|
||||||
computed: {
|
if (props.file.type.startsWith('video/')) return 'video';
|
||||||
is(): 'image' | 'video' | 'midi' | 'audio' | 'csv' | 'pdf' | 'textfile' | 'archive' | 'unknown' {
|
if (props.file.type === 'audio/midi') return 'midi';
|
||||||
if (this.file.type.startsWith('image/')) return 'image';
|
if (props.file.type.startsWith('audio/')) return 'audio';
|
||||||
if (this.file.type.startsWith('video/')) return 'video';
|
if (props.file.type.endsWith('/csv')) return 'csv';
|
||||||
if (this.file.type === 'audio/midi') return 'midi';
|
if (props.file.type.endsWith('/pdf')) return 'pdf';
|
||||||
if (this.file.type.startsWith('audio/')) return 'audio';
|
if (props.file.type.startsWith('text/')) return 'textfile';
|
||||||
if (this.file.type.endsWith('/csv')) return 'csv';
|
if ([
|
||||||
if (this.file.type.endsWith('/pdf')) return 'pdf';
|
"application/zip",
|
||||||
if (this.file.type.startsWith('text/')) return 'textfile';
|
"application/x-cpio",
|
||||||
if ([
|
"application/x-bzip",
|
||||||
"application/zip",
|
"application/x-bzip2",
|
||||||
"application/x-cpio",
|
"application/java-archive",
|
||||||
"application/x-bzip",
|
"application/x-rar-compressed",
|
||||||
"application/x-bzip2",
|
"application/x-tar",
|
||||||
"application/java-archive",
|
"application/gzip",
|
||||||
"application/x-rar-compressed",
|
"application/x-7z-compressed"
|
||||||
"application/x-tar",
|
].some(e => e === props.file.type)) return 'archive';
|
||||||
"application/gzip",
|
return 'unknown';
|
||||||
"application/x-7z-compressed"
|
});
|
||||||
].some(e => e === this.file.type)) return 'archive';
|
|
||||||
return 'unknown';
|
const isThumbnailAvailable = computed(() => {
|
||||||
},
|
return props.file.thumbnailUrl
|
||||||
isThumbnailAvailable(): boolean {
|
? (is.value === 'image' as const || is.value === 'video')
|
||||||
return this.file.thumbnailUrl
|
: false;
|
||||||
? (this.is === 'image' || this.is === 'video')
|
|
||||||
: false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
const audioTag = this.$refs.volumectrl as HTMLAudioElement;
|
|
||||||
if (audioTag) audioTag.volume = ColdDeviceStorage.get('mediaVolume');
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
volumechange() {
|
|
||||||
const audioTag = this.$refs.volumectrl as HTMLAudioElement;
|
|
||||||
ColdDeviceStorage.set('mediaVolume', audioTag.volume);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue