Skip to content

Commit

Permalink
fix: webembed settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sidmorizon committed Jan 14, 2025
1 parent cd77347 commit 358a2a3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
9 changes: 8 additions & 1 deletion apps/web-embed/pages/AppProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { ConfigProvider } from '@onekeyhq/components';

import webEmbedAppSettings from '../utils/webEmbedAppSettings';

export default function AppProvider({
children,
}: {
children: React.ReactNode;
}) {
const settings = webEmbedAppSettings.getSettings();

// TODO Toast support
return (
<ConfigProvider theme="light" locale="en-US">
<ConfigProvider
theme={settings.themeVariant as any}
locale={settings.localeVariant as any}
>
{children}
</ConfigProvider>
);
Expand Down
8 changes: 2 additions & 6 deletions apps/web-embed/pages/PageWebEmbedPrimePurchase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@ import purchasesSdk from '@onekeyhq/kit/src/views/Prime/purchasesSdk/purchasesSd
import errorToastUtils from '@onekeyhq/shared/src/errors/utils/errorToastUtils';

import type { Package } from '@revenuecat/purchases-js';
import webEmbedAppSettings from '../utils/webEmbedAppSettings';

export default function PageWebEmbedPrimePurchase() {
const [packages, setPackages] = useState<Package[]>([]);
const [selectedPackageId, setSelectedPackageId] = useState<string | null>(
null,
);

// 使用 useSearchParams 获取查询参数
const [searchParams] = useSearchParams();
const primeUserId = searchParams.get('primeUserId') || '';
const primeUserEmail = searchParams.get('primeUserEmail') || '';

// @ts-ignore
const settings = window.WEB_EMBED_ONEKEY_APP_SETTINGS as {
themeVariant: string;
localeVariant: string;
};
const settings = webEmbedAppSettings.getSettings();
return (
<Stack p="$4">
<PrimeSubscriptionPlans
Expand Down
15 changes: 15 additions & 0 deletions apps/web-embed/utils/webEmbedAppSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type IWebEmbedOnekeyAppSettings = {
themeVariant: string;
localeVariant: string;
};

function getSettings(): IWebEmbedOnekeyAppSettings {
const settings =
// @ts-ignore
globalThis.WEB_EMBED_ONEKEY_APP_SETTINGS as IWebEmbedOnekeyAppSettings;
return settings;
}

export default {
getSettings,
};

0 comments on commit 358a2a3

Please sign in to comment.