Javascript 使用清单json添加到主屏幕propmpt不显示

Javascript 使用清单json添加到主屏幕propmpt不显示,javascript,vue.js,service-worker,progressive-web-apps,Javascript,Vue.js,Service Worker,Progressive Web Apps,我需要使用manifest.json向主屏幕添加添加提示,但当我在审计中的pwa分数为100%时,该提示不显示 我有如下dist文件夹:- 我的清单如下: { "name": "xyz", "short_name": "xyz", "icons": [ { "src": "/xyz/static/img/icons/xy-icon-192x192.png", "sizes": "192x192", "type": "image/png"

我需要使用manifest.json向主屏幕添加添加提示,但当我在审计中的pwa分数为100%时,该提示不显示

我有如下dist文件夹:-

我的清单如下:

{
  "name": "xyz",
  "short_name": "xyz",
  "icons": [
    {
      "src": "/xyz/static/img/icons/xy-icon-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "/xyz/static/img/icons/xy-icon-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ],
  "start_url": "xyz/index.html",
  "scope": ".",
  "display": "standalone",
  "background_color": "#0628b9",
  "theme_color": "#000000"
}
我正在为service worker使用workbox插件,并尝试使用普通service worker,如下所示:-

sw.js

我在灯塔的pwa分数是100%。


但我无法看到添加到主屏幕的提示

测试/调试A2HS时,大部分工作是清除以前的测试和安装。
一遍又一遍。
浏览器有意记住上次执行的操作,因此用户不会被安装提示所困扰。
如果希望再次看到提示,可能需要完全清除缓存

如果您对以前的提示说“否”,则在XX个月内,它不会再次请求。
如果已经安装,则不应再次询问

要寻找的一些东西
--在桌面浏览器中
--从中删除图标chrome://apps/

--如果不起作用,您可能需要清除缓存

是否已完全清除浏览器并卸载以前的安装?它会记住您是否对以前的提示回答“否”,如果您已经安装,则不会提示。请其他人在他们的设备上试用您正在测试的设备和浏览器?自动提示仅适用于Android Chrome&Edge。其他浏览器是手动A2HS。感谢Mathias的及时响应!我正在chrome浏览器上测试它。有时会显示,但删除图标后也不会显示。它只提示过一次,但不是现在。Chrome桌面还是android?
var VERSION = '20';

self.addEventListener('install', function(e) {
  e.waitUntil(caches.open(VERSION).then(cache => {
    return cache.addAll([
      'https://cfjedimaster.github.io/nomanssky/client/index.html'
    ]);
}))
});

self.addEventListener('fetch', function(e) {
  var tryInCachesFirst = caches.open(VERSION).then(cache => {
    return cache.match(e.request).then(response => {
      if (!response) {
    return handleNoCacheMatch(e);
  }
  // Update cache record in the background
  fetchFromNetworkAndCache(e);
  // Reply with stale data
  return response
});
});
  e.respondWith(tryInCachesFirst);
});

self.addEventListener('activate', function(e) {
  e.waitUntil(caches.keys().then(keys => {
    return Promise.all(keys.map(key => {
      if (key !== VERSION)
    return caches.delete(key);
}));
}));
});

function fetchFromNetworkAndCache(e) {
  // DevTools opening will trigger these o-i-c requests, which this SW can't handle.
  // There's probaly more going on here, but I'd rather just ignore this problem. :)
  // https://github.com/paulirish/caltrainschedule.io/issues/49
  if (e.request.cache === 'only-if-cached' && e.request.mode !== 'same-origin') return;

  return fetch(e.request).then(res => {
    // foreign requests may be res.type === 'opaque' and missing a url
    if (!res.url) return res;
  // regardless, we don't want to cache other origin's assets
  if (new URL(res.url).origin !== location.origin) return res;

  return caches.open(VERSION).then(cache => {
    // TODO: figure out if the content is new and therefore the page needs a reload.
    cache.put(e.request, res.clone());
  return res;
});
}).catch(err => console.error(e.request.url, err));
}

function handleNoCacheMatch(e) {
  return fetchFromNetworkAndCache(e);
}