31 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-01-09 12:02:47 +08:00
import { ChromeConst } from "cc-plugin/src/chrome/const";
import { connectBackground } from "./connectBackground";
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() {
2024-01-09 12:02:47 +08:00
if (chrome && chrome.devtools) {
2021-04-26 22:27:47 +08:00
// 对应的是Elements面板的边栏
chrome.devtools.panels.elements.createSidebarPane('Cocos', function (sidebar) {
2024-01-09 12:02:47 +08:00
sidebar.setObject({ some_data: "some data to show!" });
2021-04-26 22:27:47 +08:00
});
2021-04-03 16:47:16 +08:00
2021-04-26 22:27:47 +08:00
// 创建devtools-panel
2024-01-09 12:02:47 +08:00
chrome.devtools.panels.create("Cocos", "icons/48.png", ChromeConst.html.devtools, (panel: chrome.devtools.panels.ExtensionPanel) => {
console.log("[CC-Inspector] Dev Panel Created!");
panel.onShown.addListener((window) => {
// 面板显示查询是否是cocos游戏
console.log("panel show");
// connectBackground.postMessageToBackground(Msg.Support, null)
});
panel.onHidden.addListener(() => {
// 面板隐藏
console.log("panel hide");
});
panel.onSearch.addListener(function (action, query) {
// ctrl+f 查找触发
console.log("panel search!");
});
}
2021-04-26 22:27:47 +08:00
);
}
2024-01-09 12:02:47 +08:00
}