mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-15 17:43:43 +08:00
parent
259a5aa530
commit
a02fd2c695
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import { reactive } from 'vue';
|
||||
import { cloneDeep, mergeWith, random } from 'lodash-es';
|
||||
import { cloneDeep, mergeWith } from 'lodash-es';
|
||||
|
||||
import type { FormConfig } from '@tmagic/form';
|
||||
import type { Id, MComponent, MNode, MPage } from '@tmagic/schema';
|
||||
@ -121,12 +121,25 @@ class Props extends BaseService {
|
||||
return {
|
||||
id,
|
||||
...defaultPropsValue,
|
||||
...mergeWith(cloneDeep(this.state.propsValueMap[type] || {}), data),
|
||||
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成指定位数的GUID,无【-】格式
|
||||
* @param digit 位数,默认值8
|
||||
* @returns
|
||||
*/
|
||||
guid(digit = 8): string {
|
||||
return 'x'.repeat(digit).replace(/[xy]/g, (c) => {
|
||||
const r = (Math.random() * 16) | 0;
|
||||
const v = c == 'x' ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
public async createId(type: string | number): Promise<string> {
|
||||
return `${type}_${random(10000, false)}`;
|
||||
return `${type}_${this.guid()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user