添加了一些log

This commit is contained in:
xu_yanfeng 2024-12-15 19:59:51 +08:00
parent 153a2f66f1
commit 3cdb4db7cf
6 changed files with 34 additions and 10 deletions

View File

@ -9,6 +9,7 @@ class Content {
private connect: chrome.runtime.Port | null = null; private connect: chrome.runtime.Port | null = null;
constructor() { constructor() {
console.log("init content");
// 接受来自inject.js的消息数据,然后中转到background.js // 接受来自inject.js的消息数据,然后中转到background.js
window.addEventListener("message", (event) => { window.addEventListener("message", (event) => {
let data: PluginEvent = event.data; let data: PluginEvent = event.data;

View File

@ -0,0 +1,19 @@
export class Terminal {
color = 'red';
background = 'yellow';
tag = 'terminal';
constructor(tag: string, color: string = 'red', background: string = 'yellow') {
this.color = color;
this.background = background;
this.tag = tag;
}
ok() {
this.log(`ok`);
}
log(message: string) {
console.log(`%c${this.tag}%c${message}`, `color:${this.color};background:${this.background};padding:0 4px`, "color:black;margin-left:5px")
}
connect(msg: string) {
this.log(`[connect] ${msg}`);
}
}

View File

@ -2,6 +2,9 @@ import CCP from "cc-plugin/src/ccp/entry-render";
import { Msg, Page, PluginEvent } from "../../core/types"; import { Msg, Page, PluginEvent } from "../../core/types";
import { TestClient, testServer, TestServer } from "./test/server"; import { TestClient, testServer, TestServer } from "./test/server";
export type BackgroundCallback = (data: PluginEvent, sender: any) => void; export type BackgroundCallback = (data: PluginEvent, sender: any) => void;
if (chrome.devtools) {
console.log("chrome devtools")
}
class ConnectBackground implements TestClient { class ConnectBackground implements TestClient {
connect: chrome.runtime.Port | null = null; connect: chrome.runtime.Port | null = null;
constructor() { constructor() {

View File

@ -69,7 +69,7 @@ export default defineComponent({
appStore().init(); appStore().init();
const { config } = storeToRefs(appStore()); const { config } = storeToRefs(appStore());
const treeItemData = ref<NodeInfoData | null>({ uuid: "", group: [] }); const treeItemData = ref<NodeInfoData | null>({ uuid: "", group: [] });
const isShowDebug = ref<boolean>(true); const isShowDebug = ref<boolean>(false);
const frameID = ref<number>(0); const frameID = ref<number>(0);
const iframes = ref<Array<FrameInfo>>([]); const iframes = ref<Array<FrameInfo>>([]);
const btnRefresh: ButtonGroupItem = reactive<ButtonGroupItem>({ const btnRefresh: ButtonGroupItem = reactive<ButtonGroupItem>({
@ -172,8 +172,7 @@ export default defineComponent({
} }
}); });
} }
const elTree = ref<HTMLElement>(); const elTree = ref<typeof CCTree>();
function _initChromeRuntimeConnect() { function _initChromeRuntimeConnect() {
const msgFunctionMap: Record<string, Function> = {}; const msgFunctionMap: Record<string, Function> = {};
msgFunctionMap[Msg.TreeInfo] = (data: Array<TreeData>) => { msgFunctionMap[Msg.TreeInfo] = (data: Array<TreeData>) => {
@ -186,7 +185,7 @@ export default defineComponent({
updateNodeInfo(); updateNodeInfo();
nextTick(() => { nextTick(() => {
if (elTree.value) { if (elTree.value) {
elTree.value.setCurrentKey(selectedUUID); elTree.value.handChoose(selectedUUID);
} }
}); });
} }
@ -423,9 +422,13 @@ export default defineComponent({
matchCase.value = !matchCase.value; matchCase.value = !matchCase.value;
updateFilterText(filterText); updateFilterText(filterText);
}, },
handleNodeClick(data: TreeData) { handleNodeClick(data: TreeData | null) {
if (data) {
selectedUUID = data.id; selectedUUID = data.id;
updateNodeInfo(); updateNodeInfo();
} else {
selectedUUID = null;
}
}, },
// TODO: // TODO:
filterNode(value: any, data: any) { filterNode(value: any, data: any) {

View File

@ -1,7 +1,5 @@
import CCP from "cc-plugin/src/ccp/entry-render"; import CCP from "cc-plugin/src/ccp/entry-render";
import { ChromeConst } from "cc-plugin/src/chrome/const"; import { ChromeConst } from "cc-plugin/src/chrome/const";
import { Msg, Page, PluginEvent } from "../../core/types";
import { connectBackground } from "./connectBackground";
export function init() { export function init() {
if (chrome && chrome.devtools) { if (chrome && chrome.devtools) {
// 对应的是Elements面板的边栏 // 对应的是Elements面板的边栏

View File

@ -1,6 +1,6 @@
<template> <template>
<div v-if="show" class="test"> <div v-if="show" class="test">
<CCSection name="功能测试"> <CCSection name="功能测试" :expand="false">
<CCButton @click="onClickHasCocosGame">Has CocosGame</CCButton> <CCButton @click="onClickHasCocosGame">Has CocosGame</CCButton>
<CCButton @click="onClickNoCocosGame">No CocosGame</CCButton> <CCButton @click="onClickNoCocosGame">No CocosGame</CCButton>
<CCButton @click="onTestTree">init tree data</CCButton> <CCButton @click="onTestTree">init tree data</CCButton>