From 625b6d6ee95b15d13f4511c5693f52831ad96f87 Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Thu, 12 Dec 2024 20:13:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0tree=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cc-inspector/.vscode/settings.json | 6 +- cc-inspector/src/scripts/background.ts | 9 +- cc-inspector/src/views/devtools/index.vue | 118 +++++++----------- .../src/views/devtools/test/server.ts | 1 + cc-inspector/src/views/devtools/test/test.vue | 13 +- 5 files changed, 62 insertions(+), 85 deletions(-) diff --git a/cc-inspector/.vscode/settings.json b/cc-inspector/.vscode/settings.json index afb2c78..89b2b75 100644 --- a/cc-inspector/.vscode/settings.json +++ b/cc-inspector/.vscode/settings.json @@ -5,8 +5,8 @@ "[typescript]": { "editor.tabSize": 2, "editor.formatOnSave": true, - "prettier.printWidth": 1800, - "editor.defaultFormatter": "vscode.typescript-language-features" + "editor.defaultFormatter": "vscode.typescript-language-features", + "prettier.printWidth": 1000 }, "[json]": { "editor.quickSuggestions": { @@ -18,7 +18,7 @@ "[vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.tabSize": 2, - "prettier.printWidth": 800 + "prettier.printWidth": 1000 }, "files.refactoring.autoSave": false, "search.exclude": { diff --git a/cc-inspector/src/scripts/background.ts b/cc-inspector/src/scripts/background.ts index 0e12fca..46db5a7 100644 --- a/cc-inspector/src/scripts/background.ts +++ b/cc-inspector/src/scripts/background.ts @@ -60,18 +60,13 @@ class PortMan { } _updateFrames() { - let data: FrameDetails[] = this.content.map((item) => { + const data: FrameDetails[] = this.content.map((item) => { return { url: item.sender?.url || "", frameID: item.sender?.frameId || 0, }; }); - let event = new PluginEvent( - Page.Background, - Page.Devtools, - Msg.UpdateFrames, - data - ); + const event = new PluginEvent(Page.Background, Page.Devtools, Msg.UpdateFrames, data); this.sendDevtoolMsg(event); } diff --git a/cc-inspector/src/views/devtools/index.vue b/cc-inspector/src/views/devtools/index.vue index 9dc95b0..aca3d88 100644 --- a/cc-inspector/src/views/devtools/index.vue +++ b/cc-inspector/src/views/devtools/index.vue @@ -3,7 +3,7 @@
inspect target:
- +
@@ -14,40 +14,15 @@
-
Node Tree
+
Node Tree
- + -
- - -
+
@@ -55,10 +30,8 @@
- No games created by cocos creator found! - - - + no games created by cocos creator found! +
@@ -213,7 +186,6 @@ export default defineComponent({ updateNodeInfo(); nextTick(() => { if (elTree.value) { - //@ts-ignore elTree.value.setCurrentKey(selectedUUID); } }); @@ -455,6 +427,7 @@ export default defineComponent({ selectedUUID = data.id; updateNodeInfo(); }, + // TODO: 暂时这个版本先不实现 filterNode(value: any, data: any) { if (!value) { return true; @@ -477,16 +450,18 @@ export default defineComponent({ onChangeFrame, onNodeExpand(data: TreeData) { - if (data.hasOwnProperty("uuid") && data.id) { + if (data.id) { expandedKeys.value.push(data.id); } }, onNodeCollapse(data: TreeData) { - if (data.hasOwnProperty("uuid")) { - let index = expandedKeys.value.findIndex((el) => el === data.id); + if (data.id) { + const keys = toRaw(expandedKeys.value); + const index = keys.findIndex((el) => el === data.id); if (index !== -1) { - expandedKeys.value.splice(index, 1); + keys.splice(index, 1); } + expandedKeys.value = keys; } }, }; @@ -503,15 +478,20 @@ export default defineComponent({ overflow: hidden; background-color: #5c5c5c; color: white; + .head { display: flex; flex-direction: row; align-items: center; - padding: 1px 0; + padding: 2px 0; border-bottom: solid 1px grey; .label { + color: white; + font-size: 12px; margin: 0 3px; + margin-right: 5px; + user-select: none; } } @@ -521,9 +501,27 @@ export default defineComponent({ flex-direction: row; align-items: center; justify-content: center; + user-select: none; span { margin-right: 20px; + color: white; + font-size: 20px; + user-select: none; + } + + .fresh { + cursor: pointer; + color: white; + font-size: 20px; + + &:hover { + color: #cef57b; + } + + &:active { + color: #ffaa00; + } } } @@ -544,6 +542,14 @@ export default defineComponent({ flex-direction: row; align-items: center; justify-content: center; + + .text { + padding-left: 5px; + flex: 1; + user-select: none; + font-size: 12px; + color: white; + } } .matchCase { @@ -554,40 +560,6 @@ export default defineComponent({ align-items: center; justify-content: center; } - - .treeList { - margin-top: 3px; - height: 100%; - border-radius: 4px; - min-height: 20px; - overflow: auto; - width: 100%; - - .leaf { - width: 100%; - } - - .leaf-show { - color: black; - } - - .leaf-hide { - color: #c7bbbb; - text-decoration: line-through; - } - - &::-webkit-scrollbar { - width: 6px; - height: 6px; - background: #999; - border-radius: 2px; - } - - &::-webkit-scrollbar-thumb { - background-color: #333; - border-radius: 2px; - } - } } .right { diff --git a/cc-inspector/src/views/devtools/test/server.ts b/cc-inspector/src/views/devtools/test/server.ts index 495611d..93019ae 100644 --- a/cc-inspector/src/views/devtools/test/server.ts +++ b/cc-inspector/src/views/devtools/test/server.ts @@ -107,6 +107,7 @@ export class TestServer { .buildProperty("un_known", new EngineData().init('name', 'un_known', 'uuid')) const c = this.testData.buildChild("str1") + c.active = false; c.buildComponent("group51").buildProperty("str1", new StringData("str1")) c.buildComponent("group52").buildProperty("num", new NumberData(200)) diff --git a/cc-inspector/src/views/devtools/test/test.vue b/cc-inspector/src/views/devtools/test/test.vue index 90e787a..37b1532 100644 --- a/cc-inspector/src/views/devtools/test/test.vue +++ b/cc-inspector/src/views/devtools/test/test.vue @@ -4,6 +4,7 @@ Has CocosGame No CocosGame init tree data + test frame @@ -13,8 +14,8 @@ import { ITreeData } from "@xuyanfeng/cc-ui/types/cc-tree/const"; import { defineComponent, ref } from "vue"; import { Msg, Page, PluginEvent } from "../../../core/types"; import { connectBackground } from "../connectBackground"; -import { TreeData } from "../data"; -import { TestServer } from "./server"; +import { FrameDetails, TreeData } from "../data"; +import { testServer, TestServer } from "./server"; const { CCButton, CCSection } = ccui.components; export default defineComponent({ name: "test", @@ -43,6 +44,14 @@ export default defineComponent({ const event = new PluginEvent(Page.Inject, Page.Devtools, Msg.TreeInfo, data); connectBackground.doCallback(event); }, + onFrames() { + const data: FrameDetails[] = [ + { url: "url1", frameID: 1 }, + { url: "url2", frameID: 2 }, + ]; + const event = new PluginEvent(Page.Background, Page.Devtools, Msg.UpdateFrames, data); + testServer.send(event); + }, }; }, });