mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-20 17:08:41 +00:00
显示引擎的类型
This commit is contained in:
parent
0c5e3c8da2
commit
931d119287
7
source/src/devtools/bus.ts
Normal file
7
source/src/devtools/bus.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
|
||||||
|
export enum BusMsg {
|
||||||
|
ShowPlace = 'ShowPlace',
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new Vue();
|
@ -11,6 +11,7 @@ export enum DataType {
|
|||||||
Array, // 暂时在控制台打印下
|
Array, // 暂时在控制台打印下
|
||||||
Object,
|
Object,
|
||||||
Image, // 图片
|
Image, // 图片
|
||||||
|
Engine,// 引擎的类型:cc.Node, cc.Sprite, cc.Label等。。。
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Info {
|
export class Info {
|
||||||
@ -27,6 +28,17 @@ export class TextData extends Info {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class EngineData extends Info {
|
||||||
|
public engineType: string = '';
|
||||||
|
public engineUUID: string = '';
|
||||||
|
public engineName: string = '';
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.type = DataType.Engine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class ArrayData extends Info {
|
export class ArrayData extends Info {
|
||||||
data: Array<Property> = [];
|
data: Array<Property> = [];
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import ElementUI from "element-ui"
|
import ElementUI from "element-ui"
|
||||||
import "element-ui/lib/theme-chalk/index.css"
|
import "element-ui/lib/theme-chalk/index.css"
|
||||||
|
import './icon-font/iconfont.css'
|
||||||
import "./global.less"
|
import "./global.less"
|
||||||
import index from "./index.vue";
|
import index from "./index.vue";
|
||||||
import {init} from './register-panel';
|
import {init} from './register-panel';
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
@node-expand="onNodeExpand"
|
@node-expand="onNodeExpand"
|
||||||
@node-collapse="onNodeCollapse"
|
@node-collapse="onNodeCollapse"
|
||||||
@node-click="handleNodeClick">
|
@node-click="handleNodeClick">
|
||||||
|
<!-- :render-content="renderContent"-->
|
||||||
|
|
||||||
<span slot-scope="{node,data}" class="leaf" :class="data.active?'leaf-show':'leaf-hide'">
|
<span slot-scope="{node,data}" class="leaf" :class="data.active?'leaf-show':'leaf-hide'">
|
||||||
<span>{{ node.label }}</span>
|
<span>{{ node.label }}</span>
|
||||||
@ -53,7 +54,8 @@ import {Component} from "vue-property-decorator";
|
|||||||
import properties from "./propertys.vue";
|
import properties from "./propertys.vue";
|
||||||
import {Msg, Page, PluginEvent} from '@/core/types'
|
import {Msg, Page, PluginEvent} from '@/core/types'
|
||||||
import {connectBackground} from "@/devtools/connectBackground";
|
import {connectBackground} from "@/devtools/connectBackground";
|
||||||
import {Info, TreeData} from "@/devtools/data";
|
import {EngineData, Info, TreeData} from "@/devtools/data";
|
||||||
|
import Bus, {BusMsg} from './bus';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
@ -88,6 +90,48 @@ export default class Index extends Vue {
|
|||||||
window.addEventListener("message", function (event) {
|
window.addEventListener("message", function (event) {
|
||||||
console.log("on vue:" + JSON.stringify(event));
|
console.log("on vue:" + JSON.stringify(event));
|
||||||
}, false);
|
}, false);
|
||||||
|
Bus.$on(BusMsg.ShowPlace, (data: EngineData) => {
|
||||||
|
console.log(data)
|
||||||
|
this._expand(data.engineUUID);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
_expand(uuid: string) {
|
||||||
|
|
||||||
|
let expandKeys: Array<string> = [];
|
||||||
|
|
||||||
|
function circle(array: any) {
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
let item = array[i];
|
||||||
|
expandKeys.push(item.uuid);
|
||||||
|
if (item.uuid === uuid) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
let find = circle(item.children);
|
||||||
|
if (find) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
expandKeys.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
circle(this.treeData)
|
||||||
|
|
||||||
|
expandKeys.forEach(key => {
|
||||||
|
if (!this.expandedKeys.find(el => el === key)) {
|
||||||
|
this.expandedKeys.push(key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 高亮uuid
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
renderContent(h: Function, options: any) {
|
||||||
|
let {node, data, store} = options;
|
||||||
|
return h('span', {class:''}, data.name)
|
||||||
|
// return(<span>1111</span>)
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMsgListInfo(eventData: Array<TreeData>) {
|
_onMsgListInfo(eventData: Array<TreeData>) {
|
||||||
|
@ -3,7 +3,7 @@ import {
|
|||||||
ArrayData,
|
ArrayData,
|
||||||
BoolData,
|
BoolData,
|
||||||
ColorData,
|
ColorData,
|
||||||
DataType,
|
DataType, EngineData,
|
||||||
Group, ImageData,
|
Group, ImageData,
|
||||||
Info,
|
Info,
|
||||||
NullOrUndefinedData,
|
NullOrUndefinedData,
|
||||||
@ -305,12 +305,24 @@ class CCInspector {
|
|||||||
path: path,
|
path: path,
|
||||||
value: propertyValue,
|
value: propertyValue,
|
||||||
}))
|
}))
|
||||||
!info && (info = this._buildObjectOrArrayData({
|
if (!info) {
|
||||||
data: new ObjectData(),
|
if (typeof propertyValue === "object") {
|
||||||
path: path,
|
let ctorName = propertyValue.constructor.name;
|
||||||
value: propertyValue,
|
if (ctorName.startsWith('cc_')) {
|
||||||
keys: Object.keys(propertyValue),
|
info = new EngineData();
|
||||||
}));
|
info.engineType = ctorName;
|
||||||
|
info.engineName=propertyValue.name;
|
||||||
|
info.engineUUID=propertyValue.uuid;
|
||||||
|
} else {
|
||||||
|
info = this._buildObjectOrArrayData({
|
||||||
|
data: new ObjectData(),
|
||||||
|
path: path,
|
||||||
|
value: propertyValue,
|
||||||
|
keys: Object.keys(propertyValue),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,14 @@
|
|||||||
<el-button @click="onShowValueInConsole">log</el-button>
|
<el-button @click="onShowValueInConsole">log</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="isEngine()" class="engine">
|
||||||
|
<div class="head">
|
||||||
|
<i class="icon" :class="getEngineTypeIcon()"></i>
|
||||||
|
<div class="type">{{ value.engineType }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="name">{{ value.engineName }}</div>
|
||||||
|
<el-button @click="onPlaceInTree" type="primary" icon="el-icon-place"></el-button>
|
||||||
|
</div>
|
||||||
<div class="slot">
|
<div class="slot">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
@ -109,14 +117,14 @@
|
|||||||
|
|
||||||
import Vue from "vue"
|
import Vue from "vue"
|
||||||
import {Component, Prop} from "vue-property-decorator"
|
import {Component, Prop} from "vue-property-decorator"
|
||||||
import {DataType, Info} from './data'
|
import {DataType, Info, EngineData} from './data'
|
||||||
import {connectBackground} from "@/devtools/connectBackground";
|
import {connectBackground} from "@/devtools/connectBackground";
|
||||||
import {Msg} from "@/core/types";
|
import {Msg} from "@/core/types";
|
||||||
|
import Bus, {BusMsg} from './bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {}
|
components: {}
|
||||||
})
|
})
|
||||||
// todo 支持array
|
|
||||||
export default class UiProp extends Vue {
|
export default class UiProp extends Vue {
|
||||||
@Prop({default: ""})
|
@Prop({default: ""})
|
||||||
name: string | undefined;
|
name: string | undefined;
|
||||||
@ -178,9 +186,33 @@ export default class UiProp extends Vue {
|
|||||||
return this.value && (this.value.type === DataType.Image)
|
return this.value && (this.value.type === DataType.Image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEngine() {
|
||||||
|
return this.value && (this.value.type === DataType.Engine)
|
||||||
|
}
|
||||||
|
|
||||||
|
onPlaceInTree() {
|
||||||
|
Bus.$emit(BusMsg.ShowPlace, this.value);
|
||||||
|
}
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getEngineTypeIcon() {
|
||||||
|
const value = this.value as EngineData;
|
||||||
|
switch (value.engineType) {
|
||||||
|
case 'cc_Sprite': {
|
||||||
|
return 'el-icon-picture-outline';
|
||||||
|
}
|
||||||
|
case 'cc_Label': {
|
||||||
|
return 'el-icon-third-text';
|
||||||
|
}
|
||||||
|
case 'cc_Node': {
|
||||||
|
return 'el-icon-third-node'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'el-icon-third-unknow';
|
||||||
|
}
|
||||||
|
|
||||||
getName(isArray: boolean, arr: UiProp) {
|
getName(isArray: boolean, arr: UiProp) {
|
||||||
const type = arr.value.type;
|
const type = arr.value.type;
|
||||||
if (isArray) {
|
if (isArray) {
|
||||||
@ -325,6 +357,48 @@ export default class UiProp extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.engine {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
border: solid #409EFF 1px;
|
||||||
|
border-radius: 5px;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
|
||||||
|
.head {
|
||||||
|
background-color: cornflowerblue;
|
||||||
|
height: 28px;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
font-size: 20px;
|
||||||
|
width: 20px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type {
|
||||||
|
display: flex;
|
||||||
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.name {
|
||||||
|
flex: 1;
|
||||||
|
height: 28px;
|
||||||
|
padding-left: 5px;
|
||||||
|
background-color: gold;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.vec {
|
.vec {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user