File tree 2 files changed +43
-1
lines changed
2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export default defineConfig({
58
58
plugins: [
59
59
vue (),
60
60
webUpdateNotice ({
61
+ // custom notification UI
61
62
customNotificationHTML: `
62
63
<div style="background-color: #fff;padding: 24px;border-radius: 4px;position: fixed;top: 24px;right: 24px;border: 1px solid;">
63
64
System update, please refresh the page
@@ -68,6 +69,25 @@ export default defineConfig({
68
69
});
69
70
```
70
71
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
+
71
91
72
92
73
93
## Options
@@ -78,10 +98,11 @@ function webUpdateNotice(options?: Options): Plugin;
78
98
interface Options {
79
99
/** polling interval(ms), default 10*60*1000 */
80
100
checkInterval? : number ;
81
- /** wheather to output commit-hash in console */
101
+ /** whether to output commit-hash in console */
82
102
logHash? : boolean ;
83
103
customNotificationHTML? : string ;
84
104
notificationProps? : NotificationProps ;
105
+ hiddenDefaultNotification? : boolean
85
106
}
86
107
87
108
interface NotificationProps {
Original file line number Diff line number Diff line change @@ -69,6 +69,27 @@ export default defineConfig({
69
69
})
70
70
```
71
71
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
+
72
93
## Options
73
94
74
95
``` ts
You can’t perform that action at this time.
0 commit comments