mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-21 04:05:28 +02:00
refactor and fix
This commit is contained in:
@@ -17,13 +17,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<div :class="$style.decorations">
|
||||
<XDecoration
|
||||
v-for="(avatarDecoration, i) in $i.avatarDecorations"
|
||||
:decoration="avatarDecorations.find(d => d.id === avatarDecoration.id)"
|
||||
:decoration="avatarDecorations.find(d => d.id === avatarDecoration.id) ?? { id: '', url: '', name: '?', roleIdsThatCanBeUsedThisDecoration: [] }"
|
||||
:angle="avatarDecoration.angle"
|
||||
:flipH="avatarDecoration.flipH"
|
||||
:offsetX="avatarDecoration.offsetX"
|
||||
:offsetY="avatarDecoration.offsetY"
|
||||
:active="true"
|
||||
@click="openDecoration(avatarDecoration, i)"
|
||||
@click="openAttachedDecoration(i)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -50,6 +50,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
import { ref, defineAsyncComponent, computed } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import XDecoration from './avatar-decoration.decoration.vue';
|
||||
import XDialog from './avatar-decoration.dialog.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import * as os from '@/os.js';
|
||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||
@@ -68,14 +69,24 @@ misskeyApi('get-avatar-decorations').then(_avatarDecorations => {
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
async function openDecoration(avatarDecoration, index?: number) {
|
||||
const { dispose } = await os.popupAsyncWithDialog(import('./avatar-decoration.dialog.vue').then(x => x.default), {
|
||||
function openAttachedDecoration(index: number) {
|
||||
openDecoration(avatarDecorations.value.find(d => d.id === $i.avatarDecorations[index].id) ?? { id: '', url: '', name: '?', roleIdsThatCanBeUsedThisDecoration: [] }, index);
|
||||
}
|
||||
|
||||
async function openDecoration(avatarDecoration: {
|
||||
id: string;
|
||||
url: string;
|
||||
name: string;
|
||||
roleIdsThatCanBeUsedThisDecoration: string[];
|
||||
}, index?: number) {
|
||||
const { dispose } = os.popup(XDialog, {
|
||||
decoration: avatarDecoration,
|
||||
usingIndex: index,
|
||||
usingIndex: index ?? null,
|
||||
}, {
|
||||
'attach': async (payload) => {
|
||||
const decoration = {
|
||||
id: avatarDecoration.id,
|
||||
url: avatarDecoration.url,
|
||||
angle: payload.angle,
|
||||
flipH: payload.flipH,
|
||||
offsetX: payload.offsetX,
|
||||
@@ -90,6 +101,7 @@ async function openDecoration(avatarDecoration, index?: number) {
|
||||
'update': async (payload) => {
|
||||
const decoration = {
|
||||
id: avatarDecoration.id,
|
||||
url: avatarDecoration.url,
|
||||
angle: payload.angle,
|
||||
flipH: payload.flipH,
|
||||
offsetX: payload.offsetX,
|
||||
|
||||
@@ -43,7 +43,7 @@ async function edit() {
|
||||
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkWatermarkEditorDialog.vue')), {
|
||||
preset: deepClone(props.preset),
|
||||
}, {
|
||||
ok: (preset: WatermarkPreset) => {
|
||||
ok: (preset) => {
|
||||
emit('updatePreset', preset);
|
||||
},
|
||||
closed: () => dispose(),
|
||||
|
||||
Reference in New Issue
Block a user