cecil / theme-pwa
Cecil 组件主题 PWA
资助包维护!
ArnaudLigny
Open Collective
Requires
- cecil/theme-installer: ^1.4
- 2.x-dev
- dev-master / 2.x-dev
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.19.0
- 1.18.1
- 1.18.0
- 1.17.2
- 1.17.1
- 1.17.0
- 1.16.0
- 1.15.4
- 1.15.3
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.4
- 1.14.3
- 1.14.2
- 1.14.1
- 1.14.0
- 1.13.7
- 1.13.6
- 1.13.5
- 1.13.4
- 1.13.3
- 1.13.2
- 1.13.1
- 1.13.0
- 1.12.6
- 1.12.5
- 1.12.4
- 1.12.3
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.1
- 1.11.0
- 1.10.1
- 1.10.0
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
This package is auto-updated.
Last update: 2024-09-10 23:55:08 UTC
README
为 Cecil 提供了一个 PWA 组件主题,它提供了一些助手来实现 Web 清单 和 Service Worker,将网站转换成一个 渐进式 Web 应用。
特性
- 生成和可配置的 Web 清单
- 生成和可配置的 Service Worker
- 自动缓存访问过的资源
- 无依赖项,纯 JavaScript
- 预先缓存已发布的页面
- 预先缓存资产列表
- 通用离线页面和默认图像(SVG)
先决条件
安装
composer require cecil/theme-pwa
或者 下载最新存档 并在
themes/pwa
中解压缩其内容。
用法
在 config.yml
的 theme
部分添加 pwa
theme: - pwa
Web 清单
在主模板的 HTML <header>
中添加 web manifest
<link rel="manifest" href="{{ url('manifest') }}">
配置它
manifest: background_color: '#FFFFFF' theme_color: '#202020' icons: - icon-192x192.png - icon-512x512.png - src: icon-192x192-maskable.png purpose: maskable - src: icon-512x512-maskable.png purpose: maskable
技巧
使用 Maskable.app 创建你自己的 可遮罩图标。
Web 清单(可选)
添加 shortcuts
manifest: shortcuts: true
manifest: screenshots: - screenshots/screenshot-desktop.png - screenshots/screenshot-mobile.png
服务工作者
在 HTML </body>
结束前 注册 服务工作者
{{ include('partials/regsw.js.twig', {site: site}, with_context = false) }}
启用服务工作者
serviceworker: enabled: true
服务工作者(可选)
定义预缓存资产
serviceworker: install: precache: assets: - logo.png - icon-192x192.png - icon-512x512.png - icon-192x192-maskable.png - icon-512x512-maskable.png
限制预缓存页面数量
serviceworker: install: precache: pages: limit: 10
禁用安装提示
serviceworker: install: prompt: false
定义忽略路径
serviceworker: ignore: - name: 'cms' path: '/admin'
不要通过其元数据预缓存特定页面
--- serviceworker: precache: false ---