Skip to content

Commit

Permalink
fix: layout config
Browse files Browse the repository at this point in the history
  • Loading branch information
pomelo-nwu committed Oct 10, 2023
1 parent 4c5cdf2 commit 15e4937
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions packages/gi-sdk/src/GISDK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,30 @@ const GISDK = (props: Props) => {
};

console.log('%c GISDK RENDER....', 'color:rgba(255,87,34,1)', HAS_GRAPH, state.initialized, state);

const layout = useMemo(() => {
return deepClone(layoutCfg.props);
}, [layoutCfg]);

const { renderComponents, InitializerComponent, InitializerProps, GICC_LAYOUT_COMPONENT, GICC_LAYOUT_PROPS } =
getComponents({
config: { pageLayout, components: ComponentCfg },
initializer: INITIALIZER,
GICC_LAYOUT,
components: ComponentCfg,
GISDK_ID,
propsComponentsCfg: ComponentCfg,
ComponentAssets,
});

/** 节点样式映射 */
const nodeMapper = useMemo(() => getMapperByCfg(nodesCfg, ElementAssets), [nodesCfg]);
/** 边样式映射 */
const edgeMapper = useMemo(() => getMapperByCfg(edgesCfg, ElementAssets), [edgesCfg]);

const ContextValue = {
...state,
layout,
GISDK_ID,
services,
assets,
Expand Down Expand Up @@ -218,26 +240,6 @@ const GISDK = (props: Props) => {
language,
};

const layout2 = useMemo(() => {
return deepClone(layoutCfg.props);
}, [layoutCfg]);

const { renderComponents, InitializerComponent, InitializerProps, GICC_LAYOUT_COMPONENT, GICC_LAYOUT_PROPS } =
getComponents({
config: { pageLayout, components: ComponentCfg },
initializer: INITIALIZER,
GICC_LAYOUT,
components: ComponentCfg,
GISDK_ID,
propsComponentsCfg: ComponentCfg,
ComponentAssets,
});

/** 节点样式映射 */
const nodeMapper = useMemo(() => getMapperByCfg(nodesCfg, ElementAssets), [nodesCfg]);
/** 边样式映射 */
const edgeMapper = useMemo(() => getMapperByCfg(edgesCfg, ElementAssets), [edgesCfg]);

return (
<div id={`${GISDK_ID}-container`} style={{ width: '100%', height: '100%', position: 'relative', ...props.style }}>
{/* @ts-ignore */}
Expand All @@ -253,7 +255,7 @@ const GISDK = (props: Props) => {
edge={edgeMapper}
data={data}
//@ts-ignore
layout={layout2}
layout={layout}
onInit={handleGraphInit}
/>
{HAS_GRAPH && <InitializerComponent {...InitializerProps} />}
Expand Down

0 comments on commit 15e4937

Please sign in to comment.