From 20b6d03617611a9d9beb15cba40902825a9efb8f Mon Sep 17 00:00:00 2001 From: thzxx <1440196015@qq.com> Date: Fri, 24 Jul 2026 15:06:21 +0800 Subject: [PATCH] =?UTF-8?q?release:=20v0.4.2=20=E2=80=94=20MetonaToast=200?= =?UTF-8?q?.1.2=20=E9=99=8D=E7=BA=A7=E4=B8=8E=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - chore: @metona-team/metona-toast 2.0.1 -> 0.1.2 - chore: 应用版本号 0.4.1 -> 0.4.2 --- DESIGN.md | 2 +- DEVSETUP.md | 2 +- README.md | 2 +- docs/metona-toast-demo.html | 46 +++++++++++++++++++++++++++++-------- docs/metona-toast-docs.html | 22 ++++++++++-------- package.json | 4 ++-- src/shared/constants.ts | 2 +- 7 files changed, 55 insertions(+), 25 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 0f4223e..b78f268 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -1,4 +1,4 @@ -# MarkLite v0.4.1 — 架构设计文档 +# MarkLite v0.4.2 — 架构设计文档 ## 1. 项目概述 diff --git a/DEVSETUP.md b/DEVSETUP.md index c1842d8..72f7e18 100644 --- a/DEVSETUP.md +++ b/DEVSETUP.md @@ -1,4 +1,4 @@ -# MarkLite v0.4.1 — 开发环境配置指南 +# MarkLite v0.4.2 — 开发环境配置指南 以下涵盖从 Node 版本管理、镜像源配置到 electron-builder 打包的全流程。 diff --git a/README.md b/README.md index c3ebe0a..2ae5333 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ TypeScript React License - Version + Version

diff --git a/docs/metona-toast-demo.html b/docs/metona-toast-demo.html index 677e342..ffbc685 100644 --- a/docs/metona-toast-demo.html +++ b/docs/metona-toast-demo.html @@ -136,7 +136,7 @@

-
⚡ Action Toast v2.0
+
⚡ Action Toast
@@ -146,7 +146,7 @@
-
📁 分组管理 v2.0
+
📁 分组管理
@@ -209,9 +209,9 @@
- +
-
🆕 v2.0 新功能 resetTimer · onUpdate · render · notify
+
🔥 高级特性 resetTimer · onUpdate · render · notify
@@ -242,7 +242,16 @@
- + +
+
🛡️ onError 错误捕获 v0.1.2
+
+ + +
+
+ +
✋ 交互特性
@@ -254,7 +263,7 @@
- +
🌍 国际化 & 格式化
@@ -264,7 +273,7 @@
- +
🎨 107种预设图标 — 点击任意图标发送Toast
@@ -273,7 +282,7 @@ @@ -351,7 +360,7 @@ MeToast.info('自定义插件已安装(消息后追加计数)'); } - // === v2.0 new features === + // === 高级特性 === function demoResetTimer() { const t=MeToast.info('这条消息不会自动消失(resetTimer)',{duration:3000,resetTimerOnUpdate:true,closeButton:true}); let n=0; const iv=setInterval(()=>{n++;if(n>8){clearInterval(iv);t.close();return;}t.update({message:'重置计时器 #'+n+' — 每次更新重置3秒'});},1000); @@ -387,6 +396,25 @@ }); } + // === onError === + function demoOnError() { + MeToast.configure({ + onError: function(info) { + MeToast.error('⚠️ 捕获错误: ' + (info.hook || info.source), { duration: 3000, position: 'bottom-center' }); + } + }); + MeToast.info('已启用 onError 监控(钩子/定时器异常将被捕获)', { duration: 3000 }); + // 触发一个钩子错误来演示 + var badFn = function() { throw new Error('demo-error'); }; + Toast.on('afterShow', badFn); + MeToast.success('这条消息会触发错误', { duration: 2000 }); + setTimeout(function() { Toast.off('afterShow', badFn); }, 3000); + } + function demoOnErrorReset() { + MeToast.configure({ onError: null }); + MeToast.info('onError 已重置为 null'); + } + // === i18n === function switchLocale(loc) { try{MeToast.i18n.switchLocale(loc);MeToast.configure({locale:loc});MeToast.success(loc==='zh-CN'?'已切换到中文':'Switched to English',{theme:'dark'});} diff --git a/docs/metona-toast-docs.html b/docs/metona-toast-docs.html index 55efa52..d1bfc3d 100644 --- a/docs/metona-toast-docs.html +++ b/docs/metona-toast-docs.html @@ -69,9 +69,9 @@ countdown() queue() stack() - action() NEW + action()
管理方法
- group() NEW + group() dismiss() clear() configure() @@ -87,7 +87,7 @@

