enhance(client): improve file moderation ui

This commit is contained in:
syuilo 2022-06-17 15:03:02 +09:00 committed by Chloe Kudryavtsev
parent 22ded9e3f8
commit 75e8b2bf25
4 changed files with 30 additions and 29 deletions

View file

@ -845,6 +845,7 @@ failedToFetchAccountInformation: "アカウント情報の取得に失敗しま
rateLimitExceeded: "レート制限を超えました" rateLimitExceeded: "レート制限を超えました"
cropImage: "画像のクロップ" cropImage: "画像のクロップ"
cropImageAsk: "画像をクロップしますか?" cropImageAsk: "画像をクロップしますか?"
file: "ファイル"
_emailUnavailable: _emailUnavailable:
used: "既に使用されています" used: "既に使用されています"

View file

@ -1,12 +1,7 @@
<template> <template>
<XModalWindow ref="dialog" <MkSpacer :content-max="500" :margin-min="16" :margin-max="32">
:width="370" <div v-if="file" class="cxqhhsmd _formRoot">
@close="$refs.dialog.close()" <div class="_formBlock">
@closed="$emit('closed')"
>
<template v-if="file" #header>{{ file.name }}</template>
<div v-if="file" class="cxqhhsmd">
<div class="_section">
<MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/> <MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/>
<div class="info"> <div class="info">
<span style="margin-right: 1em;">{{ file.type }}</span> <span style="margin-right: 1em;">{{ file.type }}</span>
@ -14,35 +9,33 @@
<MkTime :time="file.createdAt" mode="detail" style="display: block;"/> <MkTime :time="file.createdAt" mode="detail" style="display: block;"/>
</div> </div>
</div> </div>
<div class="_section"> <div class="_formBlock">
<div class="_content"> <MkSwitch v-model="isSensitive" @update:modelValue="toggleIsSensitive">NSFW</MkSwitch>
<MkSwitch v-model="isSensitive" @update:modelValue="toggleIsSensitive">NSFW</MkSwitch>
</div>
</div> </div>
<div class="_section"> <div class="_formBlock">
<div class="_content"> <MkButton full @click="showUser"><i class="fas fa-external-link-square-alt"></i> {{ $ts.user }}</MkButton>
<MkButton full @click="showUser"><i class="fas fa-external-link-square-alt"></i> {{ $ts.user }}</MkButton>
<MkButton full danger @click="del"><i class="fas fa-trash-alt"></i> {{ $ts.delete }}</MkButton>
</div>
</div> </div>
<div v-if="info" class="_section"> <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"> <details class="_content rawdata">
<pre><code>{{ JSON.stringify(info, null, 2) }}</code></pre> <pre><code>{{ JSON.stringify(info, null, 2) }}</code></pre>
</details> </details>
</div> </div>
</div> </div>
</XModalWindow> </MkSpacer>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { } from 'vue'; import { computed } from 'vue';
import MkButton from '@/components/ui/button.vue'; import MkButton from '@/components/ui/button.vue';
import MkSwitch from '@/components/form/switch.vue'; import MkSwitch from '@/components/form/switch.vue';
import XModalWindow from '@/components/ui/modal-window.vue';
import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue'; import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue';
import bytes from '@/filters/bytes'; import bytes from '@/filters/bytes';
import * as os from '@/os'; import * as os from '@/os';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import * as symbols from '@/symbols';
let file: any = $ref(null); let file: any = $ref(null);
let info: any = $ref(null); let info: any = $ref(null);
@ -72,7 +65,7 @@ async function del() {
if (canceled) return; if (canceled) return;
os.apiWithDialog('drive/files/delete', { os.apiWithDialog('drive/files/delete', {
fileId: file.id fileId: file.id,
}); });
} }
@ -80,6 +73,14 @@ async function toggleIsSensitive(v) {
await os.api('drive/files/update', { fileId: props.fileId, isSensitive: v }); await os.api('drive/files/update', { fileId: props.fileId, isSensitive: v });
isSensitive = v; isSensitive = v;
} }
defineExpose({
[symbols.PAGE_INFO]: computed(() => ({
title: file ? i18n.ts.file + ': ' + file.name : i18n.ts.file,
icon: 'fas fa-file',
bg: 'var(--bg)',
})),
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View file

@ -82,9 +82,7 @@ function clear() {
} }
function show(file) { function show(file) {
os.popup(defineAsyncComponent(() => import('./file-dialog.vue')), { os.pageWindow(`/admin-file/${file.id}`);
fileId: file.id,
}, {}, 'closed');
} }
async function find() { async function find() {

View file

@ -1,9 +1,9 @@
import { AsyncComponentLoader, defineAsyncComponent, markRaw } from 'vue'; import { AsyncComponentLoader, defineAsyncComponent, markRaw } from 'vue';
import { createRouter, createWebHistory } from 'vue-router'; import { createRouter, createWebHistory } from 'vue-router';
import { $i, iAmModerator } from './account';
import MkLoading from '@/pages/_loading_.vue'; import MkLoading from '@/pages/_loading_.vue';
import MkError from '@/pages/_error_.vue'; import MkError from '@/pages/_error_.vue';
import MkTimeline from '@/pages/timeline.vue'; import MkTimeline from '@/pages/timeline.vue';
import { $i, iAmModerator } from './account';
import { ui } from '@/config'; import { ui } from '@/config';
// pathに/が入るとrollupが解決してくれないので、() => import('*.vue')を指定すること // pathに/が入るとrollupが解決してくれないので、() => import('*.vue')を指定すること
@ -70,6 +70,7 @@ const defaultRoutes = [
{ path: '/scratchpad', component: page('scratchpad') }, { path: '/scratchpad', component: page('scratchpad') },
{ path: '/admin/:page(.*)?', component: iAmModerator ? page(() => import('./pages/admin/index.vue')) : page('not-found'), props: route => ({ initialPage: route.params.page || null }) }, { path: '/admin/:page(.*)?', component: iAmModerator ? page(() => import('./pages/admin/index.vue')) : page('not-found'), props: route => ({ initialPage: route.params.page || null }) },
{ path: '/admin', component: iAmModerator ? page(() => import('./pages/admin/index.vue')) : page('not-found') }, { path: '/admin', component: iAmModerator ? page(() => import('./pages/admin/index.vue')) : page('not-found') },
{ path: '/admin-file/:fileId', component: page('admin-file'), props: route => ({ fileId: route.params.fileId }) },
{ path: '/notes/:note', name: 'note', component: page('note'), props: route => ({ noteId: route.params.note }) }, { path: '/notes/:note', name: 'note', component: page('note'), props: route => ({ noteId: route.params.note }) },
{ path: '/tags/:tag', component: page('tag'), props: route => ({ tag: route.params.tag }) }, { path: '/tags/:tag', component: page('tag'), props: route => ({ tag: route.params.tag }) },
{ path: '/user-info/:user', component: page('user-info'), props: route => ({ userId: route.params.user }) }, { path: '/user-info/:user', component: page('user-info'), props: route => ({ userId: route.params.user }) },
@ -82,7 +83,7 @@ const defaultRoutes = [
{ path: '/miauth/:session', component: page('miauth') }, { path: '/miauth/:session', component: page('miauth') },
{ path: '/authorize-follow', component: page('follow') }, { path: '/authorize-follow', component: page('follow') },
{ path: '/share', component: page('share') }, { path: '/share', component: page('share') },
{ path: '/:catchAll(.*)', component: page('not-found') } { path: '/:catchAll(.*)', component: page('not-found') },
]; ];
const chatRoutes = [ const chatRoutes = [
@ -126,7 +127,7 @@ export const router = createRouter({
window.scroll({ top: 0, behavior: 'instant' }); window.scroll({ top: 0, behavior: 'instant' });
} }
}; };
} },
}); });
router.afterEach((to, from) => { router.afterEach((to, from) => {
@ -141,6 +142,6 @@ export function resolve(path: string) {
return { return {
component: markRaw(route.components.default), component: markRaw(route.components.default),
// TODO: route.propsには関数以外も入る可能性があるのでよしなにハンドリングする // TODO: route.propsには関数以外も入る可能性があるのでよしなにハンドリングする
props: route.props?.default ? route.props.default(resolved) : resolved.params props: route.props.default ? route.props.default(resolved) : resolved.params,
}; };
} }