mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-18 07:58:40 +00:00
属性排序
This commit is contained in:
parent
3e0dd01b14
commit
807e0c83ef
@ -142,6 +142,24 @@ export class Group {
|
||||
addProperty(property: Property) {
|
||||
this.data.push(property)
|
||||
}
|
||||
|
||||
sort() {
|
||||
let order = ['name', 'uuid', 'position', 'rotation', 'scale', 'anchor', 'size', 'color', 'opacity', 'skew', 'group'];
|
||||
let orderKeys: Array<Property> = [];
|
||||
let otherKeys: Array<Property> = [];
|
||||
this.data.forEach(property => {
|
||||
if (order.find(el => el === property.name)) {
|
||||
orderKeys.push(property)
|
||||
} else {
|
||||
otherKeys.push(property);
|
||||
}
|
||||
})
|
||||
orderKeys.sort((a, b) => {
|
||||
return order.indexOf(a.name) - order.indexOf(b.name);
|
||||
})
|
||||
otherKeys.sort();
|
||||
this.data = orderKeys.concat(otherKeys);
|
||||
}
|
||||
}
|
||||
|
||||
export const testData = [
|
||||
|
@ -176,6 +176,7 @@ class CCInspector {
|
||||
rotation: ["rotationX", "rotationY"],
|
||||
anchor: ["anchorX", "anchorY"],
|
||||
size: ["width", "height"],
|
||||
skew: ['skewX', 'skewY'],
|
||||
position: ["x", "y", "z"],
|
||||
scale: ["scaleX", "scaleY", "scaleZ"],
|
||||
designResolution: ["width", "height"], // 这个比较特殊,在key下边,其他的都不是在key下
|
||||
@ -230,16 +231,18 @@ class CCInspector {
|
||||
_getGroupData(node: any) {
|
||||
let nodeGroup = new Group(node.constructor.name);
|
||||
let keys = this._getNodeKeys(node);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
for (let i = 0; i < keys.length;) {
|
||||
let key = keys[i];
|
||||
let propertyValue = node[key];
|
||||
let pair = this._getPairProperty(key);
|
||||
if (pair) {
|
||||
let bSplice = false;
|
||||
// 把这个成对的属性剔除掉
|
||||
pair.values.forEach((item: string) => {
|
||||
let index = keys.findIndex(el => el === item);
|
||||
if (index !== -1) {
|
||||
keys.splice(index, 1);
|
||||
bSplice = true;
|
||||
}
|
||||
});
|
||||
// 序列化成对的属性
|
||||
@ -265,14 +268,19 @@ class CCInspector {
|
||||
let property = new Property(pair.key, info);
|
||||
nodeGroup.addProperty(property);
|
||||
}
|
||||
if (!bSplice) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
let propertyPath = [node.uuid, key];
|
||||
let info = this._genInfoData(propertyValue, propertyPath);
|
||||
if (info) {
|
||||
nodeGroup.addProperty(new Property(key, info));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
nodeGroup.sort();
|
||||
return nodeGroup;
|
||||
}
|
||||
|
||||
@ -310,6 +318,7 @@ class CCInspector {
|
||||
let nodeOrComp = this.inspectorGameMemoryStorage[uuid];
|
||||
if (nodeOrComp && key in nodeOrComp) {
|
||||
debugger
|
||||
|
||||
function circleFind(base: Object): boolean {
|
||||
let obj = Object.getPrototypeOf(base);
|
||||
let ret = Object.getOwnPropertyDescriptor(obj, key)
|
||||
|
Loading…
x
Reference in New Issue
Block a user