Skip to content

Commit 9cb20eb

Browse files
author
taojiu
committed
refactor(editor-skeleton): 优化内容配置处理逻辑
- 修改了 PanelDock 配置的判断条件 - 增加了对内容配置是数组情况的处理 - 优化了对象配置的处理逻辑,对 props 进行了特殊处理 - 为 DialogDock 添加了 TODO 注释
1 parent 1965c67 commit 9cb20eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/editor-skeleton/src/skeleton.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export class Skeleton implements ISkeleton {
386386
if (isPanelDockConfig(config)) {
387387
widget = new PanelDock(this, config);
388388
} else if (false) {
389-
// DialogDock
389+
// TODO DialogDock
390390
// others...
391391
} else {
392392
widget = new Dock(this, config);
@@ -458,7 +458,8 @@ export class Skeleton implements ISkeleton {
458458
}
459459
const { content, ...restConfig } = config;
460460
if (content) {
461-
if (isPlainObject(content) && (isReactComponent(content) || !isValidElement(content))) {
461+
// 对象配置进行拆分
462+
if (isPlainObject(content) && !isReactComponent(content) && !isValidElement(content)) {
462463
Object.keys(content).forEach((key: any) => {
463464
if (/props$/i.test(key) && restConfig[key]) {
464465
restConfig[key] = {
@@ -469,6 +470,9 @@ export class Skeleton implements ISkeleton {
469470
restConfig[key] = (content as unknown as IPublicTypePanelConfig)[key];
470471
}
471472
});
473+
} else if (Array.isArray(content)) {
474+
// 数组配置
475+
restConfig.content = content;
472476
} else {
473477
restConfig.content = content;
474478
}

0 commit comments

Comments
 (0)