之前的逻辑优化

This commit is contained in:
xuyanfeng
2021-05-08 22:05:59 +08:00
parent 8debbe8974
commit e5e38d92b9
3 changed files with 24 additions and 13 deletions

View File

@@ -19,13 +19,17 @@ class CCInspector {
init() {
console.log('cc-inspector init ~~~');
setInterval(() => {
// this.checkIsGamePage(true);
// if (this.stop) {
// } else {
// }
}, 1000);
// 注册cc_after_render事件
let timer = setInterval(() => {
if (this._isCocosGame()) {
clearInterval(timer)
// @ts-ignore
cc.director.on(cc.Director.EVENT_AFTER_SCENE_LAUNCH, () => {
console.log('scene launch')
})
}
}, 300)
window.addEventListener("message", (event) => {
// 接受来自content的事件有可能也会受到其他插件的
if (!event || !event.data) {
@@ -33,7 +37,7 @@ class CCInspector {
}
let pluginEvent: PluginEvent = event.data;
if (PluginEvent.check(pluginEvent, Page.Content, Page.Inject)) {
console.log(`[Inject] ${JSON.stringify(pluginEvent)}`, 'color:green;');
console.log(`%c[Inject] ${JSON.stringify(pluginEvent)}`, 'color:green;');
PluginEvent.finish(pluginEvent)
switch (pluginEvent.msg) {
case Msg.UrlChange:

View File

@@ -1,5 +1,6 @@
import Manifest from '../manifest.json'
import {connectBackground} from "@/devtools/connectBackground";
import {PluginEvent, Msg, Page} from "@/core/types";
export function init() {
if (chrome && chrome.devtools) {
@@ -14,8 +15,7 @@ export function init() {
panel.onShown.addListener((window) => {
// 面板显示查询是否是cocos游戏
console.log("panel show");
// let sendData = new PluginEvent(PluginMsg.Msg.Support);
// connectBackground.postMessage(sendData)
connectBackground.postMessageToBackground(Msg.Support, null)
});
panel.onHidden.addListener(() => {
// 面板隐藏