如何为Google Chrome构建插件/扩展程序,以在用户桌面上为网站创建快捷方式图标

时间:2020-04-18 18:49:57

标签: javascript google-chrome google-chrome-extension desktop-shortcut chrome-plugins

我想拥有Install功能,例如在此网站中: https://lacasadehamburguer.grandchef.com.br/?fbclid=IwAR14WN_LkR92kT8rocPFk4CqEEyAlXA4hA7Gl3SASc_eEg972RG5QckzgvM

用户点击按钮Install时,会将插件“已安装”添加到chrome中,并在用户的桌面上创建一个图标。

此功能如何命名?

1 个答案:

答案 0 :(得分:1)

声明PWA(Progress Web应用程序),以便Google Chrome可以检测到并提供访问者安装。

您必须为PWA编写一个manifest文件,其中描述了您的应用程序,版本,主题颜色,应用程序图标等。

清单文件如下所示:

{
  "background_color": "orange",
  "description": "Cute and random little cat pictures.",
  "display": "fullscreen",
  "icons": [
    {
      "src": "icon/cat-icon.png",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "name": "Cute cat pictures",
  "short_name": "Cats",
  "start_url": "/pwa-examples/a2hs/index.html"
}

使用Google Chrome桌面安装

您可以通过从浏览器安装PWA来对其进行测试,这是在Google Chrome上进行安装的方式:

  1. 访问要作为PWA安装的单页应用程序。
  2. 在“位置”标签中,有一个+图标,单击它并选择Install
  3. 注意要在系统上安装该应用程序并启动它。

通过Google Chrome桌面卸载

  • 导航至chrome://apps/,然后右键单击应用程序图标,然后选择Remove from Chrome

您可以在此处了解有关此清单文件的更多信息:

相关问题