Files
cc-inspector-chrome/cc-inspector/src/views/devtools/register-panel.ts
T
xu_yanfeng 4da068e358 format
2024-12-09 16:23:58 +08:00

36 lines
1.3 KiB
TypeScript

import CCP from "cc-plugin/src/ccp/entry-render";
import { ChromeConst } from "cc-plugin/src/chrome/const";
import { Msg, Page, PluginEvent } from "../../core/types";
import { connectBackground } from "./connectBackground";
export function init() {
if (chrome && chrome.devtools) {
// 对应的是Elements面板的边栏
chrome.devtools.panels.elements.createSidebarPane(CCP.manifest.name, function (sidebar) {
sidebar.setObject({ some_data: "some data to show!" });
});
// 创建devtools-panel
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) => {
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!");
});
}
);
}
}