增加log功能

This commit is contained in:
xyf-mac 2021-12-05 18:21:00 +08:00
parent 67dea61ffe
commit 8702f666d0
7 changed files with 32 additions and 6 deletions

View File

@ -44,6 +44,7 @@ module.exports = {
"@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/ban-ts-comment": "off",
"no-inner-declarations": "off", "no-inner-declarations": "off",
"vue/no-unused-vars": "off", "vue/no-unused-vars": "off",
"@typescript-eslint/no-namespace": "off" "@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-this-alias": "off"
} }
}; };

View File

@ -17,6 +17,7 @@ export enum Msg {
UpdateFrames = "UpdateFrames", // 更新页面的frame UpdateFrames = "UpdateFrames", // 更新页面的frame
UseFrame = "UseFrame", UseFrame = "UseFrame",
GetObjectItemData = "GetObjectItemData", GetObjectItemData = "GetObjectItemData",
LogData = "LogData",
SetProperty = "set-property", // 设置node属性 SetProperty = "set-property", // 设置node属性
UpdateProperty = "update-property", // 更新属性 UpdateProperty = "update-property", // 更新属性
} }

View File

@ -3,6 +3,7 @@ import Vue from "vue"
export enum BusMsg { export enum BusMsg {
ShowPlace = "ShowPlace", ShowPlace = "ShowPlace",
RequestObjectData = "RequestObjectData", RequestObjectData = "RequestObjectData",
LogData = "LogData",
FoldAllGroup = "FoldAllGroup" FoldAllGroup = "FoldAllGroup"
} }

View File

@ -193,11 +193,13 @@ export class Property {
} }
export class Group { export class Group {
public id: string = "";
public name: string = "group"; public name: string = "group";
public data: Array<Property> = []; public data: Array<Property> = [];
constructor(name: string) { constructor(name: string,id?:string) {
this.name = name; this.name = name;
this.id=id||'';
} }
addProperty(property: Property) { addProperty(property: Property) {

View File

@ -147,7 +147,6 @@ export default class Index extends Vue {
} }
private syncSettings() { private syncSettings() {
if (settings.data) { if (settings.data) {
const {refreshType, refreshTime} = settings.data; const {refreshType, refreshTime} = settings.data;
@ -204,6 +203,9 @@ export default class Index extends Vue {
this.requestList.push({id: data.id, cb}); this.requestList.push({id: data.id, cb});
this.sendMsgToContentScript(Msg.GetObjectItemData, data) this.sendMsgToContentScript(Msg.GetObjectItemData, data)
}); });
Bus.$on(BusMsg.LogData, (data: string[]) => {
this.sendMsgToContentScript(Msg.LogData, data);
})
} }
filterNode(value: any, data: any) { filterNode(value: any, data: any) {

View File

@ -1,11 +1,19 @@
<template> <template>
<div class="property-group"> <div class="property-group">
<div class="header" @click="onClickHeader"> <div class="header" @click="onClickHeader"
@mouseenter="showLogBtn=true"
@mouseleave="showLogBtn=false">
<div style="margin: 0 5px;"> <div style="margin: 0 5px;">
<i v-if="fold" class="el-icon-caret-right"></i> <i v-if="fold" class="el-icon-caret-right"></i>
<i v-if="!fold" class="el-icon-caret-bottom"></i> <i v-if="!fold" class="el-icon-caret-bottom"></i>
</div> </div>
{{ group.name }} <div style="flex:1;">
{{ group.name }}
</div>
<el-button style="margin-right: 10px;"
v-show="showLogBtn"
type="success" icon="el-icon-chat-dot-round" @click.stop="onLog">
</el-button>
</div> </div>
<div class="content" v-show="!fold"> <div class="content" v-show="!fold">
<ui-prop v-for="(item, index) in group.data" :key="index" <ui-prop v-for="(item, index) in group.data" :key="index"
@ -29,6 +37,7 @@ import Bus, {BusMsg} from "@/devtools/bus";
}) })
export default class PropertyGroup extends Vue { export default class PropertyGroup extends Vue {
private fold = false; private fold = false;
private showLogBtn = false;
@Prop({ @Prop({
default: () => { default: () => {
return new Group("test") return new Group("test")
@ -45,6 +54,10 @@ export default class PropertyGroup extends Vue {
mounted() { mounted() {
} }
onLog() {
Bus.$emit(BusMsg.LogData, [this.group.id]);
}
onClickHeader() { onClickHeader() {
this.fold = !this.fold; this.fold = !this.fold;
} }

View File

@ -85,6 +85,12 @@ class CCInspector {
} }
break; break;
} }
case Msg.LogData: {
const data: string[] = pluginEvent.data;
const value = getValue(this.inspectorGameMemoryStorage, data);
console.log(value);
break;
}
case Msg.GetObjectItemData: { case Msg.GetObjectItemData: {
const data: ObjectData = pluginEvent.data; const data: ObjectData = pluginEvent.data;
let val = getValue(this.inspectorGameMemoryStorage, data.path); let val = getValue(this.inspectorGameMemoryStorage, data.path);
@ -526,7 +532,7 @@ class CCInspector {
_getGroupData(node: any) { _getGroupData(node: any) {
const name = this.getCompName(node); const name = this.getCompName(node);
let nodeGroup = new Group(name); let nodeGroup = new Group(name, node.uuid);
let keys = this._getNodeKeys(node); let keys = this._getNodeKeys(node);
for (let i = 0; i < keys.length;) { for (let i = 0; i < keys.length;) {
let key = keys[i]; let key = keys[i];