enhance(frontend): 同じ種類のデコレーションを複数付けられるように
This commit is contained in:
		| @@ -87,24 +87,7 @@ SPDX-License-Identifier: AGPL-3.0-only | ||||
| 		<template #icon><i class="ti ti-sparkles"></i></template> | ||||
| 		<template #label>{{ i18n.ts.avatarDecorations }}</template> | ||||
|  | ||||
| 		<div class="_gaps"> | ||||
| 			<MkInfo>{{ i18n.t('_profile.avatarDecorationMax', { max: $i?.policies.avatarDecorationLimit }) }} ({{ i18n.t('remainingN', { n: $i?.policies.avatarDecorationLimit - $i.avatarDecorations.length }) }})</MkInfo> | ||||
|  | ||||
| 			<MkButton v-if="$i.avatarDecorations.length > 0" danger @click="detachAllDecorations">{{ i18n.ts.detachAll }}</MkButton> | ||||
|  | ||||
| 			<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); grid-gap: 12px;"> | ||||
| 				<div | ||||
| 					v-for="avatarDecoration in avatarDecorations" | ||||
| 					:key="avatarDecoration.id" | ||||
| 					:class="[$style.avatarDecoration, { [$style.avatarDecorationActive]: $i.avatarDecorations.some(x => x.id === avatarDecoration.id) }]" | ||||
| 					@click="openDecoration(avatarDecoration)" | ||||
| 				> | ||||
| 					<div :class="$style.avatarDecorationName"><MkCondensedLine :minScale="0.5">{{ avatarDecoration.name }}</MkCondensedLine></div> | ||||
| 					<MkAvatar style="width: 60px; height: 60px;" :user="$i" :decorations="[{ url: avatarDecoration.url }]" forceShowDecoration/> | ||||
| 					<i v-if="avatarDecoration.roleIdsThatCanBeUsedThisDecoration.length > 0 && !$i.roles.some(r => avatarDecoration.roleIdsThatCanBeUsedThisDecoration.includes(r.id))" :class="$style.avatarDecorationLock" class="ti ti-lock"></i> | ||||
| 				</div> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 		<XAvatarDecoration/> | ||||
| 	</MkFolder> | ||||
|  | ||||
| 	<MkFolder> | ||||
| @@ -128,7 +111,8 @@ SPDX-License-Identifier: AGPL-3.0-only | ||||
| </template> | ||||
|  | ||||
| <script lang="ts" setup> | ||||
| import { computed, reactive, ref, watch, defineAsyncComponent, onMounted, onUnmounted } from 'vue'; | ||||
| import { computed, reactive, ref, watch, defineAsyncComponent } from 'vue'; | ||||
| import XAvatarDecoration from './profile.avatar-decoration.vue'; | ||||
| import MkButton from '@/components/MkButton.vue'; | ||||
| import MkInput from '@/components/MkInput.vue'; | ||||
| import MkTextarea from '@/components/MkTextarea.vue'; | ||||
| @@ -150,7 +134,6 @@ import MkInfo from '@/components/MkInfo.vue'; | ||||
| const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default)); | ||||
|  | ||||
| const reactionAcceptance = computed(defaultStore.makeGetterSetter('reactionAcceptance')); | ||||
| const avatarDecorations = ref<any[]>([]); | ||||
|  | ||||
| const profile = reactive({ | ||||
| 	name: $i.name, | ||||
| @@ -171,10 +154,6 @@ watch(() => profile, () => { | ||||
| const fields = ref($i?.fields.map(field => ({ id: Math.random().toString(), name: field.name, value: field.value })) ?? []); | ||||
| const fieldEditMode = ref(false); | ||||
|  | ||||
| os.api('get-avatar-decorations').then(_avatarDecorations => { | ||||
| 	avatarDecorations.value = _avatarDecorations; | ||||
| }); | ||||
|  | ||||
| function addField() { | ||||
| 	fields.value.push({ | ||||
| 		id: Math.random().toString(), | ||||
| @@ -273,25 +252,6 @@ function changeBanner(ev) { | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| function openDecoration(avatarDecoration) { | ||||
| 	os.popup(defineAsyncComponent(() => import('./profile.avatar-decoration-dialog.vue')), { | ||||
| 		decoration: avatarDecoration, | ||||
| 	}, {}, 'closed'); | ||||
| } | ||||
|  | ||||
| function detachAllDecorations() { | ||||
| 	os.confirm({ | ||||
| 		type: 'warning', | ||||
| 		text: i18n.ts.areYouSure, | ||||
| 	}).then(async ({ canceled }) => { | ||||
| 		if (canceled) return; | ||||
| 		await os.apiWithDialog('i/update', { | ||||
| 			avatarDecorations: [], | ||||
| 		}); | ||||
| 		$i.avatarDecorations = []; | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| const headerActions = computed(() => []); | ||||
|  | ||||
| const headerTabs = computed(() => []); | ||||
| @@ -386,33 +346,4 @@ definePageMetadata({ | ||||
| .dragItemForm { | ||||
| 	flex-grow: 1; | ||||
| } | ||||
|  | ||||
| .avatarDecoration { | ||||
| 	cursor: pointer; | ||||
| 	padding: 16px 16px 28px 16px; | ||||
| 	border: solid 2px var(--divider); | ||||
| 	border-radius: 8px; | ||||
| 	text-align: center; | ||||
| 	font-size: 90%; | ||||
| 	overflow: clip; | ||||
| 	contain: content; | ||||
| } | ||||
|  | ||||
| .avatarDecorationActive { | ||||
| 	background-color: var(--accentedBg); | ||||
| 	border-color: var(--accent); | ||||
| } | ||||
|  | ||||
| .avatarDecorationName { | ||||
| 	position: relative; | ||||
| 	z-index: 10; | ||||
| 	font-weight: bold; | ||||
| 	margin-bottom: 20px; | ||||
| } | ||||
|  | ||||
| .avatarDecorationLock { | ||||
| 	position: absolute; | ||||
| 	bottom: 12px; | ||||
| 	right: 12px; | ||||
| } | ||||
| </style> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 syuilo
					syuilo