小编kkl*_*zak的帖子

在 Angular 5 中添加 ServiceWorkerModule 后,PWA 显示独立和全屏不起作用

当前行为

将配置添加到应用程序模块environment.production ? ServiceWorkerModule.register('./ngsw-worker.js') : []serviceWorker在 .angular-cli.json 中启用后,我的应用程序在通过 Chrome 安装在我的设备(LG G6)display上并在我的设备上打开standalonefullscreen打开后在我的设备上设置 manifest.json 中的属性后,应用程序始终在浏览器中打开在新标签中。当我删除 Service Worker 配置(应用模块中的行)时,仅在独立或全屏模式下打开清单的应用。

预期行为

安装应用程序后,应用程序应以 stadalone 或全屏模式打开,取决于 manifest.json 中的设置值。

使用说明最小化问题的重现

我有使用 4.3 版生成并更新到 5.1.3 的应用程序,添加 @angular/service-worker 并build使用--prod. 为了为应用程序提供服务,我在我的 chrome 中使用端口转发。

清单文件

{
  "short_name": "FindPark",
  "name": "Find Nearby Car Parks",
  "start_url": "/search",

  "theme_color": "#206886",
  "background_color": "#ffffff",

  "display": "standalone",
  "orientation": "portrait",

  "icons": [
    {
      "src": "/assets/favicon-72x72.png",
      "sizes": "72x72",
      "type": "image/png"
    },
    {
      "src": "/assets/favicon-96x96.png",
      "sizes": …
Run Code Online (Sandbox Code Playgroud)

displaymode progressive-web-apps manifest.json angular

2
推荐指数
1
解决办法
6531
查看次数