From 5db418efe41f8421a644d54926db6ce8d2164eed Mon Sep 17 00:00:00 2001 From: liujuping Date: Fri, 3 Mar 2023 17:08:04 +0800 Subject: [PATCH] fix: when the component is configured in a loop, the key value changes and renders error --- packages/renderer-core/src/renderer/base.tsx | 5 +++++ packages/types/src/shell/api/plugins.ts | 10 ++++++++++ packages/types/src/shell/type/props-map.ts | 4 ++-- packages/types/src/shell/type/value-type.ts | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/renderer-core/src/renderer/base.tsx b/packages/renderer-core/src/renderer/base.tsx index 311493736..a96554908 100644 --- a/packages/renderer-core/src/renderer/base.tsx +++ b/packages/renderer-core/src/renderer/base.tsx @@ -774,6 +774,11 @@ export default function baseRendererFactory(): IBaseRenderComponent { { ...schema, loop: undefined, + props: { + ...schema.props, + // 循环下 key 不能为常量,这样会造成 key 值重复,渲染异常 + key: isJSExpression(schema.props?.key) ? schema.props?.key : null, + }, }, loopSelf, parentInfo, diff --git a/packages/types/src/shell/api/plugins.ts b/packages/types/src/shell/api/plugins.ts index 518362b97..a93016290 100644 --- a/packages/types/src/shell/api/plugins.ts +++ b/packages/types/src/shell/api/plugins.ts @@ -13,6 +13,11 @@ export interface IPluginPreferenceMananger { export type PluginOptionsType = string | number | boolean | object; export interface IPublicApiPlugins { + /** + * 可以通过 plugin api 获取其他插件 export 导出的内容 + */ + [key: string]: any; + register( pluginModel: IPublicTypePlugin, options?: Record, @@ -21,6 +26,7 @@ export interface IPublicApiPlugins { /** * 引擎初始化时可以提供全局配置给到各插件,通过这个方法可以获得本插件对应的配置 + * * use this to get preference config for this plugin when engine.init() called */ getPluginPreference( @@ -29,24 +35,28 @@ export interface IPublicApiPlugins { /** * 获取指定插件 + * * get plugin instance by name */ get(pluginName: string): IPublicModelPluginInstance | null; /** * 获取所有的插件实例 + * * get all plugin instances */ getAll(): IPublicModelPluginInstance[]; /** * 判断是否有指定插件 + * * check if plugin with certain name exists */ has(pluginName: string): boolean; /** * 删除指定插件 + * * delete plugin instance by name */ delete(pluginName: string): void; diff --git a/packages/types/src/shell/type/props-map.ts b/packages/types/src/shell/type/props-map.ts index e43095757..1b93f4625 100644 --- a/packages/types/src/shell/type/props-map.ts +++ b/packages/types/src/shell/type/props-map.ts @@ -1,3 +1,3 @@ -import { IPublicTypeCompositeObject } from './'; +import { IPublicTypeCompositeObject, IPublicTypeNodeData } from './'; -export type IPublicTypePropsMap = IPublicTypeCompositeObject; +export type IPublicTypePropsMap = IPublicTypeCompositeObject; diff --git a/packages/types/src/shell/type/value-type.ts b/packages/types/src/shell/type/value-type.ts index c0c012544..16fb789a2 100644 --- a/packages/types/src/shell/type/value-type.ts +++ b/packages/types/src/shell/type/value-type.ts @@ -131,6 +131,6 @@ export interface IPublicTypeJSONObject { } export type IPublicTypeCompositeArray = IPublicTypeCompositeValue[]; -export interface IPublicTypeCompositeObject { - [key: string]: IPublicTypeCompositeValue; +export interface IPublicTypeCompositeObject { + [key: string]: IPublicTypeCompositeValue | T; } \ No newline at end of file