feat: Enhance Home component to support language messaging

- Added language messaging functionality to the iframe in the Home component.
- This update ensures that the iframe receives the current language setting, improving localization support.
This commit is contained in:
CalciumIon
2024-12-16 21:10:46 +08:00
parent 1f70904fc5
commit fe6f3d7978

View File

@@ -7,7 +7,7 @@ import { StyleContext } from '../../context/Style/index.js';
import { useTranslation } from 'react-i18next';
const Home = () => {
const { t } = useTranslation();
const { t, i18n } = useTranslation();
const [statusState] = useContext(StatusContext);
const [homePageContentLoaded, setHomePageContentLoaded] = useState(false);
const [homePageContent, setHomePageContent] = useState('');
@@ -49,6 +49,7 @@ const Home = () => {
// console.log('Sending theme-mode to iframe:', theme);
iframe.onload = () => {
iframe.contentWindow.postMessage({ themeMode: theme }, '*');
iframe.contentWindow.postMessage({ lang: i18n.language }, '*');
};
}
}