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;