diff --git a/cc-inspector/src/views/devtools/data.ts b/cc-inspector/src/views/devtools/data.ts index 4bfe8eb..be0f00f 100644 --- a/cc-inspector/src/views/devtools/data.ts +++ b/cc-inspector/src/views/devtools/data.ts @@ -186,6 +186,11 @@ export class InvalidData extends Info { this.data = data; this.type = DataType.Invalid; } + parse(data: InvalidData) { + this.id = data.id; + this.data = data.data; + return this; + } public isInvalid(): boolean { return true; } } @@ -457,6 +462,9 @@ export class Property { case DataType.Engine: this.value = new EngineData().parse(data.value as EngineData); break; + case DataType.Invalid: + this.value = new InvalidData(data.value).parse(data.value as InvalidData); + break; case DataType.ObjectItem: default: throw new Error(`not support type: ${typeof data === 'string' ? data : JSON.stringify(data)}`); diff --git a/cc-inspector/src/views/devtools/test/server.ts b/cc-inspector/src/views/devtools/test/server.ts index 9e70298..b7bf9a7 100644 --- a/cc-inspector/src/views/devtools/test/server.ts +++ b/cc-inspector/src/views/devtools/test/server.ts @@ -1,6 +1,6 @@ import { v4 } from "uuid"; import { Msg, Page, PluginEvent } from "../../../core/types"; -import { ArrayData, BoolData, ColorData, EngineData, EnumData, Group, ImageData, Info, NodeInfoData, NumberData, ObjectData, ObjectItemRequestData, Property, StringData, TextData, TreeData, Vec2Data, Vec3Data, Vec4Data } from "../data"; +import { ArrayData, BoolData, ColorData, EngineData, EnumData, Group, ImageData, Info, InvalidData, NodeInfoData, NumberData, ObjectData, ObjectItemRequestData, Property, StringData, TextData, TreeData, Vec2Data, Vec3Data, Vec4Data } from "../data"; export class TestClient { recv(event: PluginEvent) { @@ -113,6 +113,12 @@ export class TestServer { this.testData.buildChild("str2").buildComponent("group6") .buildProperty("str2", new StringData("str2")) + + this.testData.buildChild("Invalid").buildComponent("group7") + .buildProperty("NaN", new InvalidData(NaN)) + .buildProperty("null", new InvalidData(null)) + .buildProperty("Infinity", new InvalidData(Infinity)) + .buildProperty("undefined", new InvalidData(undefined)) } add(client: TestClient) { this.clients.push(client); diff --git a/cc-inspector/src/views/devtools/test/test.vue b/cc-inspector/src/views/devtools/test/test.vue index 3d1b476..4598795 100644 --- a/cc-inspector/src/views/devtools/test/test.vue +++ b/cc-inspector/src/views/devtools/test/test.vue @@ -6,6 +6,7 @@ init tree data test frame test node info + test null @@ -15,7 +16,7 @@ import { ITreeData } from "@xuyanfeng/cc-ui/types/cc-tree/const"; import { defineComponent, ref } from "vue"; import { Msg, Page, PluginEvent } from "../../../core/types"; import { connectBackground } from "../connectBackground"; -import { FrameDetails, TreeData } from "../data"; +import { FrameDetails, Group, Info, InvalidData, NodeInfoData, TreeData } from "../data"; import { testServer, TestServer } from "./server"; const { CCButton, CCSection } = ccui.components; export default defineComponent({ @@ -83,6 +84,11 @@ export default defineComponent({ const event = new PluginEvent(Page.Background, Page.Devtools, Msg.NodeInfo, testData); testServer.send(event); }, + onNull() { + const data = new NodeInfoData("", [new Group("", "1").buildProperty("dependAssets", new InvalidData("Null"))]); + const event = new PluginEvent(Page.Background, Page.Devtools, Msg.NodeInfo, data); + testServer.send(event); + }, }; }, }); diff --git a/cc-inspector/src/views/devtools/ui/ui-prop.vue b/cc-inspector/src/views/devtools/ui/ui-prop.vue index aea8280..6e8eef8 100644 --- a/cc-inspector/src/views/devtools/ui/ui-prop.vue +++ b/cc-inspector/src/views/devtools/ui/ui-prop.vue @@ -3,7 +3,7 @@
- {{ value.data }} + {{ formatValue(value.data) }}
@@ -81,6 +81,20 @@ export default defineComponent({ return { expand, subData, + formatValue(data: any) { + console.log(data); + if (data === null) { + return "null"; + } else if (data === undefined) { + return "undefined"; + } else if (data === Infinity) { + return "Infinity"; + } else if (Number.isNaN(data)) { + return "NaN"; + } else { + return data; + } + }, getEnumValues(data: any): Option[] { const value: EnumData = data; const ret: Option[] = []; @@ -147,6 +161,8 @@ export default defineComponent({ align-items: flex-start; .invalid { + user-select: none; + font-size: 12px; color: grey; }