2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2022-06-20 17:38:49 +09:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<MkSpacer :content-max="500" :margin-min="16" :margin-max="32">
|
|
|
|
<div v-if="file" class="cxqhhsmd _formRoot">
|
|
|
|
<div class="_formBlock">
|
|
|
|
<MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/>
|
|
|
|
<div class="info">
|
|
|
|
<span style="margin-right: 1em;">{{ file.type }}</span>
|
|
|
|
<span>{{ bytes(file.size) }}</span>
|
|
|
|
<MkTime :time="file.createdAt" mode="detail" style="display: block;"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="_formBlock">
|
|
|
|
<MkSwitch v-model="isSensitive" @update:modelValue="toggleIsSensitive">NSFW</MkSwitch>
|
|
|
|
</div>
|
2022-06-20 21:05:18 +09:00
|
|
|
<FormLink class="_formBlock" :to="file.url" :external="true">Open</FormLink>
|
|
|
|
<FormLink class="_formBlock" :to="`/user-info/${file.userId}`">{{ $ts.user }}</FormLink>
|
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
<div class="_formBlock">
|
|
|
|
<MkButton full danger @click="del"><i class="fas fa-trash-alt"></i> {{ $ts.delete }}</MkButton>
|
|
|
|
</div>
|
|
|
|
<div v-if="info" class="_formBlock">
|
|
|
|
<details class="_content rawdata">
|
|
|
|
<pre><code>{{ JSON.stringify(info, null, 2) }}</code></pre>
|
|
|
|
</details>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-20 17:38:49 +09:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-10-17 20:12:00 +09:00
|
|
|
</template>
|
|
|
|
|
2022-05-18 01:33:21 +09:00
|
|
|
<script lang="ts" setup>
|
2022-06-17 15:03:02 +09:00
|
|
|
import { computed } from 'vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkSwitch from '@/components/form/switch.vue';
|
|
|
|
import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue';
|
2022-06-20 21:05:18 +09:00
|
|
|
import FormLink from '@/components/form/link.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';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
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-20 17:38:49 +09:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: file ? i18n.ts.file + ': ' + file.name : i18n.ts.file,
|
|
|
|
icon: 'fas fa-file',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
})));
|
2020-10-17 20:12:00 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.cxqhhsmd {
|
|
|
|
> ._section {
|
|
|
|
> .thumbnail {
|
|
|
|
height: 150px;
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .info {
|
|
|
|
text-align: center;
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .rawdata {
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|