当切换暗模式时,我可以停止 Chrome on Android 刷新页面吗?

Can I stop Chrome on Android refreshing the page when dark mode is toggled?

我有一个简单的音乐播放器应用程序,它存储一个瞬态播放列表。我的三星手机也有预定的暗模式 (运行 Android 10)。当黑暗模式时间到来时(如果我手动切换黑暗模式),Chrome 刷新页面,立即丢失播放列表和缓存的歌曲。

理想情况下它不会这样做。有什么办法可以禁用此行为吗?

我试过的

我尝试设置 window.onbeforeunload 功能,这使我无法手动刷新页面。但是,当我切换系统暗模式时,它会被忽略并且 Chrome 会自动刷新页面。

我已经在我的 Windows 10 桌面上测试了深色模式的切换,Google Chrome 没有刷新页面。

好吧,我起草了这个问题,并认为我还要检查 chrome 移动标志以备不时之需。

原来有一个选项,使用 enable-android-night-mode-tab-reparenting 标志:

If enabled, when the user changes themes the tabs are reparented instead of reloaded – Android

启用时,选项卡会重新绘制而不是重新加载。