fix(frontend/pageMetadata): ページタイトルが更新されない問題 (#13289)
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
parent
bb83ee844e
commit
860e8bb5d8
140 changed files with 496 additions and 430 deletions
|
@ -16,9 +16,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
@closed="$emit('closed')"
|
||||
>
|
||||
<template #header>
|
||||
<template v-if="pageMetadata?.value">
|
||||
<i v-if="pageMetadata.value.icon" :class="pageMetadata.value.icon" style="margin-right: 0.5em;"></i>
|
||||
<span>{{ pageMetadata.value.title }}</span>
|
||||
<template v-if="pageMetadata">
|
||||
<i v-if="pageMetadata.icon" :class="pageMetadata.icon" style="margin-right: 0.5em;"></i>
|
||||
<span>{{ pageMetadata.title }}</span>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ComputedRef, onMounted, onUnmounted, provide, ref, shallowRef } from 'vue';
|
||||
import { computed, onMounted, onUnmounted, provide, ref, shallowRef } from 'vue';
|
||||
import RouterView from '@/components/global/RouterView.vue';
|
||||
import MkWindow from '@/components/MkWindow.vue';
|
||||
import { popout as _popout } from '@/scripts/popout.js';
|
||||
|
@ -37,7 +37,7 @@ import copyToClipboard from '@/scripts/copy-to-clipboard.js';
|
|||
import { url } from '@/config.js';
|
||||
import { useScrollPositionManager } from '@/nirax.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { PageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata.js';
|
||||
import { PageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
|
||||
import { openingWindowsCount } from '@/os.js';
|
||||
import { claimAchievement } from '@/scripts/achievements.js';
|
||||
import { getScrollContainer } from '@/scripts/scroll.js';
|
||||
|
@ -56,7 +56,7 @@ const routerFactory = useRouterFactory();
|
|||
const windowRouter = routerFactory(props.initialPath);
|
||||
|
||||
const contents = shallowRef<HTMLElement | null>(null);
|
||||
const pageMetadata = ref<null | ComputedRef<PageMetadata>>();
|
||||
const pageMetadata = ref<null | PageMetadata>(null);
|
||||
const windowEl = shallowRef<InstanceType<typeof MkWindow>>();
|
||||
const history = ref<{ path: string; key: any; }[]>([{
|
||||
path: windowRouter.getCurrentPath(),
|
||||
|
@ -101,9 +101,11 @@ windowRouter.addListener('replace', ctx => {
|
|||
windowRouter.init();
|
||||
|
||||
provide('router', windowRouter);
|
||||
provideMetadataReceiver((info) => {
|
||||
provideMetadataReceiver((metadataGetter) => {
|
||||
const info = metadataGetter();
|
||||
pageMetadata.value = info;
|
||||
});
|
||||
provideReactiveMetadata(pageMetadata);
|
||||
provide('shouldOmitHeaderTitle', true);
|
||||
provide('shouldHeaderThin', true);
|
||||
provide('forceSpacerMin', true);
|
||||
|
|
|
@ -11,18 +11,18 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</div>
|
||||
<div v-else-if="!thin_ && narrow && !hideTitle" :class="$style.buttonsLeft"/>
|
||||
|
||||
<template v-if="metadata">
|
||||
<template v-if="pageMetadata">
|
||||
<div v-if="!hideTitle" :class="$style.titleContainer" @click="top">
|
||||
<div v-if="metadata.avatar" :class="$style.titleAvatarContainer">
|
||||
<MkAvatar :class="$style.titleAvatar" :user="metadata.avatar" indicator/>
|
||||
<div v-if="pageMetadata.avatar" :class="$style.titleAvatarContainer">
|
||||
<MkAvatar :class="$style.titleAvatar" :user="pageMetadata.avatar" indicator/>
|
||||
</div>
|
||||
<i v-else-if="metadata.icon" :class="[$style.titleIcon, metadata.icon]"></i>
|
||||
<i v-else-if="pageMetadata.icon" :class="[$style.titleIcon, pageMetadata.icon]"></i>
|
||||
|
||||
<div :class="$style.title">
|
||||
<MkUserName v-if="metadata.userName" :user="metadata.userName" :nowrap="true"/>
|
||||
<div v-else-if="metadata.title">{{ metadata.title }}</div>
|
||||
<div v-if="metadata.subtitle" :class="$style.subtitle">
|
||||
{{ metadata.subtitle }}
|
||||
<MkUserName v-if="pageMetadata.userName" :user="pageMetadata.userName" :nowrap="true"/>
|
||||
<div v-else-if="pageMetadata.title">{{ pageMetadata.title }}</div>
|
||||
<div v-if="pageMetadata.subtitle" :class="$style.subtitle">
|
||||
{{ pageMetadata.subtitle }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -46,7 +46,7 @@ import tinycolor from 'tinycolor2';
|
|||
import XTabs, { Tab } from './MkPageHeader.tabs.vue';
|
||||
import { scrollToTop } from '@/scripts/scroll.js';
|
||||
import { globalEvents } from '@/events.js';
|
||||
import { injectPageMetadata } from '@/scripts/page-metadata.js';
|
||||
import { injectReactiveMetadata } from '@/scripts/page-metadata.js';
|
||||
import { $i, openAccountMenu as openAccountMenu_ } from '@/account.js';
|
||||
import { PageHeaderItem } from '@/types/page-header.js';
|
||||
|
||||
|
@ -64,7 +64,7 @@ const emit = defineEmits<{
|
|||
(ev: 'update:tab', key: string);
|
||||
}>();
|
||||
|
||||
const metadata = injectPageMetadata();
|
||||
const pageMetadata = injectReactiveMetadata();
|
||||
|
||||
const hideTitle = inject('shouldOmitHeaderTitle', false);
|
||||
const thin_ = props.thin || inject('shouldHeaderThin', false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue