Files
misskey/packages/frontend-embed/src/pages/note.vue
syuilo 3f0aaaa41e perf(embed): improve embed performance (#14613)
* wip

* wip

* wip

* refactor

* refactor

---------

Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
2024-09-23 19:49:52 +09:00

46 lines
1.0 KiB
Vue

<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<div :class="$style.noteEmbedRoot">
<EmNoteDetailed v-if="note" :note="note"/>
<XNotFound v-else/>
</div>
</template>
<script setup lang="ts">
import { inject, ref } from 'vue';
import * as Misskey from 'misskey-js';
import EmNoteDetailed from '@/components/EmNoteDetailed.vue';
import XNotFound from '@/pages/not-found.vue';
import { DI } from '@/di.js';
import { misskeyApi } from '@/misskey-api.js';
import { assertServerContext } from '@/server-context';
const props = defineProps<{
noteId: string;
}>();
const serverContext = inject(DI.serverContext)!;
const note = ref<Misskey.entities.Note | null>(null);
if (assertServerContext(serverContext, 'note')) {
note.value = serverContext.note;
} else {
note.value = await misskeyApi('notes/show', {
noteId: props.noteId,
}).catch(() => {
return null;
});
}
</script>
<style lang="scss" module>
.noteEmbedRoot {
background-color: var(--panel);
}
</style>