mirror of
https://github.com/fankes/beszel.git
synced 2025-10-18 17:29:28 +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}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
$router.open(new URL((e.currentTarget as HTMLAnchorElement).href).pathname)
|
||||
props.onClick?.(e)
|
||||
const href = props.href || ""
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
window.open(href, "_blank")
|
||||
} else {
|
||||
$router.open(href)
|
||||
props.onClick?.(e)
|
||||
}
|
||||
}}
|
||||
></a>
|
||||
)
|
||||
|
Reference in New Issue
Block a user