API 文档

-

MetonaToast v2.0.1 完整 API 参考。所有基础通知方法(show/success/error/warning/info/loading)支持两种调用形式,均可传入任何 配置项 作为可选第二参数。

+

MetonaToast v0.1.2 完整 API 参考。所有基础通知方法(show/success/error/warning/info/loading)支持两种调用形式,均可传入任何 配置项 作为可选第二参数。

show(message, opts?)

@@ -309,7 +309,7 @@ q.cancel(); // 中途取消 type: 'info', }); -

action(message, actions, opts?) v2.0

+

action(message, actions, opts?)

Action Toast:内嵌操作按钮。默认 duration=0 不自动关闭,closeButton=true。

@@ -331,7 +331,7 @@ q.cancel(); // 中途取消 ]); -

group(name) v2.0

+

group(name)

创建 Toast 分组,返回 GroupAPI 对象。该对象所有方法自动传入 group: name,按组管理。

参数类型默认值说明
@@ -409,7 +409,7 @@ MeToast.use('accessibility');

全部配置项

-

以下配置可用于 configure()init() 或单个 Toast 方法的 opts 参数。带 v2.0 标识的为 v2.0 新增。

+

以下配置可用于 configure()init() 或单个 Toast 方法的 opts 参数。

参数类型说明
@@ -431,9 +431,10 @@ MeToast.use('accessibility'); - - - + + + +
配置项类型默认值说明
positionstring'top-right'位置:top-left / top-center / top-right / bottom-left / bottom-center / bottom-right
classNamestring''附加到 Toast 元素上的 CSS 类名
styleobject{}附加到 Toast 元素上的内联样式对象
localestring'zh-CN'语言代码(zh-CN / en-US 等)
resetTimerOnUpdate v2.0booleanfalse调用 update() 时重置 duration 倒计时
notifyWhenHidden v2.0booleanfalse页面不可见时自动通过 Notification API 发送系统通知
render v2.0function自定义渲染函数 (toast) => htmlString,完全接管 DOM 构建
resetTimerOnUpdatebooleanfalse调用 update() 时重置 duration 倒计时
notifyWhenHiddenbooleanfalse页面不可见时自动通过 Notification API 发送系统通知
renderfunction自定义渲染函数 (toast) => htmlString,完全接管 DOM 构建
onErrorfunction全局错误回调 ({ hook, source, error, toast }) => void,钩子异常或定时器错误时触发

回调函数

@@ -442,7 +443,8 @@ MeToast.use('accessibility'); onShow(toast: ToastInstance) => voidToast DOM 创建并播放入场动画后 onClose(toast: ToastInstance) => voidToast DOM 被移除后(离场动画完成时) onClick(toast: ToastInstance) => voidToast 被点击时(closeOnClick 为 true 时还会自动关闭) -onUpdate v2.0(toast: ToastInstance) => voidToast 内容通过 update() 更新后 +onUpdate(toast: ToastInstance) => voidToast 内容通过 update() 更新后 +onError({ hook, source, error, toast }) => void钩子回调或定时器发生异常时(全局配置,适用于接入错误监控)

动画列表

diff --git a/package.json b/package.json index 67ef960..284f08f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "marklite", - "version": "0.4.1", + "version": "0.4.2", "description": "Lightweight Markdown Editor for Windows", "main": "./dist/main/index.js", "scripts": { @@ -29,7 +29,7 @@ "license": "MIT", "dependencies": { "@metona-team/metona-editor": "^0.1.10", - "@metona-team/metona-toast": "^2.0.1", + "@metona-team/metona-toast": "^0.1.2", "dexie": "^4.0.11", "nanoid": "^5.1.5", "react": "^18.3.1", diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 48985ca..2d59ad3 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -1,5 +1,5 @@ // 共享常量 — 主进程和渲染进程共用 -export const APP_VERSION = 'v0.4.1' +export const APP_VERSION = 'v0.4.2' export const MAX_FILE_SIZE = 20 * 1024 * 1024 // 20MB export const ALLOWED_EXTENSIONS = ['.md', '.markdown', '.txt'] as const export const SKIP_DIRS = new Set([