From 2f91d8ccb329c85e18deb2aa873a3732b5d9a9d3 Mon Sep 17 00:00:00 2001
From: "G.RQ" <61670021+guoruqiang@users.noreply.github.com>
Date: Mon, 6 Jul 2026 13:57:20 +0800
Subject: [PATCH] fix(web): sync home iframe theme and language (#5917)
---
web/default/src/features/home/index.tsx | 29 ++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/web/default/src/features/home/index.tsx b/web/default/src/features/home/index.tsx
index 0494191e..abfc9a29 100644
--- a/web/default/src/features/home/index.tsx
+++ b/web/default/src/features/home/index.tsx
@@ -16,11 +16,13 @@ along with this program. If not, see .
For commercial licensing, please contact support@quantumnous.com
*/
+import { useCallback, useEffect, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { PublicLayout } from '@/components/layout'
import { Footer } from '@/components/layout/components/footer'
import { RichContent } from '@/components/rich-content'
+import { useTheme } from '@/context/theme-provider'
import { isLikelyHtml } from '@/lib/content-format'
import { useAuthStore } from '@/stores/auth-store'
@@ -28,11 +30,34 @@ import { CTA, Features, Hero, HowItWorks, Stats } from './components'
import { useHomePageContent } from './hooks'
export function Home() {
- const { t } = useTranslation()
+ const { i18n, t } = useTranslation()
+ const iframeRef = useRef(null)
+ const { resolvedTheme } = useTheme()
const { auth } = useAuthStore()
const isAuthenticated = !!auth.user
const { content, isLoaded, isUrl } = useHomePageContent()
+ const syncIframePreferences = useCallback(() => {
+ try {
+ iframeRef.current?.contentWindow?.postMessage(
+ { themeMode: resolvedTheme },
+ '*'
+ )
+ iframeRef.current?.contentWindow?.postMessage(
+ { lang: i18n.language },
+ '*'
+ )
+ } catch {
+ // Cross-origin frames may reject access while navigating.
+ }
+ }, [i18n.language, resolvedTheme])
+
+ useEffect(() => {
+ if (isUrl) {
+ syncIframePreferences()
+ }
+ }, [isUrl, syncIframePreferences])
+
if (!isLoaded) {
return (
@@ -48,10 +73,12 @@ export function Home() {
return (
)