File tree Expand file tree Collapse file tree 4 files changed +33
-2
lines changed
Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { useTranslation } from '@/i18n'
44import { AppVersion } from './AppVersionPayload'
55import { Separator } from './ui/separator'
66import { Link } from 'react-router-dom'
7- // import { Link } from 'react-router-dom '
7+ import { handleExternalLinkClick } from '@/lib/openExternalUrl '
88
99const CONTACTS = [
1010 {
@@ -36,6 +36,7 @@ export function AppFooter() {
3636 < a
3737 key = { contact . link }
3838 href = { contact . link }
39+ onClick = { ( event ) => handleExternalLinkClick ( event , contact . link ) }
3940 target = "_blank"
4041 rel = "noopener noreferrer"
4142 aria-label = { contact [ 'aria-label' ] }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { useTranslation } from '../../i18n'
1616import { cn } from '../../lib/utils'
1717import { LICENSE_LINK , PRIVACY_LINK , VERSION_DISPLAY } from '../../lib/version'
1818import { Badge } from '../ui/badge'
19+ import { handleExternalLinkClick } from '@/lib/openExternalUrl'
1920
2021function SettingSidebarRoot ( props : React . ComponentProps < typeof Sidebar > ) {
2122 return < Sidebar { ...props } />
@@ -118,6 +119,7 @@ function SettingSidebarFooter({
118119 < a
119120 className = "hover:underline hover:text-foreground transition-color"
120121 href = { PRIVACY_LINK }
122+ onClick = { ( event ) => handleExternalLinkClick ( event , PRIVACY_LINK ) }
121123 target = "_blank"
122124 rel = "noopener noreferrer"
123125 >
@@ -127,6 +129,7 @@ function SettingSidebarFooter({
127129 < a
128130 className = "hover:underline hover:text-foreground transition-color"
129131 href = { LICENSE_LINK }
132+ onClick = { ( event ) => handleExternalLinkClick ( event , LICENSE_LINK ) }
130133 target = "_blank"
131134 rel = "noopener noreferrer"
132135 >
Original file line number Diff line number Diff line change 1+ import { openUrl } from '@tauri-apps/plugin-opener'
2+
3+ export async function openExternalUrl ( url : string ) : Promise < void > {
4+ if ( IS_TAURI ) {
5+ await openUrl ( url )
6+ return
7+ }
8+
9+ const openedWindow = window . open ( url , '_blank' , 'noopener,noreferrer' )
10+ if ( openedWindow ) {
11+ openedWindow . opener = null
12+ }
13+ }
14+
15+ export function handleExternalLinkClick (
16+ event : { preventDefault : ( ) => void } ,
17+ url : string
18+ ) : void {
19+ if ( ! IS_TAURI ) {
20+ return
21+ }
22+
23+ event . preventDefault ( )
24+ void openExternalUrl ( url ) . catch ( ( error ) => {
25+ console . error ( 'Failed to open external URL:' , error )
26+ } )
27+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ import packageJson from '../../../package.json'
33export const VERSION = packageJson . version
44export const VERSION_DISPLAY = `v${ VERSION } `
55export const PRIVACY_LINK =
6- 'https://github.com/tonyantony300/alt-sendme/blob/main/PRIVACY'
6+ 'https://github.com/tonyantony300/alt-sendme/blob/main/PRIVACY.md '
77export const LICENSE_LINK =
88 'https://github.com/tonyantony300/alt-sendme/blob/main/LICENSE'
You can’t perform that action at this time.
0 commit comments