修复讲解详情页返回按钮

This commit is contained in:
lyf
2026-07-03 02:44:51 +08:00
parent c26713ebf3
commit 8b2c36677e

View File

@@ -400,14 +400,29 @@ const handleNavigate = async () => {
}) })
} }
const fallbackToExplainHome = () => {
uni.reLaunch({
url: '/pages/index/index?tab=explain'
})
}
const handleBack = () => { const handleBack = () => {
if (typeof window !== 'undefined' && window.history.length > 1) {
const currentHref = window.location.href
window.history.back()
// H5 深链或异常历史栈下 history.back 可能不改变页面,兜底回到讲解首页。
window.setTimeout(() => {
if (window.location.href === currentHref) {
fallbackToExplainHome()
}
}, 800)
return
}
uni.navigateBack({ uni.navigateBack({
delta: 1, delta: 1,
fail: () => { fail: fallbackToExplainHome
uni.reLaunch({
url: '/pages/index/index?tab=explain'
})
}
}) })
} }
</script> </script>