优化苹果与微信内地址导航

This commit is contained in:
Rei
2026-09-09 13:00:00 +08:00
parent ddb919a3a2
commit 3c2b633dad
+14 -3
View File
@@ -22,9 +22,20 @@ export default function Footer() {
window.location.href = `geo:0,0?q=${destination}` window.location.href = `geo:0,0?q=${destination}`
} else if (/iPhone|iPad|iPod/i.test(ua)) { } else if (/iPhone|iPad|iPod/i.test(ua)) {
event.preventDefault() event.preventDefault()
// Apple Maps Link is an HTTPS URL, which Safari and most iOS webviews if (/MicroMessenger/i.test(ua)) {
// handle more reliably than the blocked custom `maps://` scheme. // WeChat blocks third-party app schemes on iOS. Give the visitor a useful
window.location.href = appleMapsLink // next step instead of leaving the tap with no visible response.
void window.navigator.clipboard?.writeText(address).catch(() => undefined)
window.alert('微信内无法直接唤起地图 App,地址已复制。请点击右上角“···”,选择“在 Safari 中打开”后再点击导航。')
return
}
// AMap's iOS scheme opens the installed AMap app and uses its current
// location as the starting point when only dname is supplied.
const openedAt = Date.now()
window.location.href = `iosamap://path?sourceApplication=ameiba&dname=${destination}&t=0`
window.setTimeout(() => {
if (!document.hidden && Date.now() - openedAt >= 1_000) window.location.href = appleMapsLink
}, 1_200)
} }
} }
return ( return (