mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 09:41:57 +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
|
||||
: T;
|
||||
|
||||
export interface ComponentMap {
|
||||
componentName: string;
|
||||
package: string;
|
||||
version?: string;
|
||||
destructuring?: boolean;
|
||||
exportName?: string;
|
||||
subName?: string;
|
||||
}
|
||||
export interface ComponentMap {
|
||||
componentName: string;
|
||||
package: string;
|
||||
version?: string;
|
||||
destructuring?: boolean;
|
||||
exportName?: string;
|
||||
subName?: string;
|
||||
}
|
||||
|
||||
export class DocumentModel {
|
||||
/**
|
||||
@ -148,7 +148,12 @@ export class DocumentModel {
|
||||
* 生成唯一id
|
||||
*/
|
||||
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) {
|
||||
const { componentName, id, children, props, ...extras } = nodeSchema;
|
||||
this.id = id || `node_${document.nextId()}`;
|
||||
this.id = id || document.nextId();
|
||||
this.componentName = componentName;
|
||||
if (this.componentName === 'Leaf') {
|
||||
this.props = new Props(this, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user