Skip to content

Commit 75877d4

Browse files
committed
docs(plugin-pwa-popup): add plugin reference
1 parent 2905d6a commit 75877d4

File tree

2 files changed

+114
-2
lines changed

2 files changed

+114
-2
lines changed

docs/reference/plugin/pwa-popup.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
11
# pwa-popup
22

3-
> TODO
3+
> @vuepress/plugin-pwa-popup
4+
5+
Provide a popup component for users to activate the new PWA service worker manually.
6+
7+
This plugin must be used together with [pwa plugin](./pwa.md), and the `skipWaiting` option must not be set to `true`.
8+
9+
When the new service worker is ready, a popup will appear in the right bottom of the page to ask users to activate the waiting service worker.
10+
11+
## Options
12+
13+
### locales
14+
15+
- Type: `Record<string, { message: string, buttonText: string }>`
16+
17+
- Details:
18+
19+
The messages of the popup in different locales.
20+
21+
If this option is not specified, it will fallback to default messages.
22+
23+
- Example:
24+
25+
```js
26+
module.exports = {
27+
plugins: [
28+
['@vuepress/plugin-pwa'],
29+
[
30+
'@vuepress/plugin-pwa-popup',
31+
{
32+
locales: {
33+
'/': {
34+
message: 'New content is available.',
35+
buttonText: 'Refresh',
36+
},
37+
'/zh/': {
38+
message: '发现新内容可用',
39+
buttonText: '刷新',
40+
},
41+
},
42+
},
43+
],
44+
],
45+
}
46+
```
47+
48+
- Also see:
49+
- [Guide > I18n](../../guide/i18n.md)
50+
51+
## Styles
52+
53+
You can customize the style of the popup via CSS variables:
54+
55+
```css
56+
:root {
57+
--pwa-popup-color: #3eaf7c;
58+
}
59+
```

docs/zh/reference/plugin/pwa-popup.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
11
# pwa-popup
22

3-
> TODO
3+
> @vuepress/plugin-pwa-popup
4+
5+
提供一个弹窗组件,允许用户手动刷新 PWA Service Worker 。
6+
7+
该插件必须和 [pwa 插件](./pwa.md) 一起使用,并且 `skipWaiting` 配置项不能设置为 `true`
8+
9+
当新的 Service Worker 就绪时,会在页面右下角出现一个弹窗,询问用户是否需要激活处于 Waiting 状态的 Service Worker 。
10+
11+
## 配置项
12+
13+
### locales
14+
15+
- 类型: `Record<string, { message: string, buttonText: string }>`
16+
17+
- 详情:
18+
19+
弹窗在不同 locales 下的信息。
20+
21+
如果没有指定该配置项,它会降级使用默认信息。
22+
23+
- 示例:
24+
25+
```js
26+
module.exports = {
27+
plugins: [
28+
['@vuepress/plugin-pwa'],
29+
[
30+
'@vuepress/plugin-pwa-popup',
31+
{
32+
locales: {
33+
'/': {
34+
message: 'New content is available.',
35+
buttonText: 'Refresh',
36+
},
37+
'/zh/': {
38+
message: '发现新内容可用',
39+
buttonText: '刷新',
40+
},
41+
},
42+
},
43+
],
44+
],
45+
}
46+
```
47+
48+
- 参考:
49+
- [指南 > 多语言支持](../../guide/i18n.md)
50+
51+
## 样式
52+
53+
你可以通过 CSS 变量来自定义弹窗的样式:
54+
55+
```css
56+
:root {
57+
--pwa-popup-color: #3eaf7c;
58+
}
59+
```

0 commit comments

Comments
 (0)