36 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-12-09 16:23:58 +08:00
import CCP from "cc-plugin/src/ccp/entry-render";
2024-01-09 12:02:47 +08:00
import { ChromeConst } from "cc-plugin/src/chrome/const";
2024-12-09 16:23:58 +08:00
import { Msg, Page, PluginEvent } from "../../core/types";
2024-01-09 12:02:47 +08:00
import { connectBackground } from "./connectBackground";
2021-04-26 22:27:47 +08:00
export function init() {
2024-01-09 16:34:16 +08:00
if (chrome && chrome.devtools) {
2021-04-26 22:27:47 +08:00
// 对应的是Elements面板的边栏
2024-01-09 16:34:16 +08:00
chrome.devtools.panels.elements.createSidebarPane(CCP.manifest.name, 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 16:34:16 +08:00
let iconPath = "";
const { icon } = CCP.manifest;
if (icon && icon['48']) {
iconPath = icon['48'];
}
chrome.devtools.panels.create(CCP.manifest.name, iconPath, ChromeConst.html.devtools, (panel: chrome.devtools.panels.ExtensionPanel) => {
2024-01-09 12:02:47 +08:00
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
}