mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-20 08:58:41 +00:00
完善节点树刷新后,尽量保持原有的状态
This commit is contained in:
parent
ec8c00ea8f
commit
af69e1ecda
@ -17,11 +17,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="treeList">
|
<div class="treeList">
|
||||||
<el-tree :data="treeData"
|
<el-tree :data="treeData"
|
||||||
|
ref="tree"
|
||||||
style="display: inline-block;"
|
style="display: inline-block;"
|
||||||
:props="defaultProps"
|
:props="defaultProps"
|
||||||
:highlight-current="true"
|
:highlight-current="true"
|
||||||
:default-expand-all="false"
|
:default-expand-all="false"
|
||||||
:expand-on-click-node="true"
|
:default-expanded-keys="expandedKeys"
|
||||||
|
:expand-on-click-node="false"
|
||||||
|
node-key="uuid"
|
||||||
|
@node-expand="onNodeExpand"
|
||||||
|
@node-collapse="onNodeCollapse"
|
||||||
@node-click="handleNodeClick"></el-tree>
|
@node-click="handleNodeClick"></el-tree>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -43,6 +48,7 @@ import SceneProperty from "@/devtools/ccType/SceneProperty.vue";
|
|||||||
import ComponentsProperty from "@/devtools/ccType/ComponentsProperty.vue";
|
import ComponentsProperty from "@/devtools/ccType/ComponentsProperty.vue";
|
||||||
import NodeBaseProperty from "@/devtools/ccType/NodeBaseProperty.vue";
|
import NodeBaseProperty from "@/devtools/ccType/NodeBaseProperty.vue";
|
||||||
import {DataType, testData} from "./data"
|
import {DataType, testData} from "./data"
|
||||||
|
import {NodeData} from "@/devtools/type";
|
||||||
|
|
||||||
const PluginMsg = require("../core/plugin-msg");
|
const PluginMsg = require("../core/plugin-msg");
|
||||||
@Component({
|
@Component({
|
||||||
@ -53,8 +59,10 @@ const PluginMsg = require("../core/plugin-msg");
|
|||||||
export default class Index extends Vue {
|
export default class Index extends Vue {
|
||||||
private isShowDebug: boolean = false;
|
private isShowDebug: boolean = false;
|
||||||
treeItemData: Array<Record<string, any>> = [];
|
treeItemData: Array<Record<string, any>> = [];
|
||||||
treeData: Array<Record<string, any>> = []
|
treeData: Array<NodeData> = []
|
||||||
bgConn: chrome.runtime.Port | null = null// 与background.js的链接
|
bgConn: chrome.runtime.Port | null = null// 与background.js的链接
|
||||||
|
expandedKeys: Array<string> = [];
|
||||||
|
selectedUUID: string | null = null;
|
||||||
|
|
||||||
// el-tree的渲染key
|
// el-tree的渲染key
|
||||||
defaultProps = {
|
defaultProps = {
|
||||||
@ -89,7 +97,7 @@ export default class Index extends Vue {
|
|||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let eventData = data.data;
|
let eventData: Array<NodeData> = data.data;
|
||||||
let eventMsg = data.msg;
|
let eventMsg = data.msg;
|
||||||
if (eventMsg === PluginMsg.Msg.ListInfo) {
|
if (eventMsg === PluginMsg.Msg.ListInfo) {
|
||||||
this.isShowDebug = true;
|
this.isShowDebug = true;
|
||||||
@ -97,6 +105,12 @@ export default class Index extends Vue {
|
|||||||
eventData = [eventData]
|
eventData = [eventData]
|
||||||
}
|
}
|
||||||
this.treeData = eventData;
|
this.treeData = eventData;
|
||||||
|
if (this.selectedUUID) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.tree.setCurrentKey(this.selectedUUID);
|
||||||
|
// todo 需要重新获取下node的数据
|
||||||
|
})
|
||||||
|
}
|
||||||
} else if (eventMsg === PluginMsg.Msg.Support) {
|
} else if (eventMsg === PluginMsg.Msg.Support) {
|
||||||
this.isShowDebug = eventData.support;
|
this.isShowDebug = eventData.support;
|
||||||
} else if (eventMsg === PluginMsg.Msg.NodeInfo) {
|
} else if (eventMsg === PluginMsg.Msg.NodeInfo) {
|
||||||
@ -119,7 +133,8 @@ export default class Index extends Vue {
|
|||||||
this.treeItemData = testData;
|
this.treeItemData = testData;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleNodeClick(data: any) {
|
handleNodeClick(data: NodeData) {
|
||||||
|
this.selectedUUID = data.uuid;
|
||||||
// todo 去获取节点信息
|
// todo 去获取节点信息
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
let uuid = data.uuid;
|
let uuid = data.uuid;
|
||||||
@ -183,6 +198,20 @@ export default class Index extends Vue {
|
|||||||
this.evalInspectorFunction("onMemoryInfo");
|
this.evalInspectorFunction("onMemoryInfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onNodeExpand(data: NodeData, a, b) {
|
||||||
|
if (data.hasOwnProperty('uuid')) {
|
||||||
|
this.expandedKeys.push(data.uuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onNodeCollapse(data: NodeData) {
|
||||||
|
if (data.hasOwnProperty('uuid')) {
|
||||||
|
let index = this.expandedKeys.findIndex(el => el === data.uuid);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.expandedKeys.splice(index, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -258,6 +287,7 @@ export default class Index extends Vue {
|
|||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
height: 6px;
|
height: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-webkit-scrollbar-thumb {
|
&::-webkit-scrollbar-thumb {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
|
5
source/src/devtools/type.ts
Normal file
5
source/src/devtools/type.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export class NodeData {
|
||||||
|
uuid: string | null = null;
|
||||||
|
name: string = '';
|
||||||
|
children: Array<NodeData> = []
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user