2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2022-06-20 17:38:49 +09:00
|
|
|
<MkStickyContainer>
|
2022-06-22 16:29:21 +09:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-09-10 07:42:17 +09:00
|
|
|
<MkSpacer :content-max="600" :margin-min="16" :margin-max="32">
|
|
|
|
<swiper
|
|
|
|
:modules="[Virtual]"
|
|
|
|
:space-between="20"
|
|
|
|
:virtual="true"
|
2022-09-16 05:40:34 +09:00
|
|
|
:allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)"
|
2022-09-10 07:42:17 +09:00
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
|
|
|
>
|
|
|
|
<swiper-slide>
|
2022-09-10 07:26:33 +09:00
|
|
|
<div class="cxqhhsmd _formRoot">
|
|
|
|
<a class="_formBlock thumbnail" :href="file.url" target="_blank">
|
|
|
|
<MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/>
|
|
|
|
</a>
|
|
|
|
<div class="_formBlock">
|
|
|
|
<MkKeyValue :copy="file.type" oneline style="margin: 1em 0;">
|
|
|
|
<template #key>MIME Type</template>
|
|
|
|
<template #value><span class="_monospace">{{ file.type }}</span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue oneline style="margin: 1em 0;">
|
|
|
|
<template #key>Size</template>
|
|
|
|
<template #value><span class="_monospace">{{ bytes(file.size) }}</span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue :copy="file.id" oneline style="margin: 1em 0;">
|
|
|
|
<template #key>ID</template>
|
|
|
|
<template #value><span class="_monospace">{{ file.id }}</span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue :copy="file.md5" oneline style="margin: 1em 0;">
|
|
|
|
<template #key>MD5</template>
|
|
|
|
<template #value><span class="_monospace">{{ file.md5 }}</span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue oneline style="margin: 1em 0;">
|
|
|
|
<template #key>{{ i18n.ts.createdAt }}</template>
|
|
|
|
<template #value><span class="_monospace"><MkTime :time="file.createdAt" mode="detail" style="display: block;"/></span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
</div>
|
|
|
|
<MkA v-if="file.user" class="user" :to="`/user-info/${file.user.id}`">
|
|
|
|
<MkUserCardMini :user="file.user"/>
|
|
|
|
</MkA>
|
|
|
|
<div class="_formBlock">
|
|
|
|
<MkSwitch v-model="isSensitive" @update:modelValue="toggleIsSensitive">NSFW</MkSwitch>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="_formBlock">
|
2023-03-12 06:01:04 +09:00
|
|
|
<MkButton danger @click="del"><i class="ph-trash ph-bold ph-lg"></i> {{ i18n.ts.delete }}</MkButton>
|
2022-09-10 07:26:33 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-10 07:42:17 +09:00
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
2022-09-10 07:26:33 +09:00
|
|
|
<div v-if="info" class="_formRoot">
|
|
|
|
<MkInfo v-if="!iAmAdmin" warn>{{ i18n.ts.requireAdminForView }}</MkInfo>
|
|
|
|
<MkKeyValue v-if="info.requestIp" class="_formBlock _monospace" :copy="info.requestIp" oneline>
|
|
|
|
<template #key>IP</template>
|
|
|
|
<template #value>{{ info.requestIp }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<FormSection v-if="info.requestHeaders">
|
|
|
|
<template #label>Headers</template>
|
|
|
|
<MkKeyValue v-for="(v, k) in info.requestHeaders" :key="k" class="_formBlock _monospace">
|
|
|
|
<template #key>{{ k }}</template>
|
|
|
|
<template #value>{{ v }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2022-09-10 07:42:17 +09:00
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
2022-09-10 07:26:33 +09:00
|
|
|
<div class="_formRoot">
|
|
|
|
<MkObjectView v-if="info" tall :value="info">
|
|
|
|
</MkObjectView>
|
|
|
|
</div>
|
2022-09-10 07:42:17 +09:00
|
|
|
</swiper-slide>
|
|
|
|
</swiper>
|
|
|
|
</MkSpacer>
|
2022-06-20 17:38:49 +09:00
|
|
|
</MkStickyContainer>
|
2020-10-17 20:12:00 +09:00
|
|
|
</template>
|
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
<script lang="ts" setup>
|
2022-10-26 11:48:25 +09:00
|
|
|
import { computed, watch } from 'vue';
|
2022-09-10 07:26:33 +09:00
|
|
|
import { Virtual } from 'swiper';
|
|
|
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
2022-09-06 18:21:49 +09:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import MkSwitch from '@/components/form/switch.vue';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MkObjectView from '@/components/MkObjectView.vue';
|
|
|
|
import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue';
|
|
|
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
2022-07-02 15:12:11 +09:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
2022-09-06 18:21:49 +09:00
|
|
|
import MkInfo from '@/components/MkInfo.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import * as os from '@/os';
|
2022-05-18 01:33:21 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-09-16 02:43:48 +09:00
|
|
|
import { deviceKind } from '@/scripts/device-kind';
|
2022-06-22 00:10:34 +09:00
|
|
|
import { acct } from '@/filters/user';
|
2022-07-02 15:12:11 +09:00
|
|
|
import { iAmAdmin, iAmModerator } from '@/account';
|
2022-09-16 05:40:34 +09:00
|
|
|
import { defaultStore } from '@/store';
|
2022-09-10 07:26:33 +09:00
|
|
|
import 'swiper/scss';
|
|
|
|
import 'swiper/scss/virtual';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-09-10 07:26:33 +09:00
|
|
|
let tabs = ['overview'];
|
|
|
|
if (iAmModerator) tabs.push('ip');
|
|
|
|
tabs.push('raw');
|
2022-10-26 11:19:42 +09:00
|
|
|
let tab = $ref(tabs[0]);
|
|
|
|
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
|
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
let file: any = $ref(null);
|
|
|
|
let info: any = $ref(null);
|
|
|
|
let isSensitive: boolean = $ref(false);
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
const props = defineProps<{
|
|
|
|
fileId: string,
|
|
|
|
}>();
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
async function fetch() {
|
|
|
|
file = await os.api('drive/files/show', { fileId: props.fileId });
|
|
|
|
info = await os.api('admin/drive/show-file', { fileId: props.fileId });
|
|
|
|
isSensitive = file.isSensitive;
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
fetch();
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
async function del() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.t('removeAreYouSure', { x: file.name }),
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
os.apiWithDialog('drive/files/delete', {
|
2022-06-17 15:03:02 +09:00
|
|
|
fileId: file.id,
|
2022-05-18 01:33:21 +09:00
|
|
|
});
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
async function toggleIsSensitive(v) {
|
|
|
|
await os.api('drive/files/update', { fileId: props.fileId, isSensitive: v });
|
|
|
|
isSensitive = v;
|
|
|
|
}
|
2022-06-17 15:03:02 +09:00
|
|
|
|
2022-06-22 00:10:34 +09:00
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
text: i18n.ts.openInNewTab,
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-arrow-square-out ph-bold ph-lg',
|
2022-06-22 00:10:34 +09:00
|
|
|
handler: () => {
|
|
|
|
window.open(file.url, '_blank');
|
|
|
|
},
|
|
|
|
}]);
|
2022-06-20 17:38:49 +09:00
|
|
|
|
2022-06-22 00:10:34 +09:00
|
|
|
const headerTabs = $computed(() => [{
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'overview',
|
2022-06-22 00:10:34 +09:00
|
|
|
title: i18n.ts.overview,
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-info ph-bold ph-lg',
|
2022-07-02 15:12:11 +09:00
|
|
|
}, iAmModerator ? {
|
|
|
|
key: 'ip',
|
|
|
|
title: 'IP',
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-receipt ph-bold ph-lg',
|
2022-07-02 15:12:11 +09:00
|
|
|
} : null, {
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'raw',
|
2022-06-22 00:10:34 +09:00
|
|
|
title: 'Raw data',
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-code ph-bold ph-lg',
|
2022-06-22 00:10:34 +09:00
|
|
|
}]);
|
2022-06-20 17:38:49 +09:00
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: file ? i18n.ts.file + ': ' + file.name : i18n.ts.file,
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-file ph-bold ph-lg',
|
2022-06-20 17:38:49 +09:00
|
|
|
})));
|
2022-09-10 07:26:33 +09:00
|
|
|
|
|
|
|
let swiperRef = null;
|
|
|
|
|
|
|
|
function setSwiperRef(swiper) {
|
|
|
|
swiperRef = swiper;
|
|
|
|
syncSlide(tabs.indexOf(tab));
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSlideChange() {
|
|
|
|
tab = tabs[swiperRef.activeIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
function syncSlide(index) {
|
|
|
|
swiperRef.slideTo(index);
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.cxqhhsmd {
|
2022-06-22 00:10:34 +09:00
|
|
|
> .thumbnail {
|
|
|
|
display: block;
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
> .thumbnail {
|
2022-06-22 00:10:34 +09:00
|
|
|
height: 300px;
|
2020-10-17 20:12:00 +09:00
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
}
|
2022-06-23 23:45:22 +09:00
|
|
|
|
|
|
|
> .user {
|
|
|
|
&:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
</style>
|