fix: 🐛
This commit is contained in:
parent
b4618e8cd1
commit
f697421c1b
1 changed files with 8 additions and 1 deletions
|
|
@ -109,6 +109,7 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
|
||||||
|
|
||||||
const onPopState = (e: PopStateEvent) => {
|
const onPopState = (e: PopStateEvent) => {
|
||||||
let state = e.state as { index: number; url: string } | null
|
let state = e.state as { index: number; url: string } | null
|
||||||
|
console.log('popstate', state)
|
||||||
setSecondaryStack((pre) => {
|
setSecondaryStack((pre) => {
|
||||||
const currentItem = pre[pre.length - 1] as TStackItem | undefined
|
const currentItem = pre[pre.length - 1] as TStackItem | undefined
|
||||||
const currentIndex = currentItem?.index
|
const currentIndex = currentItem?.index
|
||||||
|
|
@ -202,8 +203,14 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const popSecondaryPage = () => {
|
const popSecondaryPage = () => {
|
||||||
|
if (secondaryStack.length === 1) {
|
||||||
|
// back to home page
|
||||||
|
window.history.replaceState(null, '', '/')
|
||||||
|
setSecondaryStack([])
|
||||||
|
} else {
|
||||||
window.history.go(-1)
|
window.history.go(-1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const clearSecondaryPages = () => {
|
const clearSecondaryPages = () => {
|
||||||
if (secondaryStack.length === 0) return
|
if (secondaryStack.length === 0) return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue