feat(iframe-bridge): implement iframe communication bridge and language sync

This commit is contained in:
2025-11-14 20:07:08 +08:00
parent 4356813820
commit 034c190373
15 changed files with 469 additions and 160 deletions

View File

@@ -0,0 +1,23 @@
import type { ChildApi } from '@teres/iframe-bridge';
import logger from '@/utils/logger';
let childPromise: Promise<ChildApi> | null = null;
export function setChildPromise(promise: Promise<ChildApi>) {
childPromise = promise;
}
export function clearChildPromise() {
childPromise = null;
}
export async function changeChildLanguage(lng: string) {
if (!childPromise) return;
try {
const child = await childPromise;
// @ts-ignore
await child?.changeLanguage?.(lng);
} catch (err) {
logger.warn('changeChildLanguage failed', err);
}
}