File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- export function shareContent ( title : string , text : string , url ?: string ) {
1+ export async function shareContent ( title : string , text : string , url ?: string ) {
22 const shareUrl = url || window . location . href ;
33 if ( navigator . share ) {
4- navigator . share ( { title, text, url : shareUrl } ) . catch ( ( ) => { } ) ;
4+ try {
5+ await navigator . share ( { title, text, url : shareUrl } ) ;
6+ } catch {
7+ // User cancelled or share failed, try clipboard fallback
8+ try {
9+ await navigator . clipboard . writeText ( `${ text } ${ shareUrl } ` ) ;
10+ } catch {
11+ // Clipboard also failed, silently ignore
12+ }
13+ }
514 } else {
6- navigator . clipboard . writeText ( `${ text } ${ shareUrl } ` ) . catch ( ( ) => { } ) ;
15+ try {
16+ await navigator . clipboard . writeText ( `${ text } ${ shareUrl } ` ) ;
17+ } catch {
18+ // Clipboard failed, silently ignore
19+ }
720 }
821}
922
You can’t perform that action at this time.
0 commit comments