2021-04-03 16:47:16 +08:00
|
|
|
|
import Manifest from '../manifest.json'
|
2021-04-26 22:27:47 +08:00
|
|
|
|
import {connectBackground} from "@/devtools/connectBackground";
|
2021-05-08 22:05:59 +08:00
|
|
|
|
import {PluginEvent, Msg, Page} from "@/core/types";
|
2021-04-03 16:47:16 +08:00
|
|
|
|
|
2021-04-26 22:27:47 +08:00
|
|
|
|
export function init() {
|
|
|
|
|
if (chrome && chrome.devtools) {
|
|
|
|
|
// 对应的是Elements面板的边栏
|
|
|
|
|
chrome.devtools.panels.elements.createSidebarPane('Cocos', function (sidebar) {
|
|
|
|
|
sidebar.setObject({some_data: "some data to show!"});
|
|
|
|
|
});
|
2021-04-03 16:47:16 +08:00
|
|
|
|
|
2021-04-26 22:27:47 +08:00
|
|
|
|
// 创建devtools-panel
|
|
|
|
|
chrome.devtools.panels.create("Cocos", "icons/48.png", Manifest.devtools_page, (panel: chrome.devtools.panels.ExtensionPanel) => {
|
|
|
|
|
console.log("[CC-Inspector] Dev Panel Created!");
|
|
|
|
|
panel.onShown.addListener((window) => {
|
|
|
|
|
// 面板显示,查询是否是cocos游戏
|
|
|
|
|
console.log("panel show");
|
2021-11-04 21:01:33 +08:00
|
|
|
|
// connectBackground.postMessageToBackground(Msg.Support, null)
|
2021-04-26 22:27:47 +08:00
|
|
|
|
});
|
|
|
|
|
panel.onHidden.addListener(() => {
|
|
|
|
|
// 面板隐藏
|
|
|
|
|
console.log("panel hide");
|
|
|
|
|
});
|
|
|
|
|
panel.onSearch.addListener(function (action, query) {
|
|
|
|
|
// ctrl+f 查找触发
|
|
|
|
|
console.log("panel search!");
|
|
|
|
|
});
|
2021-04-22 19:09:35 +08:00
|
|
|
|
}
|
2021-04-26 22:27:47 +08:00
|
|
|
|
);
|
|
|
|
|
}
|
2021-04-03 16:47:16 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|