diff --git a/source/package.json b/source/package.json
index 8590431..65ab458 100644
--- a/source/package.json
+++ b/source/package.json
@@ -9,20 +9,21 @@
"build-watch": "vue-cli-service build --watch"
},
"dependencies": {
- "@types/fs-extra": "^9.0.9",
- "@types/node": "^14.14.37",
+ "@types/kind-of": "^6.0.0",
"babel-eslint": "^10.1.0",
"core-js": "^3.6.5",
- "uuid": "^8.3.2",
"element-ui": "^2.15.1",
"fs-extra": "^9.1.0",
"less": "^4.1.1",
"less-loader": "^7.3.0",
+ "uuid": "^8.3.2",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2"
},
"devDependencies": {
+ "@types/fs-extra": "^9.0.9",
+ "@types/node": "^14.14.37",
"@types/uuid": "^8.3.1",
"@types/chrome": "0.0.133",
"@typescript-eslint/eslint-plugin": "^4.18.0",
diff --git a/source/src/devtools/data.ts b/source/src/devtools/data.ts
index e169391..890c04f 100644
--- a/source/src/devtools/data.ts
+++ b/source/src/devtools/data.ts
@@ -79,7 +79,7 @@ export class ObjectData extends Info {
}
export class InvalidData extends Info {
- data: any;
+ data: "undefined" | "null" | "Infinity" | "NaN"|string;
constructor(data: any) {
super();
diff --git a/source/src/devtools/ui/index.vue b/source/src/devtools/ui/index.vue
index d041f3a..6ead9b4 100644
--- a/source/src/devtools/ui/index.vue
+++ b/source/src/devtools/ui/index.vue
@@ -98,7 +98,7 @@ export default class Index extends Vue {
this._expand(data.engineUUID);
})
Bus.$on(BusMsg.RequestObjectData, (data: ObjectData, cb: Function) => {
- if (this.requestList.find(el => el.id === data.id)) {
+ if (!data.id || this.requestList.find(el => el.id === data.id)) {
return
}
this.requestList.push({id: data.id, cb});
diff --git a/source/src/devtools/ui/ui-prop.vue b/source/src/devtools/ui/ui-prop.vue
index 8fe83f9..3652145 100644
--- a/source/src/devtools/ui/ui-prop.vue
+++ b/source/src/devtools/ui/ui-prop.vue
@@ -20,7 +20,7 @@
- {{ getInvalidDisplayText() }}
+ {{ value.data }}
el.offsetWidth) {
// 出现了省略号
diff --git a/source/src/inject/index.ts b/source/src/inject/index.ts
index 455ed1c..73bce7f 100644
--- a/source/src/inject/index.ts
+++ b/source/src/inject/index.ts
@@ -271,78 +271,81 @@ class CCInspector {
_genInfoData(node: any, key: string | number, path: Array, filterKey = true) {
let propertyValue = node[key];
let info = null;
- switch (typeof propertyValue) {
- case "boolean":
- info = new BoolData(propertyValue);
- break;
- case "number":
- info = new NumberData(propertyValue);
- break;
- case "string":
- info = new StringData(propertyValue);
- break;
- default:
- if (this._isInvalidValue(propertyValue)) {
- info = new InvalidData(propertyValue);
+ let invalidType = this._isInvalidValue(propertyValue);
+ if (invalidType) {
+ info = new InvalidData(invalidType);
+ } else {
+ switch (typeof propertyValue) {
+ case "boolean":
+ info = new BoolData(propertyValue);
+ break;
+ case "number":
+ info = new NumberData(propertyValue);
+ break;
+ case "string":
+ info = new StringData(propertyValue);
+ break;
+ default:
//@ts-ignore
- } else if (propertyValue instanceof cc.Color) {
- let hex = propertyValue.toHEX();
- info = new ColorData(`#${hex}`);
- } else if (Array.isArray(propertyValue)) {
- let keys: number[] = [];
- for (let i = 0; i < propertyValue.length; i++) {
- keys.push(i);
- }
- info = this._buildArrayData({
- data: new ArrayData(),
- path: path,
- value: propertyValue,
- keys: keys,
- })
- } else {
- !info && (info = this._buildVecData({
- // @ts-ignore
- ctor: cc.Vec3,
- path: path,
- data: new Vec3Data(),
- keys: ["x", "y", "z"],
- value: propertyValue,
- }))
- !info && (info = this._buildVecData({
- // @ts-ignore
- ctor: cc.Vec2,
- path: path,
- data: new Vec2Data(),
- keys: ["x", "y"],
- value: propertyValue
- }))
- !info && (info = this._buildImageData({
- //@ts-ignore
- ctor: cc.SpriteFrame,
- data: new ImageData(),
- path: path,
- value: propertyValue,
- }))
- if (!info) {
- if (typeof propertyValue === "object") {
- let ctorName = propertyValue.constructor.name;
- if (ctorName.startsWith("cc_")) {
- info = new EngineData();
- info.engineType = ctorName;
- info.engineName = propertyValue.name;
- info.engineUUID = propertyValue.uuid;
- } else {
- info = this._buildObjectData({
- data: new ObjectData(),
- path: path,
- value: propertyValue,
- filterKey: filterKey,
- })
+ if (propertyValue instanceof cc.Color) {
+ let hex = propertyValue.toHEX();
+ info = new ColorData(`#${hex}`);
+ } else if (Array.isArray(propertyValue)) {
+ let keys: number[] = [];
+ for (let i = 0; i < propertyValue.length; i++) {
+ keys.push(i);
+ }
+ info = this._buildArrayData({
+ data: new ArrayData(),
+ path: path,
+ value: propertyValue,
+ keys: keys,
+ })
+ } else {
+ !info && (info = this._buildVecData({
+ // @ts-ignore
+ ctor: cc.Vec3,
+ path: path,
+ data: new Vec3Data(),
+ keys: ["x", "y", "z"],
+ value: propertyValue,
+ }))
+ !info && (info = this._buildVecData({
+ // @ts-ignore
+ ctor: cc.Vec2,
+ path: path,
+ data: new Vec2Data(),
+ keys: ["x", "y"],
+ value: propertyValue
+ }))
+ !info && (info = this._buildImageData({
+ //@ts-ignore
+ ctor: cc.SpriteFrame,
+ data: new ImageData(),
+ path: path,
+ value: propertyValue,
+ }))
+ if (!info) {
+ if (typeof propertyValue === "object") {
+ let ctorName = propertyValue.constructor.name;
+ if (ctorName.startsWith("cc_")) {
+ info = new EngineData();
+ info.engineType = ctorName;
+ info.engineName = propertyValue.name;
+ info.engineUUID = propertyValue.uuid;
+ } else {
+ info = this._buildObjectData({
+ data: new ObjectData(),
+ path: path,
+ value: propertyValue,
+ filterKey: filterKey,
+ })
+ }
}
}
}
- }
- break;
+ break;
+ }
}
if (info) {
info.readonly = this._isReadonly(node, key)
@@ -389,7 +392,23 @@ class CCInspector {
}
_isInvalidValue(value: any) {
- return value === null || value === Infinity || value === undefined;
+ // !!Infinity=true
+ if ((value && value !== Infinity) || value === 0 || value === false) {
+ return false;
+ }
+
+ if (value === null) {
+ return "null"
+ } else if (value === Infinity) {
+ return "Infinity"
+ } else if (value === undefined) {
+ return "undefined"
+ } else if (Number.isNaN(value)) {
+ return "NaN";
+ } else {
+ debugger
+ return false;
+ }
}
_buildObjectData({value, path, data, filterKey}: BuildObjectOptions) {