Skip to content

Commit d5d47c0

Browse files
committed
docs: update README.md
1 parent 0b9c772 commit d5d47c0

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

README.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default defineConfig({
5858
plugins: [
5959
vue(),
6060
webUpdateNotice({
61+
// custom notification UI
6162
customNotificationHTML: `
6263
<div style="background-color: #fff;padding: 24px;border-radius: 4px;position: fixed;top: 24px;right: 24px;border: 1px solid;">
6364
System update, please refresh the page
@@ -68,6 +69,25 @@ export default defineConfig({
6869
});
6970
```
7071

72+
```ts
73+
// vite.config.ts
74+
export default defineConfig({
75+
plugins: [
76+
vue(),
77+
webUpdateNotice({
78+
hiddenDefaultNotification: true
79+
}),
80+
]
81+
});
82+
83+
84+
// other file to listener custom update event
85+
document.body.addEventListener('system_update_vite_plugin_web_update_notification', options => {
86+
console.log(options)
87+
alert('System update!')
88+
})
89+
```
90+
7191

7292

7393
## Options
@@ -78,10 +98,11 @@ function webUpdateNotice(options?: Options): Plugin;
7898
interface Options {
7999
/** polling interval(ms), default 10*60*1000 */
80100
checkInterval?: number;
81-
/** wheather to output commit-hash in console */
101+
/** whether to output commit-hash in console */
82102
logHash?: boolean;
83103
customNotificationHTML?: string;
84104
notificationProps?: NotificationProps;
105+
hiddenDefaultNotification?: boolean
85106
}
86107

87108
interface NotificationProps {

README.zh-CN.md

+21
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ export default defineConfig({
6969
})
7070
```
7171

72+
```ts
73+
// vite.config.ts
74+
export default defineConfig({
75+
plugins: [
76+
vue(),
77+
webUpdateNotice({
78+
hiddenDefaultNotification: true
79+
}),
80+
]
81+
});
82+
83+
84+
// 在其他文件中监听自定义更新事件
85+
document.body.addEventListener('system_update_vite_plugin_web_update_notification', options => {
86+
console.log(options)
87+
alert('System update!')
88+
})
89+
```
90+
91+
92+
7293
## Options
7394

7495
```ts

0 commit comments

Comments
 (0)