xcatliu / pagic

A static site generator powered by Deno + React
https://pagic.org
MIT License
1.64k stars 104 forks source link

在博客插件下,点击进入某篇文章之后,使用浏览器的后退,将无法点击任何链接。 #115

Open rainzee opened 12 months ago

rainzee commented 12 months ago

当点击进入某篇文章后,使用浏览器的后退,回到博客主页,此时任何文章,都无法点击。

Redlnn commented 12 months ago

原因是,按下后退按钮后回到博客主页时自动执行的 rerender() 内,有如下判断

https://github.com/xcatliu/pagic/blob/61c63447bbfa5190f02c6d9a364a13e83cfc24c5/src/plugins/script_index.js#L79-L82

该判断中,lastProps.layoutPath !== props.layoutPath 成立,只改变了地址栏的 URL 就触发 returnloading 没有被置为 false,在下一次点击链接触发 rerender() 时,下面的判断使得函数无法运行到后续跳转的部分

https://github.com/xcatliu/pagic/blob/61c63447bbfa5190f02c6d9a364a13e83cfc24c5/src/plugins/script_index.js#L57-L59