解析发送过来的数据异常主动报错

This commit is contained in:
xu_yanfeng 2024-12-16 10:10:31 +08:00
parent 91e7f271f6
commit a079de4241
2 changed files with 11 additions and 6 deletions

View File

@ -68,7 +68,7 @@ export default defineComponent({
setup(props, ctx) { setup(props, ctx) {
appStore().init(); appStore().init();
const { config } = storeToRefs(appStore()); const { config } = storeToRefs(appStore());
const treeItemData = ref<NodeInfoData | null>({ uuid: "", group: [] }); const treeItemData = ref<NodeInfoData | null>(null);
const isShowDebug = ref<boolean>(false); const isShowDebug = ref<boolean>(false);
const frameID = ref<number>(0); const frameID = ref<number>(0);
const iframes = ref<Array<FrameInfo>>([]); const iframes = ref<Array<FrameInfo>>([]);
@ -204,7 +204,13 @@ export default defineComponent({
}; };
msgFunctionMap[Msg.NodeInfo] = (eventData: NodeInfoData) => { msgFunctionMap[Msg.NodeInfo] = (eventData: NodeInfoData) => {
isShowDebug.value = true; isShowDebug.value = true;
treeItemData.value = eventData; try {
const nodeInfo = new NodeInfoData(eventData.uuid, eventData.group).parse(eventData);
treeItemData.value = nodeInfo;
} catch (error) {
console.error(error);
ccui.footbar.showError(error, { title: "parse property error" });
}
}; };
msgFunctionMap[Msg.MemoryInfo] = (eventData: any) => { msgFunctionMap[Msg.MemoryInfo] = (eventData: any) => {
memory.value = eventData; memory.value = eventData;

View File

@ -129,10 +129,7 @@ export class TestServer {
let g = new Group("scene").buildProperty("scene id", new StringData(id)); let g = new Group("scene").buildProperty("scene id", new StringData(id));
group.push(g); group.push(g);
} }
const ret: NodeInfoData = { const ret: NodeInfoData = new NodeInfoData(id, group);
uuid: id,
group: group
};
const event = new PluginEvent(Page.Background, Page.Devtools, Msg.NodeInfo, ret); const event = new PluginEvent(Page.Background, Page.Devtools, Msg.NodeInfo, ret);
this.send(event); this.send(event);
break; break;
@ -158,6 +155,8 @@ export class TestServer {
} }
const event = new PluginEvent(Page.Inject, Page.Devtools, Msg.GetObjectItemData, ret); const event = new PluginEvent(Page.Inject, Page.Devtools, Msg.GetObjectItemData, ret);
this.send(event) this.send(event)
} else {
console.warn("not found data: ", objData.id);
} }
break; break;
} }