From 06ade4868b16c2b89663095394ad4766b26832e3 Mon Sep 17 00:00:00 2001 From: mutu Date: Fri, 2 Aug 2024 11:46:08 +0800 Subject: [PATCH] fix: gisdk keep render --- packages/gi-sdk-app/src/index.tsx | 12 ++++++------ packages/gi-sdk/src/GISDK.tsx | 8 ++++---- packages/gi-sdk/src/typing.ts | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/gi-sdk-app/src/index.tsx b/packages/gi-sdk-app/src/index.tsx index b70dce10a..91e424277 100644 --- a/packages/gi-sdk-app/src/index.tsx +++ b/packages/gi-sdk-app/src/index.tsx @@ -43,7 +43,7 @@ export interface StudioProps { service: (id: string) => Promise<{ data: Project }>; loadingText?: string; loadingComponent?: React.ReactElement; - GISDKExtraParams?: Record; + extraParams?: Record; componentExtraParams?: Record; } @@ -54,8 +54,8 @@ const Studio: React.FunctionComponent = props => { service, loadingText = '正在加载图应用...', loadingComponent, - GISDKExtraParams = {}, - componentExtraParams = {}, + extraParams, + componentExtraParams, } = props; const [state, setState] = React.useState({ isReady: false, @@ -64,8 +64,8 @@ const Studio: React.FunctionComponent = props => { services: [], ThemeComponent: () => null, GISDK: () => <>, - GISDKExtraParams: {}, - componentExtraParams: {}, + extraParams: undefined, + componentExtraParams: undefined, }); const startStudio = async () => { @@ -145,7 +145,7 @@ const Studio: React.FunctionComponent = props => { assets={assets} services={services} id={`GI_STUDIO_${id}`} - GISDKExtraParams={GISDKExtraParams} + extraParams={extraParams} componentExtraParams={componentExtraParams} /> diff --git a/packages/gi-sdk/src/GISDK.tsx b/packages/gi-sdk/src/GISDK.tsx index d2bafa7f8..1bc2f89d1 100644 --- a/packages/gi-sdk/src/GISDK.tsx +++ b/packages/gi-sdk/src/GISDK.tsx @@ -20,7 +20,7 @@ let updateHistoryTimer: number; const GISDK = (props: Props) => { const graphinRef = React.useRef(null); // @ts-ignore - const { children, assets, id, services, config, locales, componentExtraParams = {}, GISDKExtraParams = {} } = props; + const { children, assets, id, services, config, locales, componentExtraParams, extraParams } = props; const { language = 'zh-CN', ...localeMessages } = locales || {}; const GISDK_ID = React.useMemo(() => { if (!id) { @@ -62,7 +62,7 @@ const GISDK = (props: Props) => { }, //@ts-ignore GISDK_ID, - extraParams: {}, + extraParams: undefined, }); React.useEffect(() => { @@ -74,9 +74,9 @@ const GISDK = (props: Props) => { // 更新参数 React.useEffect(() => { updateState(draft => { - draft.extraParams = GISDKExtraParams; + draft.extraParams = extraParams; }); - }, [GISDKExtraParams]); + }, [extraParams]); const { layout: layoutCfg, diff --git a/packages/gi-sdk/src/typing.ts b/packages/gi-sdk/src/typing.ts index 5c8ca5f54..5568b69e1 100644 --- a/packages/gi-sdk/src/typing.ts +++ b/packages/gi-sdk/src/typing.ts @@ -74,7 +74,7 @@ export interface State< /** 是否使用缓存的布局 */ layoutCache: boolean; /** 额外参数 */ - extraParams: Record; + extraParams?: Record; } export interface Props { @@ -105,7 +105,7 @@ export interface Props { className?: string; children?: React.ReactChildren | JSX.Element | JSX.Element[]; /** 全局额外参数 */ - GISDKExtraParams?: Record; + extraParams?: Record; /** 资产额外参数,以资产ID为 key, value 为传入对应资产的 props */ componentExtraParams?: Record; }