fix color theme change bug

This commit is contained in:
Xin Wang 2025-12-17 12:04:01 +08:00
parent 800aa700f9
commit 7fbb9a5431

View File

@ -75,6 +75,7 @@ export default function Playground({
const [rpcMethod, setRpcMethod] = useState("");
const [rpcPayload, setRpcPayload] = useState("");
const [showRpc, setShowRpc] = useState(false);
const [qrCodeUrl, setQrCodeUrl] = useState<string>("");
// Clean up RPC resolvers before disconnecting to prevent errors
const cleanupRpcResolvers = useCallback(() => {
@ -406,6 +407,7 @@ export default function Playground({
}, [agentVideoTrack, config, roomState]);
useEffect(() => {
if (typeof document !== "undefined") {
document.body.style.setProperty(
"--lk-theme-color",
// @ts-ignore
@ -415,8 +417,15 @@ export default function Playground({
"--lk-drop-shadow",
`var(--lk-theme-color) 0px 0px 18px`,
);
}
}, [config.settings.theme_color]);
useEffect(() => {
if (typeof window !== "undefined") {
setQrCodeUrl(window.location.href);
}
}, []);
const audioTileContent = useMemo(() => {
const disconnectedContent = (
<div className="flex flex-col items-center justify-center gap-2 text-gray-700 text-center w-full">
@ -738,10 +747,10 @@ export default function Playground({
<AudioInputTile trackRef={localMicTrack} />
</ConfigurationPanelItem>
)}
{config.show_qr && (
{config.show_qr && qrCodeUrl && (
<div className="w-full">
<ConfigurationPanelItem title="QR Code">
<QRCodeSVG value={window.location.href} width="128" />
<QRCodeSVG value={qrCodeUrl} width="128" />
</ConfigurationPanelItem>
</div>
)}