From 56bac1fa0fdcd5d06e76494f3cafbef30df8d5ea Mon Sep 17 00:00:00 2001 From: tianhao Date: Tue, 16 Jun 2026 12:42:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(#9,#16,#17):=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8import;=20=E5=90=88=E5=B9=B6=E9=87=8D?= =?UTF-8?q?=E5=A4=8DCSS=20@media=20print;=20accessibility=E4=BB=8Ei18n?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E7=B1=BB=E5=9E=8B=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core.js | 2 +- src/plugins.js | 6 ++++-- src/styles.js | 10 +++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/core.js b/src/core.js index 0d1170e..6d0220d 100644 --- a/src/core.js +++ b/src/core.js @@ -5,7 +5,7 @@ * @description 重构后的核心模块,包含Toast类的优化实现 */ -import { generateId, escapeHTML, prefersDark } from './utils.js'; +import { generateId, escapeHTML } from './utils.js'; import { DEFAULTS, ICONS, TYPE_COLORS, THEMES } from './constants.js'; import { injectStyles } from './styles.js'; import { getTheme, applyTheme } from './themes.js'; diff --git a/src/plugins.js b/src/plugins.js index 2575b64..e6b23d8 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -5,6 +5,8 @@ * @description 插件管理器 + 3 款预设插件 (keyboard / persistence / accessibility) */ +import { t } from './i18n.js'; + /** * 插件管理器 */ @@ -154,8 +156,8 @@ const presetPlugins = { el.setAttribute('aria-live', 'assertive'); el.setAttribute('aria-atomic', 'true'); el.style.cssText = 'position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;'; - const typeNames = { success:'成功', error:'错误', warning:'警告', info:'信息', loading:'加载中', default:'通知' }; - el.textContent = `${typeNames[toast.type] || '通知'}: ${toast.title || ''} ${toast.message || ''}`; + const typeName = t(toast.type) || toast.type; + el.textContent = `${typeName}: ${toast.title || ''} ${toast.message || ''}`; document.body.appendChild(el); setTimeout(() => { if (el.parentNode) el.parentNode.removeChild(el); }, 3000); }, diff --git a/src/styles.js b/src/styles.js index e60f108..f13b876 100644 --- a/src/styles.js +++ b/src/styles.js @@ -446,6 +446,9 @@ const generateCSS = (theme) => { .met-container { display: none !important; } + .met-toast { + display: none !important; + } } /* 高对比度模式 */ @@ -663,13 +666,6 @@ const generateCSS = (theme) => { } } - /* 打印时隐藏 */ - @media print { - .met-toast { - display: none !important; - } - } - /* 滚动时固定位置 */ .met-container { position: fixed;