2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
2024-02-14 00:59:27 +09:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-05-15 19:08:46 +09:00
|
|
|
<template>
|
2024-06-01 21:37:34 +09:00
|
|
|
<div
|
|
|
|
ref="rootEl"
|
|
|
|
:class="isEmbed ? [
|
|
|
|
$style.rootForEmbedPage,
|
|
|
|
{
|
|
|
|
[$style.rounded]: embedRounded,
|
|
|
|
}
|
|
|
|
] : [$style.root]"
|
|
|
|
>
|
2023-07-07 20:18:06 +09:00
|
|
|
<div style="container-type: inline-size;">
|
|
|
|
<RouterView/>
|
|
|
|
</div>
|
2023-05-15 19:08:46 +09:00
|
|
|
|
|
|
|
<XCommon/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-06-01 21:37:34 +09:00
|
|
|
import { computed, provide, ref, shallowRef, onMounted, onUnmounted } from 'vue';
|
2023-05-15 19:08:46 +09:00
|
|
|
import XCommon from './_common_/common.vue';
|
2024-02-16 16:17:09 +09:00
|
|
|
import { PageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
|
2023-09-19 16:37:43 +09:00
|
|
|
import { instanceName } from '@/config.js';
|
2024-01-30 21:07:34 +09:00
|
|
|
import { mainRouter } from '@/router/main.js';
|
2024-06-01 21:37:34 +09:00
|
|
|
import { isEmbedPage } from '@/scripts/embed-page.js';
|
|
|
|
import { postMessageToParentWindow } from '@/scripts/post-message';
|
2023-05-15 19:08:46 +09:00
|
|
|
|
2024-06-01 21:37:34 +09:00
|
|
|
const isEmbed = isEmbedPage();
|
2024-06-01 21:03:39 +09:00
|
|
|
|
2024-02-16 16:17:09 +09:00
|
|
|
const isRoot = computed(() => mainRouter.currentRoute.value.name === 'index');
|
|
|
|
|
|
|
|
const pageMetadata = ref<null | PageMetadata>(null);
|
2023-05-15 19:08:46 +09:00
|
|
|
|
|
|
|
provide('router', mainRouter);
|
2024-02-16 16:17:09 +09:00
|
|
|
provideMetadataReceiver((metadataGetter) => {
|
|
|
|
const info = metadataGetter();
|
2023-12-07 14:42:09 +09:00
|
|
|
pageMetadata.value = info;
|
2024-02-16 16:17:09 +09:00
|
|
|
if (pageMetadata.value) {
|
|
|
|
if (isRoot.value && pageMetadata.value.title === instanceName) {
|
|
|
|
document.title = pageMetadata.value.title;
|
|
|
|
} else {
|
|
|
|
document.title = `${pageMetadata.value.title} | ${instanceName}`;
|
|
|
|
}
|
2023-05-15 19:08:46 +09:00
|
|
|
}
|
|
|
|
});
|
2024-02-16 16:17:09 +09:00
|
|
|
provideReactiveMetadata(pageMetadata);
|
2023-05-15 19:08:46 +09:00
|
|
|
|
2024-06-01 21:37:34 +09:00
|
|
|
//#region Embed Style
|
|
|
|
const params = new URLSearchParams(location.search);
|
|
|
|
const embedRounded = ref(params.get('rounded') !== '0');
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region Embed Resizer
|
|
|
|
const rootEl = shallowRef<HTMLElement | null>(null);
|
|
|
|
|
|
|
|
if (isEmbed) {
|
|
|
|
const resizeObserver = new ResizeObserver(async () => {
|
|
|
|
postMessageToParentWindow('misskey:embed:changeHeight', {
|
|
|
|
height: rootEl.value!.scrollHeight + 2, // border 上下1px
|
|
|
|
});
|
|
|
|
});
|
|
|
|
onMounted(() => {
|
|
|
|
resizeObserver.observe(rootEl.value!);
|
|
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
|
|
resizeObserver.disconnect();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
if (isEmbed) {
|
|
|
|
document.documentElement.style.maxWidth = '500px';
|
|
|
|
document.documentElement.classList.add('embed');
|
|
|
|
} else {
|
2024-06-01 21:03:39 +09:00
|
|
|
document.documentElement.style.overflowY = 'scroll';
|
|
|
|
}
|
2023-05-15 19:08:46 +09:00
|
|
|
</script>
|
|
|
|
|
2023-05-19 16:30:39 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2023-05-15 19:08:46 +09:00
|
|
|
min-height: 100dvh;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
2024-06-01 21:03:39 +09:00
|
|
|
|
|
|
|
.rootForEmbedPage {
|
|
|
|
box-sizing: border-box;
|
2024-06-01 21:37:34 +09:00
|
|
|
border: 1px solid var(--divider);
|
|
|
|
background-color: var(--bg);
|
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&.rounded {
|
|
|
|
border-radius: var(--radius);
|
|
|
|
}
|
2024-06-01 21:03:39 +09:00
|
|
|
}
|
2023-05-15 19:08:46 +09:00
|
|
|
</style>
|