mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-12 05:01:03 +00:00
code menu hover时,提示具体的函数实现逻辑,方便选择是哪个函数
This commit is contained in:
parent
0452694ee6
commit
246829f80c
@ -73,7 +73,7 @@ export interface ResponseUseFrameData {
|
||||
export type RequestSetPropertyData = Info;
|
||||
export type ResponseSetPropertyData = Info;
|
||||
export type RequestLogData = string[];
|
||||
export type RequestOpenNodeTouchFuntionData = { uuid: string; code: ShowCode };
|
||||
export type RequestOpenNodeTouchFuntionData = { uuid: string; code: ShowCode; index: number };
|
||||
export type ResponseErrorData = string;
|
||||
export enum Msg {
|
||||
None = "None",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TreeData } from "../../views/devtools/data";
|
||||
import { FunctionInfo, TreeData } from "../../views/devtools/data";
|
||||
import { ShowCode } from "./types";
|
||||
declare const cc: any;
|
||||
|
||||
@ -29,18 +29,30 @@ export function getCallbacks(node: any, code: ShowCode) {
|
||||
if (!funArray || funArray.length === 0) {
|
||||
return [];
|
||||
}
|
||||
if (funArray.length > 1) {
|
||||
console.warn(`多个事件回调函数${funArray.length}`);
|
||||
}
|
||||
return funArray.map((fun) => {
|
||||
// @ts-ignore
|
||||
return fun.callback;
|
||||
});
|
||||
}
|
||||
export function calcCodeHint(node: any, data: TreeData) {
|
||||
data.codeTouchStart = getCallbacks(node, ShowCode.TouchStart).length;
|
||||
data.codeTouchMove = getCallbacks(node, ShowCode.TouchMove).length;
|
||||
data.codeTouchEnd = getCallbacks(node, ShowCode.TouchEnd).length;
|
||||
data.codeTouchCancel = getCallbacks(node, ShowCode.TouchCancel).length;
|
||||
data.codeButtonClick = getCallbacks(node, ShowCode.ButtonClick).length;
|
||||
export const ANONYMOUS = "anonymous";
|
||||
|
||||
function functionInfo(node: any, type: ShowCode): FunctionInfo[] {
|
||||
return getCallbacks(node, type).map((item) => {
|
||||
let desc = item.toString();
|
||||
const max = 50;
|
||||
if (desc.length > max) {
|
||||
// desc = desc.substr(0, max) + "...";
|
||||
}
|
||||
return {
|
||||
name: item.name || ANONYMOUS,
|
||||
desc,
|
||||
} as FunctionInfo;
|
||||
});
|
||||
}
|
||||
export function calcCodeHint(node: any, data: TreeData) {
|
||||
data.codeTouchStart = functionInfo(node, ShowCode.TouchStart);
|
||||
data.codeTouchMove = functionInfo(node, ShowCode.TouchMove);
|
||||
data.codeTouchEnd = functionInfo(node, ShowCode.TouchEnd);
|
||||
data.codeTouchCancel = functionInfo(node, ShowCode.TouchCancel);
|
||||
data.codeButtonClick = functionInfo(node, ShowCode.ButtonClick);
|
||||
}
|
||||
|
@ -113,11 +113,11 @@ export class Inspector extends InjectEvent {
|
||||
return;
|
||||
}
|
||||
const funArray = getCallbacks(node, data.code);
|
||||
if (funArray && funArray.length) {
|
||||
if (funArray && funArray.length && data.index < funArray.length) {
|
||||
// @ts-ignore
|
||||
const fn = funArray[0];
|
||||
const fn = funArray[data.index];
|
||||
this.target = fn;
|
||||
if (funArray.length !== 1) {
|
||||
if (!fn) {
|
||||
debugger;
|
||||
}
|
||||
}
|
||||
|
@ -518,7 +518,10 @@ export class EnumData extends Info {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
export interface FunctionInfo {
|
||||
name: string;
|
||||
desc: string;
|
||||
}
|
||||
export class TreeData implements ITreeData {
|
||||
id: string = "";
|
||||
icon: string = "";
|
||||
@ -526,11 +529,11 @@ export class TreeData implements ITreeData {
|
||||
/**
|
||||
* 回调的数量
|
||||
*/
|
||||
codeTouchStart: number = 0;
|
||||
codeTouchMove: number = 0;
|
||||
codeTouchEnd: number = 0;
|
||||
codeTouchCancel: number = 0;
|
||||
codeButtonClick: number = 0;
|
||||
codeTouchStart: FunctionInfo[] = [];
|
||||
codeTouchMove: FunctionInfo[] = [];
|
||||
codeTouchEnd: FunctionInfo[] = [];
|
||||
codeTouchCancel: FunctionInfo[] = [];
|
||||
codeButtonClick: FunctionInfo[] = [];
|
||||
active: boolean = true;
|
||||
text: string = "";
|
||||
children: TreeData[] = [];
|
||||
|
@ -29,7 +29,7 @@ import { ShowCode } from "../../scripts/inject/types";
|
||||
import { bridge } from "./bridge";
|
||||
import { Bus, BusMsg } from "./bus";
|
||||
import { RotateType } from "./const";
|
||||
import { EngineData, TreeData } from "./data";
|
||||
import { EngineData, FunctionInfo, TreeData } from "./data";
|
||||
import GameInfo from "./game-info.vue";
|
||||
import Refresh from "./refresh.vue";
|
||||
import { appStore } from "./store";
|
||||
@ -275,48 +275,68 @@ export default defineComponent({
|
||||
onMenu(event: MouseEvent, data: TreeData) {
|
||||
const menus: IUiMenuItem[] = [];
|
||||
if (data) {
|
||||
function hintCode(type: ShowCode) {
|
||||
bridge.send(Msg.RequestOpenNodeTouchFuntion, { uuid: data.id, code: type } as RequestOpenNodeTouchFuntionData);
|
||||
function doInspect(type: ShowCode, index: number) {
|
||||
bridge.send(Msg.RequestOpenNodeTouchFuntion, { uuid: data.id, code: type, index } as RequestOpenNodeTouchFuntionData);
|
||||
chrome.devtools.inspectedWindow.eval(`DoInspect()`);
|
||||
}
|
||||
function hintCode(type: ShowCode, cbArray: FunctionInfo[], event: MouseEvent) {
|
||||
if (cbArray.length === 1) {
|
||||
doInspect(type, 0);
|
||||
} else {
|
||||
const subMenu: IUiMenuItem[] = [];
|
||||
for (let i = 0; i < cbArray.length; i++) {
|
||||
const item = cbArray[i];
|
||||
subMenu.push({
|
||||
name: item.name,
|
||||
tip: item.desc,
|
||||
callback: (item) => {
|
||||
doInspect(type, i);
|
||||
},
|
||||
});
|
||||
}
|
||||
nextTick(() => {
|
||||
ccui.menu.showMenuByMouseEvent(event, subMenu);
|
||||
});
|
||||
}
|
||||
}
|
||||
menus.push({
|
||||
name: `code button-click [${data.codeButtonClick}]`,
|
||||
visible: !!data.codeButtonClick,
|
||||
callback: (item) => {
|
||||
name: `code button-click [${data.codeButtonClick.length}]`,
|
||||
visible: !!data.codeButtonClick.length,
|
||||
callback: (item, event: MouseEvent) => {
|
||||
ga.fireEventWithParam(GA_EventName.MouseMenu, ShowCode.ButtonClick);
|
||||
hintCode(ShowCode.ButtonClick);
|
||||
hintCode(ShowCode.ButtonClick, data.codeButtonClick, event);
|
||||
},
|
||||
});
|
||||
menus.push({
|
||||
name: `code touch-start [${data.codeTouchStart}]`,
|
||||
visible: !!data.codeTouchStart,
|
||||
callback: (item) => {
|
||||
name: `code touch-start [${data.codeTouchStart.length}]`,
|
||||
visible: !!data.codeTouchStart.length,
|
||||
callback: (item, event: MouseEvent) => {
|
||||
ga.fireEventWithParam(GA_EventName.MouseMenu, ShowCode.TouchStart);
|
||||
hintCode(ShowCode.TouchStart);
|
||||
hintCode(ShowCode.TouchStart, data.codeTouchStart, event);
|
||||
},
|
||||
});
|
||||
menus.push({
|
||||
name: `code touch-move [${data.codeTouchMove}]`,
|
||||
visible: !!data.codeTouchMove,
|
||||
callback: (item) => {
|
||||
name: `code touch-move [${data.codeTouchMove.length}]`,
|
||||
visible: !!data.codeTouchMove.length,
|
||||
callback: (item, event: MouseEvent) => {
|
||||
ga.fireEventWithParam(GA_EventName.MouseMenu, ShowCode.TouchMove);
|
||||
hintCode(ShowCode.TouchMove);
|
||||
hintCode(ShowCode.TouchMove, data.codeTouchMove, event);
|
||||
},
|
||||
});
|
||||
menus.push({
|
||||
name: `code touch-end [${data.codeTouchEnd}]`,
|
||||
visible: !!data.codeTouchEnd,
|
||||
callback: (item) => {
|
||||
name: `code touch-end [${data.codeTouchEnd.length}]`,
|
||||
visible: !!data.codeTouchEnd.length,
|
||||
callback: (item, event: MouseEvent) => {
|
||||
ga.fireEventWithParam(GA_EventName.MouseMenu, ShowCode.TouchEnd);
|
||||
hintCode(ShowCode.TouchEnd);
|
||||
hintCode(ShowCode.TouchEnd, data.codeTouchEnd, event);
|
||||
},
|
||||
});
|
||||
menus.push({
|
||||
name: `code touch-cancel [${data.codeTouchCancel}]`,
|
||||
visible: !!data.codeTouchCancel,
|
||||
callback: (item) => {
|
||||
name: `code touch-cancel [${data.codeTouchCancel.length}]`,
|
||||
visible: !!data.codeTouchCancel.length,
|
||||
callback: (item, event: MouseEvent) => {
|
||||
ga.fireEventWithParam(GA_EventName.MouseMenu, ShowCode.TouchCancel);
|
||||
hintCode(ShowCode.TouchCancel);
|
||||
hintCode(ShowCode.TouchCancel, data.codeTouchCancel, event);
|
||||
},
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user