fix: 制御キーの場合を個別ハンドリングするのではなくブラウザ既定の挙動に任せるように
This commit is contained in:
parent
63b7beb73b
commit
d044217b98
|
@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<a ref="el" :href="to" :class="active ? activeClass : null" @click.prevent="nav" @contextmenu.prevent.stop="onContextmenu">
|
<a ref="el" :href="to" :class="active ? activeClass : null" @click="nav" @contextmenu.prevent.stop="onContextmenu">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
@ -86,6 +86,11 @@ function openWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function nav(ev: MouseEvent) {
|
function nav(ev: MouseEvent) {
|
||||||
|
// 制御キーとの組み合わせは無視(shiftを除く)
|
||||||
|
if (ev.metaKey || ev.altKey || ev.ctrlKey) return;
|
||||||
|
|
||||||
|
ev.preventDefault();
|
||||||
|
|
||||||
if (behavior === 'browser') {
|
if (behavior === 'browser') {
|
||||||
window.location.href = props.to;
|
window.location.href = props.to;
|
||||||
return;
|
return;
|
||||||
|
@ -99,11 +104,6 @@ function nav(ev: MouseEvent) {
|
||||||
return openWindow();
|
return openWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev.ctrlKey) {
|
|
||||||
window.open(props.to, '_blank', 'noopener');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
router.pushByPath(props.to, ev.ctrlKey ? 'forcePage' : null);
|
router.pushByPath(props.to, ev.ctrlKey ? 'forcePage' : null);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue