diff --git a/packages/editor/src/components/WarningArea/ErrorLogs.tsx b/packages/editor/src/components/WarningArea/ErrorLogs.tsx index ec084a2de..5f1afc51e 100644 --- a/packages/editor/src/components/WarningArea/ErrorLogs.tsx +++ b/packages/editor/src/components/WarningArea/ErrorLogs.tsx @@ -4,7 +4,7 @@ import { DebugTable } from './Table'; import { Box } from '@chakra-ui/react'; export const ErrorLogs: React.FC = ({ services }) => { - const { validateResult, setSelectedComponentId } = services.editorStore; + const { setSelectedComponentId } = services.editorStore; const errorColumns = [ { title: 'Component Id', @@ -37,7 +37,7 @@ export const ErrorLogs: React.FC = ({ services }) => { return ( = observer(({ services }) => { > - - - Errors - - - {editorStore.validateResult.length} - - Logs {editorStore.isSaved ? savedBadge : unsaveBadge} diff --git a/packages/editor/src/init.tsx b/packages/editor/src/init.tsx index 14508147b..b8456b2d2 100644 --- a/packages/editor/src/init.tsx +++ b/packages/editor/src/init.tsx @@ -92,13 +92,7 @@ export function initSunmaoUIEditor(props: SunmaoUIEditorProps = {}) { appStorage.app.spec.components ); const widgetManager = new WidgetManager(); - const editorStore = new EditorStore( - eventBus, - registry, - stateManager, - appStorage, - appModelManager - ); + const editorStore = new EditorStore(eventBus, registry, stateManager, appStorage); editorStore.eleMap = ui.eleMap; const services = { diff --git a/packages/editor/src/services/EditorStore.ts b/packages/editor/src/services/EditorStore.ts index 07edb296e..64df99ceb 100644 --- a/packages/editor/src/services/EditorStore.ts +++ b/packages/editor/src/services/EditorStore.ts @@ -5,10 +5,8 @@ import { isEqual } from 'lodash'; import { EventBusType } from './eventBus'; import { AppStorage } from './AppStorage'; -import type { SchemaValidator, ValidateErrorResult } from '../validator'; import { ExplorerMenuTabs, ToolMenuTabs } from '../constants/enum'; -import { AppModelManager } from '../operations/AppModelManager'; import type { Metadata } from '@sunmao-ui/core'; type EditingTarget = { @@ -29,7 +27,6 @@ export class EditorStore { explorerMenuTab = ExplorerMenuTabs.UI_TREE; toolMenuTab = ToolMenuTabs.INSERT; viewStateComponentId = ''; - validateResult: ValidateErrorResult[] = []; // current editor editing target(app or module) currentEditingTarget: EditingTarget = { kind: 'app', @@ -45,7 +42,6 @@ export class EditorStore { // when componentsChange event is triggered, currentComponentsVersion++ currentComponentsVersion = 0; lastSavedComponentsVersion = 0; - schemaValidator?: SchemaValidator; private isDataSourceTypeCache: Record = {}; @@ -53,23 +49,12 @@ export class EditorStore { private eventBus: EventBusType, private registry: RegistryInterface, private stateManager: StateManagerInterface, - public appStorage: AppStorage, - private appModelManager: AppModelManager + public appStorage: AppStorage ) { this.globalDependencies = this.stateManager.dependencies; - const dependencyNames = Object.keys(this.globalDependencies); - // dynamic load validator - import('../validator').then(({ SchemaValidator: SchemaValidatorClass }) => { - this.setSchemaValidator(new SchemaValidatorClass(this.registry, dependencyNames)); - // do first validation - this.setValidateResult( - this.schemaValidator!.validate(this.appModelManager.appModel) - ); - }); makeAutoObservable(this, { eleMap: false, components: observable.shallow, - schemaValidator: observable.ref, setComponents: action, setHoverComponentId: action, setDragOverComponentId: action, @@ -133,17 +118,6 @@ export class EditorStore { } ); - reaction( - () => this.components, - () => { - if (this.schemaValidator) { - this.setValidateResult( - this.schemaValidator.validate(this.appModelManager.appModel) - ); - } - } - ); - this.updateCurrentEditingTarget('app', this.app.version, this.app.metadata.name); } @@ -287,10 +261,6 @@ export class EditorStore { this.lastSavedComponentsVersion = val; }; - setValidateResult = (validateResult: ValidateErrorResult[]) => { - this.validateResult = validateResult; - }; - setExplorerMenuTab = (val: ExplorerMenuTabs) => { this.explorerMenuTab = val; }; @@ -307,10 +277,6 @@ export class EditorStore { this.isDraggingNewComponent = val; }; - setSchemaValidator = (val: SchemaValidator) => { - this.schemaValidator = val; - }; - setModuleDependencies = (exampleProperties?: Record) => { const evaledDependencies = this.stateManager.deepEval(exampleProperties || {}, { fallbackWhenError: () => undefined,