mirror of
https://github.com/sahadev/vue-component-creater-ui.git
synced 2025-12-18 16:34:17 +08:00
feat: 支持单文件二次编辑
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import isEqual from "lodash/isEqual";
|
||||
import cryptoRandomString from "crypto-random-string";
|
||||
|
||||
export function getRawComponentKey(__rawVueInfo__) {
|
||||
return Object.keys(__rawVueInfo__)[0];
|
||||
@@ -21,4 +22,35 @@ export function isArray(arr) {
|
||||
|
||||
export function isObject(obj) {
|
||||
return Object.prototype.toString.apply(obj) === "[object Object]";
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历对象,添加ID
|
||||
* @param {*} jsonObj
|
||||
*/
|
||||
export function ergodic(jsonObj) {
|
||||
if (jsonObj) {
|
||||
for (const key in jsonObj) {
|
||||
if (jsonObj.hasOwnProperty(key)) {
|
||||
const element = jsonObj[key];
|
||||
|
||||
if (isArray(element)) {
|
||||
element.forEach((item) => {
|
||||
if (isObject(item)) {
|
||||
ergodic(item);
|
||||
delete item.lc_id;
|
||||
}
|
||||
});
|
||||
} else if (isObject(element)) {
|
||||
ergodic(element);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加ID
|
||||
if (!jsonObj["lc_id"]) {
|
||||
jsonObj["lc_id"] = cryptoRandomString({ length: 10, type: "base64" });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user