优化苹果与微信内地址导航
This commit is contained in:
@@ -22,9 +22,20 @@ export default function Footer() {
|
||||
window.location.href = `geo:0,0?q=${destination}`
|
||||
} else if (/iPhone|iPad|iPod/i.test(ua)) {
|
||||
event.preventDefault()
|
||||
// Apple Maps Link is an HTTPS URL, which Safari and most iOS webviews
|
||||
// handle more reliably than the blocked custom `maps://` scheme.
|
||||
window.location.href = appleMapsLink
|
||||
if (/MicroMessenger/i.test(ua)) {
|
||||
// WeChat blocks third-party app schemes on iOS. Give the visitor a useful
|
||||
// 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 (
|
||||
|
||||
Reference in New Issue
Block a user