Merge branch 'develop' into pr/16475
This commit is contained in:
commit
3212afa507
|
@ -1,3 +1,4 @@
|
||||||
|
@ -1,70 +0,0 @@
|
||||||
<!--
|
<!--
|
||||||
SPDX-FileCopyrightText: syuilo and misskey-project
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
SPDX-License-Identifier: AGPL-3.0-only
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
@ -12,8 +13,11 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div :class="$style.error">
|
<div :class="$style.error">
|
||||||
|
<slot name="error" :error="error">
|
||||||
<div><i class="ti ti-alert-triangle"></i> {{ i18n.ts.somethingHappened }}</div>
|
<div><i class="ti ti-alert-triangle"></i> {{ i18n.ts.somethingHappened }}</div>
|
||||||
|
<div v-if="error">{{ JSON.stringify(error) }}</div>
|
||||||
<MkButton inline style="margin-top: 16px;" @click="retry"><i class="ti ti-reload"></i> {{ i18n.ts.retry }}</MkButton>
|
<MkButton inline style="margin-top: 16px;" @click="retry"><i class="ti ti-reload"></i> {{ i18n.ts.retry }}</MkButton>
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -27,15 +31,17 @@ const props = defineProps<{
|
||||||
p: () => Promise<T>;
|
p: () => Promise<T>;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(ev: 'resolved', result: T): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
const pending = ref(true);
|
const pending = ref(true);
|
||||||
const resolved = ref(false);
|
const resolved = ref(false);
|
||||||
const rejected = ref(false);
|
const rejected = ref(false);
|
||||||
const result = ref<T | null>(null);
|
const result = ref<T | null>(null);
|
||||||
|
const error = ref<any | null>(null);
|
||||||
|
|
||||||
const process = () => {
|
const process = () => {
|
||||||
if (props.p == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const promise = props.p();
|
const promise = props.p();
|
||||||
pending.value = true;
|
pending.value = true;
|
||||||
resolved.value = false;
|
resolved.value = false;
|
||||||
|
@ -44,10 +50,12 @@ const process = () => {
|
||||||
pending.value = false;
|
pending.value = false;
|
||||||
resolved.value = true;
|
resolved.value = true;
|
||||||
result.value = _result;
|
result.value = _result;
|
||||||
|
emit('resolved', _result);
|
||||||
});
|
});
|
||||||
promise.catch(() => {
|
promise.catch((_error) => {
|
||||||
pending.value = false;
|
pending.value = false;
|
||||||
rejected.value = true;
|
rejected.value = true;
|
||||||
|
error.value = _error;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,7 @@ import NestedRouterView from './global/NestedRouterView.vue';
|
||||||
import StackingRouterView from './global/StackingRouterView.vue';
|
import StackingRouterView from './global/StackingRouterView.vue';
|
||||||
import MkLoading from './global/MkLoading.vue';
|
import MkLoading from './global/MkLoading.vue';
|
||||||
import MkError from './global/MkError.vue';
|
import MkError from './global/MkError.vue';
|
||||||
|
import MkSuspense from './global/MkSuspense.vue';
|
||||||
import MkAd from './global/MkAd.vue';
|
import MkAd from './global/MkAd.vue';
|
||||||
import MkPageHeader from './global/MkPageHeader.vue';
|
import MkPageHeader from './global/MkPageHeader.vue';
|
||||||
import MkStickyContainer from './global/MkStickyContainer.vue';
|
import MkStickyContainer from './global/MkStickyContainer.vue';
|
||||||
|
@ -60,6 +61,7 @@ export const components = {
|
||||||
MkUrl: MkUrl,
|
MkUrl: MkUrl,
|
||||||
MkLoading: MkLoading,
|
MkLoading: MkLoading,
|
||||||
MkError: MkError,
|
MkError: MkError,
|
||||||
|
MkSuspense: MkSuspense,
|
||||||
MkAd: MkAd,
|
MkAd: MkAd,
|
||||||
MkPageHeader: MkPageHeader,
|
MkPageHeader: MkPageHeader,
|
||||||
MkStickyContainer: MkStickyContainer,
|
MkStickyContainer: MkStickyContainer,
|
||||||
|
@ -94,6 +96,7 @@ declare module '@vue/runtime-core' {
|
||||||
MkUrl: typeof MkUrl;
|
MkUrl: typeof MkUrl;
|
||||||
MkLoading: typeof MkLoading;
|
MkLoading: typeof MkLoading;
|
||||||
MkError: typeof MkError;
|
MkError: typeof MkError;
|
||||||
|
MkSuspense: typeof MkSuspense;
|
||||||
MkAd: typeof MkAd;
|
MkAd: typeof MkAd;
|
||||||
MkPageHeader: typeof MkPageHeader;
|
MkPageHeader: typeof MkPageHeader;
|
||||||
MkStickyContainer: typeof MkStickyContainer;
|
MkStickyContainer: typeof MkStickyContainer;
|
||||||
|
|
|
@ -96,7 +96,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSuspense v-slot="{ result: stats }" :p="initStats">
|
<MkSuspense v-slot="{ result: stats }" :p="initStats">
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ i18n.ts.statistics }}</template>
|
<template #label>{{ i18n.ts.statistics }}</template>
|
||||||
<FormSplit>
|
<FormSplit>
|
||||||
|
@ -110,7 +110,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</MkKeyValue>
|
</MkKeyValue>
|
||||||
</FormSplit>
|
</FormSplit>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
</FormSuspense>
|
</MkSuspense>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>Well-known resources</template>
|
<template #label>Well-known resources</template>
|
||||||
|
@ -134,7 +134,6 @@ import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
import FormLink from '@/components/form/link.vue';
|
import FormLink from '@/components/form/link.vue';
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import FormSplit from '@/components/form/split.vue';
|
import FormSplit from '@/components/form/split.vue';
|
||||||
import FormSuspense from '@/components/form/suspense.vue';
|
|
||||||
import MkFolder from '@/components/MkFolder.vue';
|
import MkFolder from '@/components/MkFolder.vue';
|
||||||
import MkKeyValue from '@/components/MkKeyValue.vue';
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
||||||
import MkLink from '@/components/MkLink.vue';
|
import MkLink from '@/components/MkLink.vue';
|
||||||
|
|
|
@ -4,9 +4,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<XRoot v-if="file != null && info != null" :file="file" :info="info"/>
|
<MkSuspense v-slot="{ result }" :p="_fetch_" @resolved="(result) => file = result.file">
|
||||||
<div v-else-if="error != null">Error: {{ error }}</div>
|
<XRoot v-if="result.file != null && result.info != null" :file="result.file" :info="result.info"/>
|
||||||
<MkLoading v-else/>
|
</MkSuspense>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
@ -17,27 +17,21 @@ import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { definePage } from '@/page.js';
|
import { definePage } from '@/page.js';
|
||||||
|
|
||||||
const file = ref<Misskey.entities.DriveFile | null>(null);
|
|
||||||
const info = ref<Misskey.entities.AdminDriveShowFileResponse | null>(null);
|
|
||||||
|
|
||||||
const error = ref<string | null>(null);
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
fileId: string,
|
fileId: string,
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
async function _fetch_() {
|
function _fetch_() {
|
||||||
try {
|
return Promise.all([
|
||||||
file.value = await misskeyApi('drive/files/show', { fileId: props.fileId });
|
misskeyApi('drive/files/show', { fileId: props.fileId }),
|
||||||
} catch (err: any) {
|
misskeyApi('admin/drive/show-file', { fileId: props.fileId }),
|
||||||
error.value = err.message + ' ' + err.id;
|
]).then((result) => ({
|
||||||
return;
|
file: result[0],
|
||||||
|
info: result[1],
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
info.value = await misskeyApi('admin/drive/show-file', { fileId: props.fileId });
|
const file = ref<Misskey.entities.DriveFile | null>(null);
|
||||||
}
|
|
||||||
|
|
||||||
_fetch_();
|
|
||||||
|
|
||||||
definePage(() => ({
|
definePage(() => ({
|
||||||
title: file.value ? `${i18n.ts.file}: ${file.value.name}` : i18n.ts.file,
|
title: file.value ? `${i18n.ts.file}: ${file.value.name}` : i18n.ts.file,
|
||||||
|
|
|
@ -6,19 +6,18 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<PageWithHeader :actions="headerActions" :tabs="headerTabs">
|
<PageWithHeader :actions="headerActions" :tabs="headerTabs">
|
||||||
<div class="_spacer" style="--MI_SPACER-w: 800px; --MI_SPACER-min: 16px; --MI_SPACER-max: 32px;">
|
<div class="_spacer" style="--MI_SPACER-w: 800px; --MI_SPACER-min: 16px; --MI_SPACER-max: 32px;">
|
||||||
<FormSuspense v-slot="{ result: database }" :p="databasePromiseFactory">
|
<MkSuspense v-slot="{ result: database }" :p="databasePromiseFactory">
|
||||||
<MkKeyValue v-for="table in database" :key="table[0]" oneline style="margin: 1em 0;">
|
<MkKeyValue v-for="table in database" :key="table[0]" oneline style="margin: 1em 0;">
|
||||||
<template #key>{{ table[0] }}</template>
|
<template #key>{{ table[0] }}</template>
|
||||||
<template #value>{{ bytes(table[1].size) }} ({{ number(table[1].count) }} recs)</template>
|
<template #value>{{ bytes(table[1].size) }} ({{ number(table[1].count) }} recs)</template>
|
||||||
</MkKeyValue>
|
</MkKeyValue>
|
||||||
</FormSuspense>
|
</MkSuspense>
|
||||||
</div>
|
</div>
|
||||||
</PageWithHeader>
|
</PageWithHeader>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import FormSuspense from '@/components/form/suspense.vue';
|
|
||||||
import MkKeyValue from '@/components/MkKeyValue.vue';
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
||||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
import bytes from '@/filters/bytes.js';
|
import bytes from '@/filters/bytes.js';
|
||||||
|
|
|
@ -109,7 +109,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import MkSwitch from '@/components/MkSwitch.vue';
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
import MkInput from '@/components/MkInput.vue';
|
import MkInput from '@/components/MkInput.vue';
|
||||||
import FormSuspense from '@/components/form/suspense.vue';
|
|
||||||
import FormSplit from '@/components/form/split.vue';
|
import FormSplit from '@/components/form/split.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PageWithHeader :actions="headerActions" :tabs="headerTabs">
|
||||||
|
<div class="_spacer" style="--MI_SPACER-w: 800px; --MI_SPACER-min: 16px; --MI_SPACER-max: 32px;">
|
||||||
|
<MkInput v-model="title">
|
||||||
|
<template #label>{{ i18n.ts.title }}</template>
|
||||||
|
</MkInput>
|
||||||
|
|
||||||
|
<MkTextarea v-model="description" :max="500">
|
||||||
|
<template #label>{{ i18n.ts.description }}</template>
|
||||||
|
</MkTextarea>
|
||||||
|
|
||||||
|
<div class="_gaps_s">
|
||||||
|
<div v-for="file in files" :key="file.id" class="wqugxsfx" :style="{ backgroundImage: file ? `url(${ file.thumbnailUrl })` : '' }">
|
||||||
|
<div class="name">{{ file.name }}</div>
|
||||||
|
<button v-tooltip="i18n.ts.remove" class="remove _button" @click="remove(file)"><i class="ti ti-x"></i></button>
|
||||||
|
</div>
|
||||||
|
<MkButton primary @click="chooseFile"><i class="ti ti-plus"></i> {{ i18n.ts.attachFile }}</MkButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<MkSwitch v-model="isSensitive">{{ i18n.ts.markAsSensitive }}</MkSwitch>
|
||||||
|
|
||||||
|
<div class="_buttons">
|
||||||
|
<MkButton v-if="props.post != null" primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
||||||
|
<MkButton v-else primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.publish }}</MkButton>
|
||||||
|
|
||||||
|
<MkButton v-if="props.post != null" danger @click="del"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PageWithHeader>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, watch, ref } from 'vue';
|
||||||
|
import * as Misskey from 'misskey-js';
|
||||||
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
import MkInput from '@/components/MkInput.vue';
|
||||||
|
import MkTextarea from '@/components/MkTextarea.vue';
|
||||||
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
|
import { selectFile } from '@/utility/drive.js';
|
||||||
|
import * as os from '@/os.js';
|
||||||
|
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
|
import { i18n } from '@/i18n.js';
|
||||||
|
import { useRouter } from '@/router.js';
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
post: Misskey.entities.GalleryPost | null;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const files = ref(props.post?.files ?? []);
|
||||||
|
const description = ref(props.post?.description ?? null);
|
||||||
|
const title = ref(props.post?.title ?? '');
|
||||||
|
const isSensitive = ref(props.post?.isSensitive ?? false);
|
||||||
|
|
||||||
|
function chooseFile(evt) {
|
||||||
|
selectFile({
|
||||||
|
anchorElement: evt.currentTarget ?? evt.target,
|
||||||
|
multiple: true,
|
||||||
|
}).then(selected => {
|
||||||
|
files.value = files.value.concat(selected);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove(file) {
|
||||||
|
files.value = files.value.filter(f => f.id !== file.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
if (props.post != null) {
|
||||||
|
await os.apiWithDialog('gallery/posts/update', {
|
||||||
|
postId: props.post.id,
|
||||||
|
title: title.value,
|
||||||
|
description: description.value,
|
||||||
|
fileIds: files.value.map(file => file.id),
|
||||||
|
isSensitive: isSensitive.value,
|
||||||
|
});
|
||||||
|
router.push('/gallery/:postId', {
|
||||||
|
params: {
|
||||||
|
postId: props.post.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const created = await os.apiWithDialog('gallery/posts/create', {
|
||||||
|
title: title.value,
|
||||||
|
description: description.value,
|
||||||
|
fileIds: files.value.map(file => file.id),
|
||||||
|
isSensitive: isSensitive.value,
|
||||||
|
});
|
||||||
|
router.push('/gallery/:postId', {
|
||||||
|
params: {
|
||||||
|
postId: created.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function del() {
|
||||||
|
if (props.post == null) return;
|
||||||
|
const { canceled } = await os.confirm({
|
||||||
|
type: 'warning',
|
||||||
|
text: i18n.ts.deleteConfirm,
|
||||||
|
});
|
||||||
|
if (canceled) return;
|
||||||
|
await os.apiWithDialog('gallery/posts/delete', {
|
||||||
|
postId: props.post.id,
|
||||||
|
});
|
||||||
|
router.push('/gallery');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerActions = computed(() => []);
|
||||||
|
|
||||||
|
const headerTabs = computed(() => []);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.wqugxsfx {
|
||||||
|
height: 200px;
|
||||||
|
background-size: contain;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
> .name {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
left: 9px;
|
||||||
|
padding: 8px;
|
||||||
|
background: var(--MI_THEME-panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
> .remove {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 9px;
|
||||||
|
padding: 8px;
|
||||||
|
background: var(--MI_THEME-panel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -4,162 +4,35 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<PageWithHeader :actions="headerActions" :tabs="headerTabs">
|
<MkSuspense v-slot="{ result }" :p="_fetch_">
|
||||||
<div class="_spacer" style="--MI_SPACER-w: 800px; --MI_SPACER-min: 16px; --MI_SPACER-max: 32px;">
|
<XRoot :post="result"/>
|
||||||
<FormSuspense :p="init" class="_gaps">
|
</MkSuspense>
|
||||||
<MkInput v-model="title">
|
|
||||||
<template #label>{{ i18n.ts.title }}</template>
|
|
||||||
</MkInput>
|
|
||||||
|
|
||||||
<MkTextarea v-model="description" :max="500">
|
|
||||||
<template #label>{{ i18n.ts.description }}</template>
|
|
||||||
</MkTextarea>
|
|
||||||
|
|
||||||
<div class="_gaps_s">
|
|
||||||
<div v-for="file in files" :key="file.id" class="wqugxsfx" :style="{ backgroundImage: file ? `url(${ file.thumbnailUrl })` : '' }">
|
|
||||||
<div class="name">{{ file.name }}</div>
|
|
||||||
<button v-tooltip="i18n.ts.remove" class="remove _button" @click="remove(file)"><i class="ti ti-x"></i></button>
|
|
||||||
</div>
|
|
||||||
<MkButton primary @click="chooseFile"><i class="ti ti-plus"></i> {{ i18n.ts.attachFile }}</MkButton>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<MkSwitch v-model="isSensitive">{{ i18n.ts.markAsSensitive }}</MkSwitch>
|
|
||||||
|
|
||||||
<div class="_buttons">
|
|
||||||
<MkButton v-if="postId" primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
|
||||||
<MkButton v-else primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.publish }}</MkButton>
|
|
||||||
|
|
||||||
<MkButton v-if="postId" danger @click="del"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
|
||||||
</div>
|
|
||||||
</FormSuspense>
|
|
||||||
</div>
|
|
||||||
</PageWithHeader>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, watch, ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import XRoot from './edit.root.vue';
|
||||||
import MkInput from '@/components/MkInput.vue';
|
|
||||||
import MkTextarea from '@/components/MkTextarea.vue';
|
|
||||||
import MkSwitch from '@/components/MkSwitch.vue';
|
|
||||||
import FormSuspense from '@/components/form/suspense.vue';
|
|
||||||
import { selectFile } from '@/utility/drive.js';
|
|
||||||
import * as os from '@/os.js';
|
|
||||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
import { definePage } from '@/page.js';
|
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { useRouter } from '@/router.js';
|
import { definePage } from '@/page.js';
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
postId?: string;
|
postId?: string,
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const init = ref<(() => Promise<any>) | null>(null);
|
function _fetch_() {
|
||||||
const files = ref<Misskey.entities.DriveFile[]>([]);
|
if (props.postId == null) {
|
||||||
const description = ref<string | null>(null);
|
return Promise.resolve(null);
|
||||||
const title = ref<string | null>(null);
|
|
||||||
const isSensitive = ref(false);
|
|
||||||
|
|
||||||
function chooseFile(evt) {
|
|
||||||
selectFile({
|
|
||||||
anchorElement: evt.currentTarget ?? evt.target,
|
|
||||||
multiple: true,
|
|
||||||
}).then(selected => {
|
|
||||||
files.value = files.value.concat(selected);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove(file) {
|
|
||||||
files.value = files.value.filter(f => f.id !== file.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function save() {
|
|
||||||
if (props.postId) {
|
|
||||||
await os.apiWithDialog('gallery/posts/update', {
|
|
||||||
postId: props.postId,
|
|
||||||
title: title.value,
|
|
||||||
description: description.value,
|
|
||||||
fileIds: files.value.map(file => file.id),
|
|
||||||
isSensitive: isSensitive.value,
|
|
||||||
});
|
|
||||||
router.push('/gallery/:postId', {
|
|
||||||
params: {
|
|
||||||
postId: props.postId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
const created = await os.apiWithDialog('gallery/posts/create', {
|
return misskeyApi('gallery/posts/show', {
|
||||||
title: title.value,
|
|
||||||
description: description.value,
|
|
||||||
fileIds: files.value.map(file => file.id),
|
|
||||||
isSensitive: isSensitive.value,
|
|
||||||
});
|
|
||||||
router.push('/gallery/:postId', {
|
|
||||||
params: {
|
|
||||||
postId: created.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function del() {
|
|
||||||
const { canceled } = await os.confirm({
|
|
||||||
type: 'warning',
|
|
||||||
text: i18n.ts.deleteConfirm,
|
|
||||||
});
|
|
||||||
if (canceled) return;
|
|
||||||
await os.apiWithDialog('gallery/posts/delete', {
|
|
||||||
postId: props.postId,
|
postId: props.postId,
|
||||||
});
|
});
|
||||||
router.push('/gallery');
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
watch(() => props.postId, () => {
|
|
||||||
init.value = () => props.postId ? misskeyApi('gallery/posts/show', {
|
|
||||||
postId: props.postId,
|
|
||||||
}).then(post => {
|
|
||||||
files.value = post.files ?? [];
|
|
||||||
title.value = post.title;
|
|
||||||
description.value = post.description;
|
|
||||||
isSensitive.value = post.isSensitive;
|
|
||||||
}) : Promise.resolve(null);
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
const headerActions = computed(() => []);
|
|
||||||
|
|
||||||
const headerTabs = computed(() => []);
|
|
||||||
|
|
||||||
definePage(() => ({
|
definePage(() => ({
|
||||||
title: props.postId ? i18n.ts.edit : i18n.ts.postToGallery,
|
title: props.postId ? i18n.ts.edit : i18n.ts.postToGallery,
|
||||||
icon: 'ti ti-pencil',
|
icon: 'ti ti-pencil',
|
||||||
}));
|
}));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.wqugxsfx {
|
|
||||||
height: 200px;
|
|
||||||
background-size: contain;
|
|
||||||
background-position: center;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
> .name {
|
|
||||||
position: absolute;
|
|
||||||
top: 8px;
|
|
||||||
left: 9px;
|
|
||||||
padding: 8px;
|
|
||||||
background: var(--MI_THEME-panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
> .remove {
|
|
||||||
position: absolute;
|
|
||||||
top: 8px;
|
|
||||||
right: 9px;
|
|
||||||
padding: 8px;
|
|
||||||
background: var(--MI_THEME-panel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
Loading…
Reference in New Issue