Skip to content

Commit a8b06b1

Browse files
committed
docs($cn): document for themeConfig.serviceWorker.updatePopup
1 parent 92314ac commit a8b06b1

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

docs/default-theme-config/README.md

+15-9
Original file line numberDiff line numberDiff line change
@@ -356,26 +356,32 @@ Note that it's `off` by default. If given `string`, it will be displayed as a pr
356356
Since `lastUpdated` is based on `git`, you can only use it in a `git` repository. As well, since the timestamp used comes from the git commit, it will display only after a first commit for a given page, and update only on subsequent commits of that page.
357357
:::
358358

359-
## Service Workers
359+
## Service Worker
360360

361-
The `themeConfig.serviceWorker` option allows you to configure about service workers.
361+
The `themeConfig.serviceWorker` option allows you to configure about service worker.
362362

363-
### Popup UI to refresh contents
363+
::: tip
364+
Please do not confuse this option with [Config > serviceWorker](../config/README.md#serviceworker), [Config > serviceWorker](../config/README.md#serviceworker) is **site-level**, while this option is **theme-level**.
365+
:::
364366

365-
The `themeConfig.serviceWorker.updatePopup` option enables the popup to refresh contents. The popup will be shown when the site is updated (the service worker is updated). It provides `refresh` button to allow users to refresh contents immediately.
367+
### Popup UI to refresh contents <Badge text="0.13.0+"/>
366368

367-
::: tip NOTE
368-
If without the `refresh` button, the new service worker will be active after all clients are closed.
369-
This means that visitors cannot see new contents until they close all tabs of your site.
369+
The `themeConfig.serviceWorker.updatePopup` option enables the popup to refresh contents. The popup will be shown when the site is updated (i.e. service worker is updated). It provides `refresh` button to allow users to refresh contents immediately.
370370

371-
But the `refresh` button activates the new service worker immediately.
371+
::: tip NOTE
372+
If without the `refresh` button, the new service worker will be active after all [clients](https://developer.mozilla.org/en-US/docs/Web/API/Clients) are closed. This means that visitors cannot see new contents until they close all tabs of your site. But the `refresh` button activates the new service worker immediately.
372373
:::
373374

374375
``` js
375376
module.exports = {
376377
themeConfig: {
377378
serviceWorker: {
378-
updatePopup: true | {message: "New content is available.", buttonText: "Refresh"}
379+
updatePopup: true // Boolean | Object, default to undefined.
380+
// If set to true, the default text config will be:
381+
// updatePopup: {
382+
// message: "New content is available.",
383+
// buttonText: "Refresh"
384+
// }
379385
}
380386
}
381387
}

docs/zh/default-theme-config/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,37 @@ module.exports = {
351351
由于 `lastUpdated` 是基于 `git` 的, 所以你只能在一个基于 `git` 的项目中启用它。
352352
:::
353353

354+
## Service Worker
355+
356+
`themeConfig.serviceWorker` 允许你去配置 Service Worker。
357+
358+
::: tip 提示
359+
请不要将本选项与 [Config > serviceWorker](../config/README.md#serviceworker) 混淆,[Config > serviceWorker](../config/README.md#serviceworker) 是网站级别的配置,而本选项是主题级别的配置。
360+
:::
361+
362+
### 刷新内容的弹窗 <Badge text="0.13.0+"/>
363+
364+
开启 `themeConfig.serviceWorker.updatePopup` 选项,将开启一个能够刷新内容的弹窗。当网站更新(即 Service Worker 更新)时,它会提供一个 `refresh` 按钮,允许用户立刻刷新内容。
365+
366+
::: tip 提示
367+
如果没有 `refresh` 按钮,新的 service worker 将在所有的 [clients](https://developer.mozilla.org/en-US/docs/Web/API/Clients) 关闭后才会处于活动状态。这意味着访问者在关闭你网站的所有标签之前将无法看到新内容。但是,`refresh` 按钮可以立即激活新的 Service Worker。
368+
:::
369+
370+
``` js
371+
module.exports = {
372+
themeConfig: {
373+
serviceWorker: {
374+
updatePopup: true // Boolean | Object, 默认值是 undefined.
375+
// 如果设置为 true, 默认的文本配置将是:
376+
// updatePopup: {
377+
// message: "New content is available.",
378+
// buttonText: "Refresh"
379+
// }
380+
}
381+
}
382+
}
383+
```
384+
354385
## 上 / 下一篇链接
355386

356387
上一篇和下一篇文章的链接将会自动地根据当前页面的侧边栏的顺序来获取。你也可以使用 `YAML front matter` 来明确地重写或者禁用它:

0 commit comments

Comments
 (0)