mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
fix(editor): make the created module's name is different
This commit is contained in:
parent
f5aa1460ba
commit
02d1a407dd
@ -1,5 +1,5 @@
|
||||
import { observable, makeObservable, action, toJS } from 'mobx';
|
||||
import { Application, ComponentSchema, Module } from '@sunmao-ui/core';
|
||||
import { Application, ComponentSchema, Module, RuntimeModule } from '@sunmao-ui/core';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { produce } from 'immer';
|
||||
import { DefaultNewModule, EmptyAppSchema } from '../constants';
|
||||
@ -29,7 +29,28 @@ export class AppStorage {
|
||||
}
|
||||
|
||||
createModule() {
|
||||
this.setModules([...this.modules, DefaultNewModule]);
|
||||
let index = this.modules.length;
|
||||
|
||||
this.modules.forEach((module) => {
|
||||
if (module.metadata.name === `myModule${index}`) {
|
||||
index++;
|
||||
}
|
||||
});
|
||||
|
||||
const name = `myModule${index}`;
|
||||
const newModule: RuntimeModule = {
|
||||
...DefaultNewModule,
|
||||
parsedVersion: {
|
||||
...DefaultNewModule.parsedVersion,
|
||||
value: name,
|
||||
},
|
||||
metadata: {
|
||||
...DefaultNewModule.metadata,
|
||||
name,
|
||||
}
|
||||
};
|
||||
|
||||
this.setModules([...this.modules, newModule]);
|
||||
this.saveModules();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user