mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-20 07:14:23 +00:00
fix: nextId() 逻辑调整
This commit is contained in:
parent
ffaa15fc6b
commit
488a5d8283
@ -20,14 +20,14 @@ export type GetDataType<T, NodeType> = T extends undefined
|
|||||||
: any
|
: any
|
||||||
: T;
|
: T;
|
||||||
|
|
||||||
export interface ComponentMap {
|
export interface ComponentMap {
|
||||||
componentName: string;
|
componentName: string;
|
||||||
package: string;
|
package: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
destructuring?: boolean;
|
destructuring?: boolean;
|
||||||
exportName?: string;
|
exportName?: string;
|
||||||
subName?: string;
|
subName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DocumentModel {
|
export class DocumentModel {
|
||||||
/**
|
/**
|
||||||
@ -148,7 +148,12 @@ export class DocumentModel {
|
|||||||
* 生成唯一id
|
* 生成唯一id
|
||||||
*/
|
*/
|
||||||
nextId() {
|
nextId() {
|
||||||
return (this.id.slice(-10) + (++this.seqId).toString(36)).toLocaleLowerCase();
|
let id;
|
||||||
|
do {
|
||||||
|
id = 'node_' + (this.id.slice(-10) + (++this.seqId).toString(36)).toLocaleLowerCase();
|
||||||
|
} while (this.nodesMap.get(id))
|
||||||
|
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -148,7 +148,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
|
|
||||||
constructor(readonly document: DocumentModel, nodeSchema: Schema) {
|
constructor(readonly document: DocumentModel, nodeSchema: Schema) {
|
||||||
const { componentName, id, children, props, ...extras } = nodeSchema;
|
const { componentName, id, children, props, ...extras } = nodeSchema;
|
||||||
this.id = id || `node_${document.nextId()}`;
|
this.id = id || document.nextId();
|
||||||
this.componentName = componentName;
|
this.componentName = componentName;
|
||||||
if (this.componentName === 'Leaf') {
|
if (this.componentName === 'Leaf') {
|
||||||
this.props = new Props(this, {
|
this.props = new Props(this, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user