diff --git a/source/src/background.ts b/source/src/background.ts index f17b9cb..bd27f70 100644 --- a/source/src/background.ts +++ b/source/src/background.ts @@ -112,7 +112,7 @@ class PortMan { } private updateCurrentFrameTree() { - const sendData = new PluginEvent(Page.Background, Page.Content, Msg.TreeInfo); + const sendData = new PluginEvent(Page.Background, Page.Content, Msg.Support); this.getCurrentUseContent()?.postMessage(sendData); } diff --git a/source/src/devtools/ui/index.vue b/source/src/devtools/ui/index.vue index 550ad12..4fb0b62 100644 --- a/source/src/devtools/ui/index.vue +++ b/source/src/devtools/ui/index.vue @@ -86,7 +86,6 @@ import {connectBackground} from "@/devtools/connectBackground"; import { EngineData, FrameDetails, - Group, Info, NodeInfoData, ObjectData, @@ -133,9 +132,7 @@ export default class Index extends Vue { this.showSettings = true; } - private isShowRefreshBtn = false; - - onCloseSettings() { + private syncSettings() { if (settings.data) { const {refreshType, refreshTime} = settings.data; switch (refreshType) { @@ -152,6 +149,12 @@ export default class Index extends Vue { } } + private isShowRefreshBtn = false; + + onCloseSettings() { + this.syncSettings(); + } + // el-tree的渲染key defaultProps = { children: "children", @@ -249,10 +252,10 @@ export default class Index extends Vue { } this.treeData = treeData; if (this._checkSelectedUUID()) { + this.updateNodeInfo(); this.$nextTick(() => { //@ts-ignore this.$refs.tree.setCurrentKey(this.selectedUUID); - // todo 需要重新获取下node的数据 }) } } @@ -296,25 +299,21 @@ export default class Index extends Vue { this.memory = eventData; } - _onMsgSupport(data: boolean) { - this.isShowDebug = data; - if (data) { - // 如果节点树为空,就刷新一次 - if (this.treeData.length === 0) { - this.onBtnClickUpdateTree(); - } + _onMsgSupport(isCocosGame: boolean) { + this.isShowDebug = isCocosGame; + if (isCocosGame) { + this.syncSettings(); + this.onBtnClickUpdateTree(); } else { - this._reset(); + this._clearTimer(); + this.treeData = []; + this.treeItemData = null; + this.selectedUUID = null; } } - _reset() { - this.treeData = []; - this.treeItemData = null; - } - mounted() { - this.onCloseSettings(); + this.syncSettings(); } _initChromeRuntimeConnect() { @@ -410,9 +409,12 @@ export default class Index extends Vue { handleNodeClick(data: TreeData) { this.selectedUUID = data.uuid; - let uuid = data.uuid; - if (uuid !== undefined) { - this.sendMsgToContentScript(Msg.NodeInfo, uuid); + this.updateNodeInfo(); + } + + private updateNodeInfo() { + if (this.selectedUUID) { + this.sendMsgToContentScript(Msg.NodeInfo, this.selectedUUID); } } diff --git a/source/src/devtools/ui/property-group.vue b/source/src/devtools/ui/property-group.vue index 0126e15..3409fa7 100644 --- a/source/src/devtools/ui/property-group.vue +++ b/source/src/devtools/ui/property-group.vue @@ -37,8 +37,8 @@ export default class PropertyGroup extends Vue { group!: Group; created() { - Bus.$on(BusMsg.FoldAllGroup, (b) => { - this.fold = !!b; + Bus.$on(BusMsg.FoldAllGroup, (b: boolean) => { + this.fold = b; }) } diff --git a/source/src/inject/index.ts b/source/src/inject/index.ts index b760156..c459289 100644 --- a/source/src/inject/index.ts +++ b/source/src/inject/index.ts @@ -127,7 +127,8 @@ class CCInspector { this.getNodeChildren(scene, treeData) this.sendMsgToContent(Msg.TreeInfo, treeData); } else { - this.sendMsgToContent(Msg.Support, {support: false, msg: "未发现游戏场景,不支持调试游戏!"}); + console.warn("can't execute api : cc.director.getScene") + this.notifySupportGame(false); } } else { this.notifySupportGame(false)