mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-26 04:24:22 +02:00
Update room.add-object-dialog.vue
This commit is contained in:
@@ -17,8 +17,19 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<template #header><i class="ti ti-box"></i> カタログ</template>
|
<template #header><i class="ti ti-box"></i> カタログ</template>
|
||||||
|
|
||||||
<div :class="$style.root">
|
<div :class="$style.root">
|
||||||
<div :class="$style.catalogItems">
|
<div :class="$style.main">
|
||||||
<XItem v-for="def in OBJECT_DEFS" :key="def.id" :def="def" :class="[$style.catalogItem, { [$style.selected]: selectedId === def.id }]" @click="selectedId = def.id"/>
|
<MkFoldableSection v-if="recentlyUsedDefs.length > 0" :expanded="true">
|
||||||
|
<template #header>{{ i18n.ts.recentUsed }}</template>
|
||||||
|
<div :class="$style.catalogItems">
|
||||||
|
<XItem v-for="def in recentlyUsedDefs" :key="def.id" :def="def" :class="[$style.catalogItem]" @click="selectedId = def.id"/>
|
||||||
|
</div>
|
||||||
|
</MkFoldableSection>
|
||||||
|
<MkFoldableSection :expanded="true">
|
||||||
|
<template #header>{{ i18n.ts.all }}</template>
|
||||||
|
<div :class="$style.catalogItems">
|
||||||
|
<XItem v-for="def in OBJECT_DEFS" :key="def.id" :def="def" :class="[$style.catalogItem]" @click="selectedId = def.id"/>
|
||||||
|
</div>
|
||||||
|
</MkFoldableSection>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="selectedId != null" :class="$style.preview" class="_panel">
|
<div v-show="selectedId != null" :class="$style.preview" class="_panel">
|
||||||
<canvas ref="canvas" :class="$style.canvas"></canvas>
|
<canvas ref="canvas" :class="$style.canvas"></canvas>
|
||||||
@@ -55,6 +66,7 @@ import MkButton from '@/components/MkButton.vue';
|
|||||||
import { prefer } from '@/preferences.js';
|
import { prefer } from '@/preferences.js';
|
||||||
import { deepClone } from '@/utility/clone.js';
|
import { deepClone } from '@/utility/clone.js';
|
||||||
import { store } from '@/store.js';
|
import { store } from '@/store.js';
|
||||||
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||||
|
|
||||||
// TODO: instanceのidと紛らわしいのでid -> typeにする
|
// TODO: instanceのidと紛らわしいのでid -> typeにする
|
||||||
|
|
||||||
@@ -76,6 +88,11 @@ const selectedObjectDef = computed(() => OBJECT_DEFS.find(def => def.id === sele
|
|||||||
const showObjectOptions = ref(false);
|
const showObjectOptions = ref(false);
|
||||||
const engine = shallowRef<RoomObjectPreviewEngine | null>(null);
|
const engine = shallowRef<RoomObjectPreviewEngine | null>(null);
|
||||||
|
|
||||||
|
const recentlyUsedDefs = computed(() => {
|
||||||
|
const recentlyUsed = store.s.recentlyUsedRoomObjects;
|
||||||
|
return recentlyUsed.map(id => OBJECT_DEFS.find(def => def.id === id)).filter((def): def is typeof OBJECT_DEFS[number] => def != null);
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
engine.value = await createRoomObjectPreviewEngine(canvas.value!);
|
engine.value = await createRoomObjectPreviewEngine(canvas.value!);
|
||||||
|
|
||||||
@@ -142,20 +159,22 @@ async function cancel() {
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.catalogItems {
|
.main {
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
|
||||||
grid-gap: 12px;
|
|
||||||
padding: 12px;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
background: var(--MI_THEME-bg);
|
background: var(--MI_THEME-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.catalogItem {
|
.catalogItems {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||||
|
grid-gap: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
.selected {
|
|
||||||
|
.catalogItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
.preview {
|
.preview {
|
||||||
|
|||||||
Reference in New Issue
Block a user