Skip to content

Commit

Permalink
fix: gisdk keep render
Browse files Browse the repository at this point in the history
  • Loading branch information
mutu committed Aug 2, 2024
1 parent 39c427b commit 06ade48
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions packages/gi-sdk-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface StudioProps {
service: (id: string) => Promise<{ data: Project }>;
loadingText?: string;
loadingComponent?: React.ReactElement;
GISDKExtraParams?: Record<string, any>;
extraParams?: Record<string, any>;
componentExtraParams?: Record<string, any>;
}

Expand All @@ -54,8 +54,8 @@ const Studio: React.FunctionComponent<StudioProps> = props => {
service,
loadingText = '正在加载图应用...',
loadingComponent,
GISDKExtraParams = {},
componentExtraParams = {},
extraParams,
componentExtraParams,
} = props;
const [state, setState] = React.useState({
isReady: false,
Expand All @@ -64,8 +64,8 @@ const Studio: React.FunctionComponent<StudioProps> = props => {
services: [],
ThemeComponent: () => null,
GISDK: () => <></>,
GISDKExtraParams: {},
componentExtraParams: {},
extraParams: undefined,
componentExtraParams: undefined,
});

const startStudio = async () => {
Expand Down Expand Up @@ -145,7 +145,7 @@ const Studio: React.FunctionComponent<StudioProps> = props => {
assets={assets}
services={services}
id={`GI_STUDIO_${id}`}
GISDKExtraParams={GISDKExtraParams}
extraParams={extraParams}
componentExtraParams={componentExtraParams}
/>
</>
Expand Down
8 changes: 4 additions & 4 deletions packages/gi-sdk/src/GISDK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let updateHistoryTimer: number;
const GISDK = (props: Props) => {
const graphinRef = React.useRef<null | Graphin>(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) {
Expand Down Expand Up @@ -62,7 +62,7 @@ const GISDK = (props: Props) => {
},
//@ts-ignore
GISDK_ID,
extraParams: {},
extraParams: undefined,
});

React.useEffect(() => {
Expand All @@ -74,9 +74,9 @@ const GISDK = (props: Props) => {
// 更新参数
React.useEffect(() => {
updateState(draft => {
draft.extraParams = GISDKExtraParams;
draft.extraParams = extraParams;
});
}, [GISDKExtraParams]);
}, [extraParams]);

const {
layout: layoutCfg,
Expand Down
4 changes: 2 additions & 2 deletions packages/gi-sdk/src/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface State<
/** 是否使用缓存的布局 */
layoutCache: boolean;
/** 额外参数 */
extraParams: Record<string, any>;
extraParams?: Record<string, any>;
}

export interface Props {
Expand Down Expand Up @@ -105,7 +105,7 @@ export interface Props {
className?: string;
children?: React.ReactChildren | JSX.Element | JSX.Element[];
/** 全局额外参数 */
GISDKExtraParams?: Record<string, any>;
extraParams?: Record<string, any>;
/** 资产额外参数,以资产ID为 key, value 为传入对应资产的 props */
componentExtraParams?: Record<string, any>;
}
Expand Down

0 comments on commit 06ade48

Please sign in to comment.