@@ -58,14 +58,14 @@ export default (api: IApi) => {
5858 ) ;
5959 } catch ( _ ) {
6060 throw new Error (
61- `Can't find @plugin-web-update-notification/core package. Please install antd first.` ,
61+ `Can't find @plugin-web-update-notification/core package. Please install @plugin-web-update-notification/core first.` ,
6262 ) ;
6363 }
6464
6565 function checkPkgPath ( ) {
6666 if ( ! pkgPath ) {
6767 throw new Error (
68- `Can't find @plugin-web-update-notification/core package. Please install antd first.` ,
68+ `Can't find @plugin-web-update-notification/core package. Please install @plugin-web-update-notification/core first.` ,
6969 ) ;
7070 }
7171 }
@@ -75,34 +75,107 @@ export default (api: IApi) => {
7575 api . describe ( {
7676 key : 'webUpdateNotification' ,
7777 config : {
78- schema ( Joi ) {
79- return Joi . object ( {
80- versionType : Joi . string ( ) ,
81- customVersion : Joi . string ( ) ,
82- checkInterval : Joi . number ( ) ,
83- logVersion : Joi . boolean ( ) ,
84- checkOnWindowFocus : Joi . boolean ( ) ,
85- checkImmediately : Joi . boolean ( ) ,
86- checkOnLoadFileError : Joi . boolean ( ) ,
87- injectFileBase : Joi . string ( ) ,
88- customNotificationHTML : Joi . string ( ) ,
89- notificationProps : {
90- title : Joi . string ( ) ,
91- description : Joi . string ( ) ,
92- buttonText : Joi . string ( ) ,
93- dismissButtonText : Joi . string ( ) ,
94- } ,
95- notificationConfig : {
96- primaryColor : Joi . string ( ) ,
97- secondaryColor : Joi . string ( ) ,
98- placement : Joi . string ( ) ,
99- } ,
100- silence : Joi . boolean ( ) ,
101- locale : Joi . string ( ) ,
102- localeData : Joi . object ( ) ,
103- hiddenDefaultNotification : Joi . boolean ( ) ,
104- hiddenDismissButton : Joi . boolean ( ) ,
105- } ) ;
78+ schema ( { zod } ) {
79+ return zod
80+ . object ( {
81+ versionType : zod
82+ . string ( )
83+ . describe ( '版本生成类型。指定如何生成版本号,如 "build_timestamp"(构建时间戳)、"package_version"(package.json 版本)、"custom"(自定义版本)等。决定检测更新的版本比较依据。' )
84+ . optional ( ) ,
85+ customVersion : zod
86+ . string ( )
87+ . describe ( '自定义版本号。当 versionType 为 "custom" 时使用的版本字符串。可以是任意格式的版本标识,用于手动控制版本检测逻辑。' )
88+ . optional ( ) ,
89+ checkInterval : zod
90+ . number ( )
91+ . describe ( '版本检查间隔时间(毫秒)。设置自动检查新版本的时间间隔,如 30000 表示每30秒检查一次。设为 0 或负数时禁用定时检查。' )
92+ . optional ( ) ,
93+ logVersion : zod
94+ . boolean ( )
95+ . describe ( '是否在控制台输出版本信息。设为 true 时会在浏览器控制台打印当前版本和检查过程的日志信息,便于开发调试。' )
96+ . optional ( ) ,
97+ checkOnWindowFocus : zod
98+ . boolean ( )
99+ . describe ( '是否在窗口获得焦点时检查更新。设为 true 时,当用户切换回页面标签时会自动检查是否有新版本,提高更新检测的及时性。' )
100+ . optional ( ) ,
101+ checkImmediately : zod
102+ . boolean ( )
103+ . describe ( '是否立即检查更新。设为 true 时,页面加载完成后立即执行一次版本检查,而不等待设定的检查间隔。' )
104+ . optional ( ) ,
105+ checkOnLoadFileError : zod
106+ . boolean ( )
107+ . describe ( '是否在文件加载错误时检查更新。设为 true 时,当页面加载资源文件失败时会触发版本检查,判断是否因为版本更新导致的文件路径变化。' )
108+ . optional ( ) ,
109+ injectFileBase : zod
110+ . string ( )
111+ . describe ( '注入文件的基础路径。指定检查文件和通知相关资源的请求路径前缀,默认使用 publicPath 配置。用于适配不同的部署环境和 CDN 配置。' )
112+ . optional ( ) ,
113+ customNotificationHTML : zod
114+ . string ( )
115+ . describe ( '自定义通知 HTML 内容。提供完全自定义的更新通知界面 HTML 字符串,替代默认的通知样式。设置后会忽略 notificationProps 和 notificationConfig 配置。' )
116+ . optional ( ) ,
117+ notificationProps : zod
118+ . object ( {
119+ title : zod
120+ . string ( )
121+ . describe ( '通知标题文本。显示在更新通知弹窗顶部的主标题内容。' )
122+ . optional ( ) ,
123+ description : zod
124+ . string ( )
125+ . describe ( '通知描述文本。显示在通知弹窗中的详细说明内容,用于告知用户发现新版本。' )
126+ . optional ( ) ,
127+ buttonText : zod
128+ . string ( )
129+ . describe ( '更新按钮文本。点击后刷新页面的主按钮显示文本,如 "立即更新"。' )
130+ . optional ( ) ,
131+ dismissButtonText : zod
132+ . string ( )
133+ . describe ( '关闭按钮文本。用于关闭通知弹窗的按钮显示文本,如 "稍后提醒"。' )
134+ . optional ( )
135+ } )
136+ . describe ( '通知内容属性配置。定义更新通知弹窗中显示的文本内容,包括标题、描述和按钮文字。' )
137+ . optional ( ) ,
138+ notificationConfig : zod
139+ . object ( {
140+ primaryColor : zod
141+ . string ( )
142+ . describe ( '通知主要颜色。设置通知弹窗的主色调,通常用于按钮和高亮元素,如 "#1890ff"。' )
143+ . optional ( ) ,
144+ secondaryColor : zod
145+ . string ( )
146+ . describe ( '通知次要颜色。设置通知弹窗的辅助色调,用于背景或边框等元素。' )
147+ . optional ( ) ,
148+ placement : zod
149+ . string ( )
150+ . describe ( '通知显示位置。指定通知弹窗在页面中的显示位置,如 "top"、"bottom"、"topRight" 等。' )
151+ . optional ( )
152+ } )
153+ . describe ( '通知样式配置。定义更新通知弹窗的外观样式,包括颜色主题和显示位置。' )
154+ . optional ( ) ,
155+ silence : zod
156+ . boolean ( )
157+ . describe ( '是否启用静默模式。设为 true 时,版本检查在后台静默进行,生成的 JSON 文件不包含提示信息,通常用于自定义通知实现。' )
158+ . optional ( ) ,
159+ locale : zod
160+ . string ( )
161+ . describe ( '语言环境设置。指定通知界面的语言,如 "zh-CN"、"en-US" 等。影响默认文本内容的语言显示。' )
162+ . optional ( ) ,
163+ localeData : zod
164+ . record ( zod . any ( ) )
165+ . describe ( '自定义语言数据对象。提供多语言文本映射,用于覆盖或扩展默认的语言包内容。键为语言代码,值为对应的文本配置。' )
166+ . optional ( ) ,
167+ hiddenDefaultNotification : zod
168+ . boolean ( )
169+ . describe ( '是否隐藏默认通知界面。设为 true 时不显示内置的通知弹窗,通常配合 customNotificationHTML 使用或实现完全自定义的通知逻辑。' )
170+ . optional ( ) ,
171+ hiddenDismissButton : zod
172+ . boolean ( )
173+ . describe ( '是否隐藏关闭按钮。设为 true 时通知弹窗中不显示 "稍后提醒" 类型的关闭按钮,强制用户必须更新。' )
174+ . optional ( )
175+ } )
176+ . describe ( '网页更新通知插件配置。基于 @plugin-web-update-notification/core 提供自动检测网页更新并显示通知的功能。支持多种版本检测策略、自定义通知界面、多语言、样式配置等特性。仅在生产环境下生效,通过比对版本文件判断是否有新版本发布。' )
177+ . optional ( )
178+ . default ( { } ) ;
106179 } ,
107180 } ,
108181 enableBy ( ) {
0 commit comments