From 5558c6fe71c3ad5005c2364c1bd1bc292bc6aa2e Mon Sep 17 00:00:00 2001 From: xuyanfeng Date: Tue, 15 Jun 2021 22:19:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Darray?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/src/devtools/data.ts | 7 + source/src/devtools/inject.ts | 9 +- source/src/devtools/ui-prop.vue | 355 ++++++++++++++++++-------------- 3 files changed, 221 insertions(+), 150 deletions(-) diff --git a/source/src/devtools/data.ts b/source/src/devtools/data.ts index 5b98168..3c3c897 100644 --- a/source/src/devtools/data.ts +++ b/source/src/devtools/data.ts @@ -28,10 +28,17 @@ export class TextData extends Info { } export class ArrayData extends Info { + data: Array = []; + constructor() { super(); this.type = DataType.Array; } + + add(info: Property) { + this.data.push(info); + return this; + } } export class ObjectData extends Info { diff --git a/source/src/devtools/inject.ts b/source/src/devtools/inject.ts index c1ddf94..d9c7861 100644 --- a/source/src/devtools/inject.ts +++ b/source/src/devtools/inject.ts @@ -255,7 +255,7 @@ class CCInspector { return null; } - _genInfoData(node: any, key: string, path: any) { + _genInfoData(node: any, key: string, path: Array) { let propertyValue = node[key]; let info = null; switch (typeof propertyValue) { @@ -277,6 +277,13 @@ class CCInspector { info = new ColorData(`#${hex}`); } else if (Array.isArray(propertyValue)) { info = new ArrayData(); + for (let i = 0; i < propertyValue.length; i++) { + let propPath = path.concat(i.toString()); + let itemData = this._genInfoData(propertyValue, i.toString(), propPath); + if (itemData) { + info.add(new Property(i.toString(), itemData)); + } + } } else if (propertyValue instanceof Object) { !info && (info = this._buildVecData({ // @ts-ignore diff --git a/source/src/devtools/ui-prop.vue b/source/src/devtools/ui-prop.vue index 20ee5fb..6741737 100644 --- a/source/src/devtools/ui-prop.vue +++ b/source/src/devtools/ui-prop.vue @@ -1,80 +1,102 @@