lavas-project / hexo-pwa

Hexo PWA plugin
MIT License
133 stars 17 forks source link

如何设置? #5

Closed jerryc127 closed 6 years ago

jerryc127 commented 6 years ago

我设置了manifest.json

{
  "name": "Jerryc",
  "short_name": "JerryC",
  "theme_color": "#3f51b5",
  "background_color": "#3f51b5",
  "display": "fullscreen",
  "Scope": "/",
  "start_url": "/",
  "icons": [
    {
      "src": "img/icons/icon-72x72.png",
      "sizes": "72x72",
      "type": "image/png"
    },
    {
      "src": "img/icons/icon-96x96.png",
      "sizes": "96x96",
      "type": "image/png"
    },
    {
      "src": "img/icons/icon-128x128.png",
      "sizes": "128x128",
      "type": "image/png"
    },
    {
      "src": "img/icons/icon-144x144.png",
      "sizes": "144x144",
      "type": "image/png"
    },
    {
      "src": "img/icons/icon-152x152.png",
      "sizes": "152x152",
      "type": "image/png"
    },
    {
      "src": "img/icons/icon-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "img/icons/icon-384x384.png",
      "sizes": "384x384",
      "type": "image/png"
    },
    {
      "src": "img/icons/icon-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ],
  "splash_pages": null
}

_CONFIG 也设置了

pwa:
  manifest:
    path: /manifest.json
    body:
      # name: Jerryc
      # short_name: Jerryc 
      # icons:
      #   - src: img/icons/icon-192x192.png
      #     sizes: 192x192
      #     type: image/png
  serviceWorker:
    path: /sw.js
    preload:
      urls:
        - /
      posts: 5
    opts:
      networkTimeoutSeconds: 5
    routes:
      - pattern: !!js/regexp /hm.baidu.com/
        strategy: networkOnly
      - pattern: !!js/regexp /.*\.(js|css|jpg|jpeg|png|gif)$/
        strategy: cacheFirst
      - pattern: !!js/regexp /\//
        strategy: networkFirst
  priority: 5

但是不起作用。 我是不是漏了什么步骤 Jerryc.me

PengXing commented 6 years ago

是什么不起作用,service worker 还是 manifest

jerryc127 commented 6 years ago

不清楚 是chrome打打开网页 并没有安装网页 而是建立途经 PWA没有实现。。

PengXing commented 6 years ago

sw.js 文件应该生成了吧,然后 manifest.json 文件有点小问题,Scope => scope

验证 Service Worker 和 App Manifest 是否生效

  1. App Manifest 电脑 Chrome 打开博客,右键选择审查元素,选择 Application,点击左侧 Manifest,在右边看是否有你配置的 manifest.json 文件
  2. Service Worker 同样,打开 Chrome,和上面步骤一样,区别是在左边点击 Service Worker,看右边是否有 sw.js 文件,还可以用手机 Chrome 断网来测试 sw.js 是否生效
jerryc127 commented 6 years ago

可以了 但是能问下 为什么我点击侧边栏的item 那些 会跳到网页去,而不是在PWA里打开 网站: jerryc.me

PengXing commented 6 years ago

不知道你用的是什么浏览器,但是我用的手机端的 Chrome,是不会跳到浏览里去的

jerryc127 commented 6 years ago

chrome pc 和 Safari 都會

我把網站安裝了 打開點擊側邊欄的item會打開chrome,但是點擊首頁的文章又不會 image

jerryc127 commented 6 years ago

还有 为什么生成2个? image