feat: add warning message when adding duplicate skeleton

This commit is contained in:
liujuping 2022-12-30 17:35:12 +08:00 committed by 林熠
parent bc5ec03884
commit e415ff6782
2 changed files with 6 additions and 2 deletions

View File

@ -1,9 +1,12 @@
/* eslint-disable max-len */
import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core';
import { Logger } from '@alilc/lowcode-utils';
import { IPublicTypeWidgetBaseConfig, IArea } from '@alilc/lowcode-types';
import { WidgetContainer } from './widget/widget-container';
import { Skeleton } from './skeleton';
import { IWidget } from './widget/widget';
import { IPublicTypeWidgetBaseConfig, IArea } from '@alilc/lowcode-types';
const logger = new Logger({ level: 'warn', bizName: 'skeleton:area' });
export class Area<C extends IPublicTypeWidgetBaseConfig = any, T extends IWidget = IWidget> implements IArea<C, T> {
@obx private _visible = true;
@ -36,6 +39,7 @@ export class Area<C extends IPublicTypeWidgetBaseConfig = any, T extends IWidget
add(config: T | C): T {
const item = this.container.get(config.name);
if (item) {
logger.warn(`The ${config.name} has already been added to skeleton.`);
return item;
}
return this.container.add(config);

View File

@ -11,7 +11,7 @@ export class Skeleton implements IPublicApiSkeleton {
private readonly [innerSkeletonSymbol]: InnerSkeleton;
private readonly pluginName: string;
get [skeletonSymbol]() {
get [skeletonSymbol](): InnerSkeleton {
if (this.workspaceMode) {
return this[innerSkeletonSymbol];
}