Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(GISDK): SDK 支持传入额外的 props #591

Merged
merged 4 commits into from
Jul 30, 2024
Merged

perf(GISDK): SDK 支持传入额外的 props #591

merged 4 commits into from
Jul 30, 2024

Conversation

echoOikawa
Copy link
Collaborator

@echoOikawa echoOikawa commented Jul 22, 2024

🎨 Enhance

  • [x ] Improve the performance

📝 Description

支持 GISDK 传入额外的 props
额外props 格式约定为:

interface GISDKProps {
 / ** 全局额外参数 */
  GISDKExtraParams?: Record<string, any>;
  /** 资产额外参数,以资产ID为 key, value 为传入对应资产的 props */
  componentExtraParams?: Record<string, any>;
}

比如:

const GISDKExtraParams = {
     GI_AKG_AGENT_CONTEXT: {
         id: 7,
         agentCode: 'e690b81f43'
      }
};

const componentExtraParams = {
// 传给 ToolBar 组件的 props
    Toolbar: {
      test: 123,
      test2: 'abc'
    }
}

使用在对应的资产中进行读取:

 const context = useContext();
 const { direction, components, assets, placement, offset, ...extraProps ...extraProps } = props;

  console.log({
   // 从 context 中读取存入全局的 extraParams
    contextExtraProps: context.extraParams,
   // 读取传给对应资产的 额外 props
    componentExtraProps: extraProps
  });

验证
image

🔍 Self-Check before the merge

  • Add or update relevant TypeScript definitions.

@echoOikawa echoOikawa requested a review from Aarebecca July 22, 2024 11:47
@echoOikawa echoOikawa force-pushed the feat_gisdk branch 2 times, most recently from 235bc70 to 6ae90c9 Compare July 30, 2024 08:37
.github/workflows/auto-release.yml Outdated Show resolved Hide resolved
packages/gi-sdk-app/src/index.tsx Outdated Show resolved Hide resolved
@echoOikawa echoOikawa merged commit 39c427b into master Jul 30, 2024
3 checks passed
@echoOikawa echoOikawa deleted the feat_gisdk branch July 30, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants