mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-10-23 00:35:23 +00:00
逻辑优化
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Msg, Page, PluginEvent } from "../../core/types";
|
||||
import { debugLog, Msg, Page, PluginEvent } from "../../core/types";
|
||||
import { DocumentEvent } from "../const";
|
||||
import { Terminal } from "../terminal";
|
||||
|
||||
@@ -7,14 +7,14 @@ export class InjectEvent {
|
||||
constructor() {
|
||||
document.addEventListener(DocumentEvent.Content2Inject, (event: CustomEvent) => {
|
||||
const pluginEvent: PluginEvent = PluginEvent.create(event.detail);
|
||||
console.log(...this.terminal.chunkMessage(pluginEvent.toChunk()));
|
||||
debugLog && console.log(...this.terminal.chunkMessage(pluginEvent.toChunk()));
|
||||
this.onMessage(pluginEvent);
|
||||
});
|
||||
}
|
||||
onMessage(data: PluginEvent) {}
|
||||
sendMsgToContent(msg: Msg, data: any) {
|
||||
const detail = new PluginEvent(Page.Inject, Page.Content, msg, data);
|
||||
console.log(...this.terminal.chunkSend(detail.toChunk()));
|
||||
debugLog && console.log(...this.terminal.chunkSend(detail.toChunk()));
|
||||
const event = new CustomEvent(DocumentEvent.Inject2Content, { detail });
|
||||
document.dispatchEvent(event);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// eval 注入脚本的代码,变量尽量使用var,后来发现在import之后,let会自动变为var
|
||||
import { uniq } from "lodash";
|
||||
import { Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestSetPropertyData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
||||
import { debugLog, Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestSetPropertyData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
||||
import { ArrayData, BoolData, ColorData, DataType, EngineData, Group, ImageData, Info, InvalidData, NodeInfoData, NumberData, ObjectData, Property, StringData, TreeData, Vec2Data, Vec3Data } from "../../views/devtools/data";
|
||||
import { InjectEvent } from "./event";
|
||||
import { getValue, trySetValueWithConfig } from "./setValue";
|
||||
@@ -62,10 +62,26 @@ export class Inspector extends InjectEvent {
|
||||
logFunction(value);
|
||||
break;
|
||||
}
|
||||
case Msg.RequestVisible: {
|
||||
const uuid: string = pluginEvent.data;
|
||||
const node = this.inspectorGameMemoryStorage[uuid];
|
||||
if (node) {
|
||||
node.active = !node.active;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Msg.RequestDestroy: {
|
||||
const uuid: string = pluginEvent.data;
|
||||
const node = this.inspectorGameMemoryStorage[uuid];
|
||||
if (node && node.isValid && node.destroy) {
|
||||
node.destroy();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
init() {
|
||||
console.log(...this.terminal.init());
|
||||
debugLog && console.log(...this.terminal.init());
|
||||
this.watchIsCocosGame();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user