From 88ae899d96a53a85fcb49f256b0c996fc5d5fca4 Mon Sep 17 00:00:00 2001 From: tianhao Date: Tue, 16 Jun 2026 13:01:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20RTL=E5=B8=83=E5=B1=80=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20=E2=80=94=20close=E5=8A=A8=E7=94=BB=E6=96=B9=E5=90=91?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=80=82=E9=85=8D=E8=AF=AD=E8=A8=80=E6=96=B9?= =?UTF-8?q?=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core.js b/src/core.js index 4d78f10..d679700 100644 --- a/src/core.js +++ b/src/core.js @@ -9,7 +9,7 @@ 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'; -import { t as i18nT, setCurrentLocale } from './i18n.js'; +import { t as i18nT, setCurrentLocale, getLocaleDirection, getCurrentLocale } from './i18n.js'; // 模块级共享容器缓存,所有 Toast 实例共用 // 使用 Map 而非 WeakMap:document.body 在页面存活期间永不被 GC, @@ -493,10 +493,11 @@ class Toast { el.classList.remove('met-show'); const pos = this.config.position || 'top-right'; + const isRTL = getLocaleDirection(getCurrentLocale()) === 'rtl'; let transform = 'scale(.96)'; - if (pos.includes('right')) transform = 'translateX(120%)'; - else if (pos.includes('left')) transform = 'translateX(-120%)'; + if (pos.includes('right')) transform = isRTL ? 'translateX(-120%)' : 'translateX(120%)'; + else if (pos.includes('left')) transform = isRTL ? 'translateX(120%)' : 'translateX(-120%)'; else if (pos.startsWith('top')) transform = 'translateY(-20px)'; else transform = 'translateY(20px)';