mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-19 16:38:41 +00:00
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
|
import * as PluginMsg from '../core/plugin-msg'
|
||
|
import Manifest from '../manifest.json'
|
||
|
|
||
|
|
||
|
if (chrome && chrome.devtools) {
|
||
|
// 对应的是Elements面板的边栏
|
||
|
chrome.devtools.panels.elements.createSidebarPane('Cocos', function (sidebar) {
|
||
|
sidebar.setObject({some_data: "some data to show!"});
|
||
|
});
|
||
|
// 创建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!");
|
||
|
let conn = chrome.runtime.connect({name: PluginMsg.Page.DevToolsPanel});
|
||
|
conn.onMessage.addListener(function (event, sender) {
|
||
|
// debugger
|
||
|
});
|
||
|
|
||
|
panel.onShown.addListener((window) => {
|
||
|
console.log("panel show");
|
||
|
conn.postMessage({msg: PluginMsg.Msg.UrlChange, data: {}})
|
||
|
});
|
||
|
panel.onHidden.addListener(() => {
|
||
|
console.log("panel hide");
|
||
|
});
|
||
|
panel.onSearch.addListener(function (action, query) {
|
||
|
console.log("panel search!");
|
||
|
});
|
||
|
}
|
||
|
);
|
||
|
|
||
|
|
||
|
}
|
||
|
|