1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-17 03:15:36 +02:00

fix(frontend): routerがmatchAllに入った際に一度 location.href による遷移を試みる挙動に関する修正 (#17281)

* fix(frontend): follow-up of #13509

* fix: fix use of inappropriate method

* Update CHANGELOG.md [ci skip]
This commit is contained in:
かっこかり
2026-04-07 20:35:06 +09:00
committed by GitHub
parent b9923d0a23
commit d4a5048aae
6 changed files with 99 additions and 28 deletions

View File

@@ -28,7 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { computed, onMounted, onUnmounted, provide, ref, useTemplateRef } from 'vue';
import { computed, onMounted, onUnmounted, provide, ref, useTemplateRef, nextTick } from 'vue';
import { url } from '@@/js/config.js';
import type { PageMetadata } from '@/page.js';
import RouterView from '@/components/global/RouterView.vue';
@@ -98,6 +98,24 @@ windowRouter.addListener('replace', ctx => {
_history_.value.push({ path: ctx.fullPath });
});
windowRouter.addListener('forcePush', ctx => {
window.open(url + ctx.fullPath, '_blank', 'noopener');
if (ctx.onInit) {
nextTick(() => {
windowEl.value?.close();
});
}
});
windowRouter.addListener('forceReplace', ctx => {
window.open(url + ctx.fullPath, '_blank', 'noopener');
if (ctx.onInit) {
nextTick(() => {
windowEl.value?.close();
});
}
});
windowRouter.addListener('change', ctx => {
if (_DEV_) console.log('windowRouter: change', ctx.fullPath);
searchMarkerId.value = getSearchMarker(ctx.fullPath);
@@ -107,7 +125,7 @@ windowRouter.addListener('change', ctx => {
});
});
windowRouter.init();
windowRouter.init(true);
provide(DI.router, windowRouter);
provide(DI.inAppSearchMarkerId, searchMarkerId);

View File

@@ -31,6 +31,7 @@ const props = withDefaults(defineProps<{
});
const behavior = props.behavior ?? inject<MkABehavior>('linkNavigationBehavior', null);
const isWindow = inject<boolean>('inWindow', false);
const el = useTemplateRef('el');
@@ -92,7 +93,11 @@ function nav(ev: PointerEvent) {
ev.preventDefault();
if (behavior === 'browser') {
window.location.href = props.to;
if (isWindow) {
window.open(props.to, '_blank', 'noopener');
} else {
window.location.href = props.to;
}
return;
}