fix(iframe-drawer): cannot change url when video changes (#1072)

* fix: 抽屉页面内点击其他链接跳转后,“在新标签页打开“按钮无法正确导向至当前链接 #1068

* chore: update

* chore: update

---------

Co-authored-by: Hakadao <a578457889743@gmail.com>
This commit is contained in:
apades
2024-11-11 01:53:10 +08:00
committed by GitHub
parent 1aa285d854
commit 55273b770b
6 changed files with 108 additions and 30 deletions

View File

@@ -192,20 +192,20 @@ async function haveScrollbar() {
return scrollHeight > window.innerHeight
}
// When opening a video in drawer mode, listen for changes to the drawer's inner iframe url.
// When the iframe's url changes, update the parent url to match the iframe's url.
const beforeUrl = ref<string>(location.href.replace(/\/$/, ''))
if (inIframe.value) {
useEventListener(window, 'pushstate', handleIframeUrlChange)
useEventListener(window, 'click', handleIframeUrlChange)
// // When opening a video in drawer mode, listen for changes to the drawer's inner iframe url.
// // When the iframe's url changes, update the parent url to match the iframe's url.
// const beforeUrl = ref<string>(location.href.replace(/\/$/, ''))
// if (inIframe.value) {
// // useEventListener(window, 'pushstate', handleIframeUrlChange)
// useEventListener(window, 'click', handleIframeUrlChange)
function handleIframeUrlChange() {
if (beforeUrl.value.replace(/\/$/, '') !== parent.location.href.replace(/\/$/, '')) {
parent.history.pushState(null, '', location.href.replace(/\/$/, ''))
}
beforeUrl.value = location.href.replace(/\/$/, '')
}
}
// function handleIframeUrlChange() {
// if (beforeUrl.value.replace(/\/$/, '') !== parent.location.href.replace(/\/$/, '')) {
// parent.history.pushState(null, '', location.href.replace(/\/$/, ''))
// }
// beforeUrl.value = location.href.replace(/\/$/, '')
// }
// }
provide<BewlyAppProvider>('BEWLY_APP', {
activatedPage,