简体   繁体   English

manifest.json的'orientation'和'display'属性仅在注册Service Worker时有效吗?

[英]Do 'orientation' and 'display' properties of manifest.json only work when service worker is registered?

I'm building my first progressive web app. 我正在构建我的第一个渐进式Web应用程序。 I haven't got as far as registering a service worker just yet, but I have created a manifest.json file, which looks like this: 我还没有注册服务工作者,但是我创建了一个manifest.json文件,看起来像这样:

{
  "short_name": "My PWA",
  "name": "My Progressive Web Application",
  "start_url": "/",
  "background_color": "#222",
  "display": "standalone",
  "scope": "/",
  "theme_color": "#222",
  "orientation": "portrait",
  "icons": [
    {
      "src": "/assets/images/logo-square-192.png",
      "type": "image/png",
      "sizes": "192x192"
    },
    {
      "src": "/assets/images/logo-square-512.png",
      "type": "image/png",
      "sizes": "512x512"
    }
  ]
}

I've loaded this onto a test server (not running over HTTPS currently, so I'm aware that a service worker won't work, hence I haven't got that far yet) and have looked at the site on Chrome latest on a new Nokia 6.1 running Android. 我已将其加载到测试服务器上(当前未在HTTPS上运行,因此我知道服务人员无法正常工作,因此目前为止还没有到此为止),并且最近浏览了Chrome上的网站运行Android的新诺基亚6.1。 I notice that the 'display' property doesn't seem to be doing what it should, and I can also turn the device to landscape and browse the site in that orientation. 我注意到'display'属性似乎没有按照其应有的方式工作,我还可以将设备横向放置并以该方向浏览网站。 So it seems that the manifest.json file isn't doing anything. 因此,似乎manifest.json文件没有执行任何操作。

I can't find any documentation stating whether the manifest.json file only becomes 'active' when a service worker is installed and/or via HTTPS so I wondered if anyone here could shed any light on this? 我找不到任何文档来说明manifest.json文件是否仅在安装Service Worker和/或通过HTTPS时才变为“活动”,所以我想知道这里是否有人对此有所了解?

Many thanks. 非常感谢。

So a bit of experimentation later... It seems the manifest.json rules only become active once the site has been added to the home-screen. 因此,稍后进行了一些实验...似乎只有将站点添加到主屏幕后,manifest.json规则才会变为活动状态。 (I don't have a service worker to facilitate this yet, but it can be done in the browser settings). (我还没有服务人员来帮助您完成此操作,但是可以在浏览器设置中完成此操作)。 So on Chrome/Android at least the manifest settings don't need HTTPS enabled nor a service worker. 因此,在Chrome / Android上,至少清单设置不需要启用HTTPS或服务工作者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM