feat: Enhance HeaderBar to support language change messaging

- Added functionality to post a message to the iframe when the language is changed.
- This update improves localization support by ensuring that the iframe content updates according to the selected language.
This commit is contained in:
CalciumIon
2024-12-16 21:05:02 +08:00
parent c8f437c13a
commit fd86de19b5

View File

@@ -105,6 +105,10 @@ const HeaderBar = () => {
useEffect(() => {
const handleLanguageChanged = (lng) => {
setCurrentLang(lng);
const iframe = document.querySelector('iframe');
if (iframe) {
iframe.contentWindow.postMessage({ lang: lng }, '*');
}
};
i18n.on('languageChanged', handleLanguageChanged);