mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-18 07:58:40 +00:00
完善InvalidData
This commit is contained in:
parent
a079de4241
commit
e0e78064fc
@ -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)}`);
|
||||
|
@ -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);
|
||||
|
@ -6,6 +6,7 @@
|
||||
<CCButton @click="onTestTree">init tree data</CCButton>
|
||||
<CCButton @click="onFrames">test frame</CCButton>
|
||||
<CCButton @click="onTestNodeInfo">test node info</CCButton>
|
||||
<CCButton @click="onNull">test null</CCButton>
|
||||
</CCSection>
|
||||
</div>
|
||||
</template>
|
||||
@ -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);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
<CCProp :name="name" :icon="icon" :head-width="headWidth" v-model:expand="expand" :arrow="value && value.isArrayOrObject()" :slide="value && value.isNumber()" :indent="indent * 10" @change-expand="onClickFold">
|
||||
<div class="prop-value" v-if="value">
|
||||
<div v-if="value.isInvalid()" class="invalid">
|
||||
{{ value.data }}
|
||||
{{ formatValue(value.data) }}
|
||||
</div>
|
||||
<CCInput v-if="value.isString()" v-model:value="value.data" :disabled="value.readonly" @change="onChangeValue"> </CCInput>
|
||||
<CCTextarea v-if="value.isText()" v-model:value="value.data" :disabled="value.readonly" @change="onChangeValue"> </CCTextarea>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user