File size: 631 Bytes
4e1096a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { isTauriAppPlatform } from '@/services/environment';
import { openUrl } from '@tauri-apps/plugin-opener';

interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
  href: string;
  title?: string;
}

const Link: React.FC<LinkProps> = ({ href, children, ...props }) => {
  const handleClick = async (e: React.MouseEvent<HTMLAnchorElement>) => {
    if (isTauriAppPlatform()) {
      e.preventDefault();
      await openUrl(href);
    }
  };

  return (
    <a href={href} target='_blank' rel='noopener noreferrer' onClick={handleClick} {...props}>
      {children}
    </a>
  );
};

export default Link;