是否可以传递 base64 字符串来定义 Manifest.json 中的图标?

Is it possible to pass a base64 string to define the icon inside a Manifest.json?

像这样:

{
  "theme_color": "#2196f3",
  "icon": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
  "background_color": "#2196f3",
  "display": "browser",
  "scope": "/",
  "start_url": "/"
}

还有... 如果有效,会有任何限制吗? 哪个 browser/platform 可能不接受?

不,我不相信。

图标属性也应该是对象数组,包含srctypesizes,例如:

"icons": [
  {
    "src": "/images/icons-192.png",
    "type": "image/png",
    "sizes": "192x192"
  },
  {
    "src": "/images/icons-512.png",
    "type": "image/png",
    "sizes": "512x512"
  }
],

有关详细信息,请参阅 web.dev 上的 Add a web app manifest

是的,你可以。 如前所述,'icons' 属性 是一个数组,在 'src' 属性 中,您可以将 base64 字符串设置为 png 数据图像格式:

"icons": [
  {
    "src": "data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
    "type": "image/png",
    "sizes": "192x192"
  },
  {
    "src": "data:image/png;base64,XXXXXXXX.......",
    "type": "image/png",
    "sizes": "512x512"
  }
],