内部routerで遷移した場合には正規ページに転送するように

This commit is contained in:
kakkokari-gtyih 2024-06-07 16:03:30 +09:00
parent 9a61944331
commit 6fdb004d48
3 changed files with 27 additions and 15 deletions

View file

@ -40,7 +40,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script setup lang="ts">
import { ref, computed, shallowRef, inject } from 'vue';
import { ref, computed, shallowRef, inject, onActivated } from 'vue';
import * as Misskey from 'misskey-js';
import MkNotes from '@/components/MkNotes.vue';
import XNotFound from '@/pages/not-found.vue';
@ -60,12 +60,16 @@ const props = defineProps<{
enableAutoLoad?: string;
}>();
const inEmbedPage = inject<boolean>('EMBED_PAGE', false);
function redirectIfNotEmbedPage() {
const inEmbedPage = inject<boolean>('EMBED_PAGE', false);
if (!inEmbedPage) {
const router = useRouter();
router.replace(`/clips/${props.clipId}`);
if (!inEmbedPage) {
const router = useRouter();
router.replace(`/clips/${props.clipId}`);
}
}
redirectIfNotEmbedPage();
onActivated(redirectIfNotEmbedPage);
// : true
const normalizedShowHeader = computed(() => props.showHeader !== 'false');

View file

@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script setup lang="ts">
import { ref, provide, inject } from 'vue';
import { ref, provide, inject, onActivated } from 'vue';
import * as Misskey from 'misskey-js';
import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
import XNotFound from '@/pages/not-found.vue';
@ -24,12 +24,16 @@ const props = defineProps<{
noteId: string;
}>();
const inEmbedPage = inject<boolean>('EMBED_PAGE', false);
function redirectIfNotEmbedPage() {
const inEmbedPage = inject<boolean>('EMBED_PAGE', false);
if (!inEmbedPage) {
const router = useRouter();
router.replace(`/notes/${props.noteId}`);
if (!inEmbedPage) {
const router = useRouter();
router.replace(`/notes/${props.noteId}`);
}
}
redirectIfNotEmbedPage();
onActivated(redirectIfNotEmbedPage);
provide('EMBED_ORIGINAL_ENTITY_URL', `${url}/notes/${props.noteId}`);

View file

@ -46,7 +46,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script setup lang="ts">
import { ref, computed, shallowRef, inject } from 'vue';
import { ref, computed, shallowRef, inject, onActivated } from 'vue';
import * as Misskey from 'misskey-js';
import MkNotes from '@/components/MkNotes.vue';
import XNotFound from '@/pages/not-found.vue';
@ -66,12 +66,16 @@ const props = defineProps<{
enableAutoLoad?: string;
}>();
const inEmbedPage = inject<boolean>('EMBED_PAGE', false);
function redirectIfNotEmbedPage() {
const inEmbedPage = inject<boolean>('EMBED_PAGE', false);
if (!inEmbedPage) {
const router = useRouter();
router.replace(`/@${props.username}`);
if (!inEmbedPage) {
const router = useRouter();
router.replace(`/@${props.username}`);
}
}
redirectIfNotEmbedPage();
onActivated(redirectIfNotEmbedPage);
// : true
const normalizedShowHeader = computed(() => props.showHeader !== 'false');