问题描述
我的网站有几个小节.当用户将网站添加到他们的主屏幕时,我想确保主屏幕图标将他们启动到他们添加到主屏幕时所在的子部分.
My site has several subsections. When a user adds the site to their homescreen, I'd like to make sure that the home screen icon launches them into the subsection they were on when they added to homescreen.
我可以为每个小节注册不同的清单,但这不适用于没有页面重新加载的单页应用程序.我正在考虑将小节存储在 cookie 中,然后从基于该 cookie 的通用起始 URL 重定向.
I can register a different manifest for each subsection, but this doesn't work for single page apps where there's no page reload. I'm considering storing the subsection in a cookie and then redirecting from a generic start URL based on that cookie.
有没有更好的方法来做到这一点?
Is there a better way to do this?
推荐答案
如果您从 manifest.json 文件中删除 start_url
然后它将默认为用户在将 pwa 应用程序添加到主屏幕时浏览的页面.参考:https://developers.google.com/web/工具/灯塔/审计/manifest-contains-start_url
If you remove the start_url
from the manifest.json file then it will default to the page user was browsing while adding pwa app to homescreen.ref : https://developers.google.com/web/tools/lighthouse/audits/manifest-contains-start_url
这篇关于根据添加到主屏幕的 URL 在 Web 应用清单中设置 start_url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!