## Summary - restore the GitHub and Discord links on the folder picker in the Tauri app - open those links through the desktop opener bridge instead of relying on browser-only navigation behavior - include the capability/schema updates needed for the opener path ## Testing - npm run typecheck --workspace @codenomad/ui - cargo check --manifest-path packages/tauri-app/src-tauri/Cargo.toml
24 lines
587 B
TypeScript
24 lines
587 B
TypeScript
import { isTauriHost } from "./runtime-env"
|
|
|
|
export async function openExternalUrl(url: string, context = "ui"): Promise<void> {
|
|
if (typeof window === "undefined") {
|
|
return
|
|
}
|
|
|
|
if (isTauriHost()) {
|
|
try {
|
|
const { openUrl } = await import("@tauri-apps/plugin-opener")
|
|
await openUrl(url)
|
|
return
|
|
} catch (error) {
|
|
console.warn(`[${context}] unable to open via system opener`, error)
|
|
}
|
|
}
|
|
|
|
try {
|
|
window.open(url, "_blank", "noopener,noreferrer")
|
|
} catch (error) {
|
|
console.warn(`[${context}] unable to open external url`, error)
|
|
}
|
|
}
|