Skip to content

Commit 5db418e

Browse files
liujupingJackLian
authored andcommitted
fix: when the component is configured in a loop, the key value changes and renders error
1 parent 29b9184 commit 5db418e

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

packages/renderer-core/src/renderer/base.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,11 @@ export default function baseRendererFactory(): IBaseRenderComponent {
774774
{
775775
...schema,
776776
loop: undefined,
777+
props: {
778+
...schema.props,
779+
// 循环下 key 不能为常量,这样会造成 key 值重复,渲染异常
780+
key: isJSExpression(schema.props?.key) ? schema.props?.key : null,
781+
},
777782
},
778783
loopSelf,
779784
parentInfo,

packages/types/src/shell/api/plugins.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export interface IPluginPreferenceMananger {
1313
export type PluginOptionsType = string | number | boolean | object;
1414

1515
export interface IPublicApiPlugins {
16+
/**
17+
* 可以通过 plugin api 获取其他插件 export 导出的内容
18+
*/
19+
[key: string]: any;
20+
1621
register(
1722
pluginModel: IPublicTypePlugin,
1823
options?: Record<string, PluginOptionsType>,
@@ -21,6 +26,7 @@ export interface IPublicApiPlugins {
2126

2227
/**
2328
* 引擎初始化时可以提供全局配置给到各插件,通过这个方法可以获得本插件对应的配置
29+
*
2430
* use this to get preference config for this plugin when engine.init() called
2531
*/
2632
getPluginPreference(
@@ -29,24 +35,28 @@ export interface IPublicApiPlugins {
2935

3036
/**
3137
* 获取指定插件
38+
*
3239
* get plugin instance by name
3340
*/
3441
get(pluginName: string): IPublicModelPluginInstance | null;
3542

3643
/**
3744
* 获取所有的插件实例
45+
*
3846
* get all plugin instances
3947
*/
4048
getAll(): IPublicModelPluginInstance[];
4149

4250
/**
4351
* 判断是否有指定插件
52+
*
4453
* check if plugin with certain name exists
4554
*/
4655
has(pluginName: string): boolean;
4756

4857
/**
4958
* 删除指定插件
59+
*
5060
* delete plugin instance by name
5161
*/
5262
delete(pluginName: string): void;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { IPublicTypeCompositeObject } from './';
1+
import { IPublicTypeCompositeObject, IPublicTypeNodeData } from './';
22

3-
export type IPublicTypePropsMap = IPublicTypeCompositeObject;
3+
export type IPublicTypePropsMap = IPublicTypeCompositeObject<IPublicTypeNodeData | IPublicTypeNodeData[]>;

packages/types/src/shell/type/value-type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ export interface IPublicTypeJSONObject {
131131
}
132132

133133
export type IPublicTypeCompositeArray = IPublicTypeCompositeValue[];
134-
export interface IPublicTypeCompositeObject {
135-
[key: string]: IPublicTypeCompositeValue;
134+
export interface IPublicTypeCompositeObject<T = IPublicTypeCompositeValue> {
135+
[key: string]: IPublicTypeCompositeValue | T;
136136
}

0 commit comments

Comments
 (0)