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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user