mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 01:39:34 +08:00
update Link component to support opening links in new tabs with ctrl/cmd key
This commit is contained in:
@@ -41,8 +41,13 @@ export function Link(props: React.AnchorHTMLAttributes<HTMLAnchorElement>) {
|
|||||||
{...props}
|
{...props}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
$router.open(new URL((e.currentTarget as HTMLAnchorElement).href).pathname)
|
const href = props.href || ""
|
||||||
props.onClick?.(e)
|
if (e.ctrlKey || e.metaKey) {
|
||||||
|
window.open(href, "_blank")
|
||||||
|
} else {
|
||||||
|
$router.open(href)
|
||||||
|
props.onClick?.(e)
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
></a>
|
></a>
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user