2023-10-21 09:38:07 +00:00
|
|
|
<!--
|
2024-02-13 15:59:27 +00:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-10-21 09:38:07 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2023-10-30 06:33:15 +00:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-10-21 09:38:07 +00:00
|
|
|
<MkSpacer :contentMax="900">
|
|
|
|
<div class="_gaps">
|
|
|
|
<MkFolder v-for="avatarDecoration in avatarDecorations" :key="avatarDecoration.id ?? avatarDecoration._id" :defaultOpen="avatarDecoration.id == null">
|
|
|
|
<template #label>{{ avatarDecoration.name }}</template>
|
|
|
|
<template #caption>{{ avatarDecoration.description }}</template>
|
|
|
|
|
|
|
|
<div class="_gaps_m">
|
|
|
|
<MkInput v-model="avatarDecoration.name">
|
|
|
|
<template #label>{{ i18n.ts.name }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkTextarea v-model="avatarDecoration.description">
|
|
|
|
<template #label>{{ i18n.ts.description }}</template>
|
|
|
|
</MkTextarea>
|
|
|
|
<MkInput v-model="avatarDecoration.url">
|
|
|
|
<template #label>{{ i18n.ts.imageUrl }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<div class="buttons _buttons">
|
2023-10-31 18:33:24 +00:00
|
|
|
<MkButton class="button" inline primary @click="save(avatarDecoration)"><i class="ph-floppy ph-bold ph-lg"></i> {{ i18n.ts.save }}</MkButton>
|
|
|
|
<MkButton v-if="avatarDecoration.id != null" class="button" inline danger @click="del(avatarDecoration)"><i class="ph-trash ph-bold ph-lg"></i> {{ i18n.ts.delete }}</MkButton>
|
2023-10-21 09:38:07 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</MkFolder>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { ref, computed } from 'vue';
|
2023-12-26 05:19:35 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-10-21 09:38:07 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkTextarea from '@/components/MkTextarea.vue';
|
|
|
|
import * as os from '@/os.js';
|
2024-01-04 09:32:46 +00:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-10-21 09:38:07 +00:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
|
|
|
|
2023-12-26 05:19:35 +00:00
|
|
|
const avatarDecorations = ref<Misskey.entities.AdminAvatarDecorationsListResponse>([]);
|
2023-10-21 09:38:07 +00:00
|
|
|
|
|
|
|
function add() {
|
2023-12-07 05:42:09 +00:00
|
|
|
avatarDecorations.value.unshift({
|
2023-10-21 09:38:07 +00:00
|
|
|
_id: Math.random().toString(36),
|
|
|
|
id: null,
|
|
|
|
name: '',
|
|
|
|
description: '',
|
|
|
|
url: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function del(avatarDecoration) {
|
|
|
|
os.confirm({
|
|
|
|
type: 'warning',
|
2024-01-19 23:11:59 +00:00
|
|
|
text: i18n.tsx.deleteAreYouSure({ x: avatarDecoration.name }),
|
2023-10-21 09:38:07 +00:00
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
2023-12-07 05:42:09 +00:00
|
|
|
avatarDecorations.value = avatarDecorations.value.filter(x => x !== avatarDecoration);
|
2024-01-04 09:32:46 +00:00
|
|
|
misskeyApi('admin/avatar-decorations/delete', avatarDecoration);
|
2023-10-21 09:38:07 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async function save(avatarDecoration) {
|
|
|
|
if (avatarDecoration.id == null) {
|
|
|
|
await os.apiWithDialog('admin/avatar-decorations/create', avatarDecoration);
|
|
|
|
load();
|
|
|
|
} else {
|
|
|
|
os.apiWithDialog('admin/avatar-decorations/update', avatarDecoration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function load() {
|
2024-01-04 09:32:46 +00:00
|
|
|
misskeyApi('admin/avatar-decorations/list').then(_avatarDecorations => {
|
2023-12-07 05:42:09 +00:00
|
|
|
avatarDecorations.value = _avatarDecorations;
|
2023-10-21 09:38:07 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
load();
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerActions = computed(() => [{
|
2023-10-21 09:38:07 +00:00
|
|
|
asFullButton: true,
|
2023-10-31 18:33:24 +00:00
|
|
|
icon: 'ph-plus ph-bold ph-lg',
|
2023-10-21 09:38:07 +00:00
|
|
|
text: i18n.ts.add,
|
|
|
|
handler: add,
|
|
|
|
}]);
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerTabs = computed(() => []);
|
2023-10-21 09:38:07 +00:00
|
|
|
|
2024-02-16 07:17:09 +00:00
|
|
|
definePageMetadata(() => ({
|
2023-10-21 09:38:07 +00:00
|
|
|
title: i18n.ts.avatarDecorations,
|
2023-10-31 18:33:24 +00:00
|
|
|
icon: 'ph-sparkle ph-bold ph-lg',
|
2024-02-16 07:17:09 +00:00
|
|
|
}));
|
2023-10-21 09:38:07 +00:00
|
|
|
</script>
|