UUID升级异常修复
This commit is contained in:
@@ -46,6 +46,15 @@ const setSelectRow = (row) => {
|
|||||||
showDetail.value = true;
|
showDetail.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function generateUUID() {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||||
|
const r = Math.random() * 16 | 0;
|
||||||
|
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||||
|
return v.toString(16);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const renameComponentsToChildren = (obj) => {
|
const renameComponentsToChildren = (obj) => {
|
||||||
// 如果传入的不是对象,直接返回
|
// 如果传入的不是对象,直接返回
|
||||||
if (typeof obj !== 'object' || obj === null) {
|
if (typeof obj !== 'object' || obj === null) {
|
||||||
@@ -55,7 +64,7 @@ const renameComponentsToChildren = (obj) => {
|
|||||||
// 如果对象有 `components` 属性,将其改为 `children`
|
// 如果对象有 `components` 属性,将其改为 `children`
|
||||||
if (obj.hasOwnProperty('component')) {
|
if (obj.hasOwnProperty('component')) {
|
||||||
// 生成随机 UUID 并赋值给 id
|
// 生成随机 UUID 并赋值给 id
|
||||||
obj.id = crypto.randomUUID(); // 使用浏览器/Node.js 原生 API
|
obj.id = generateUUID(); // 使用浏览器/Node.js 原生 API
|
||||||
// obj.id = obj.component.id; // 将 components 改为 children
|
// obj.id = obj.component.id; // 将 components 改为 children
|
||||||
obj.libraryName = obj.component.libraryName; // 将 components 改为 children
|
obj.libraryName = obj.component.libraryName; // 将 components 改为 children
|
||||||
obj.latestVersion = obj.component.latestVersion; // 将 components 改为 children
|
obj.latestVersion = obj.component.latestVersion; // 将 components 改为 children
|
||||||
|
|||||||
Reference in New Issue
Block a user