From 6fc79973530b7b9ccfc4a5092354419a3bc391a1 Mon Sep 17 00:00:00 2001 From: xyf-mac Date: Sat, 30 Oct 2021 16:08:29 +0800 Subject: [PATCH] =?UTF-8?q?class=20name=20=E5=90=8D=E5=AD=97=E8=BF=87?= =?UTF-8?q?=E9=95=BF=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E7=9C=81=E7=95=A5?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E6=98=BE=E7=A4=BA=E5=85=A8=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 21 --------------- README.md | 2 +- meta.json | 20 -------------- source/src/devtools/inject.ts | 39 +++++++++++++++++++--------- source/src/devtools/propertys.vue | 1 + source/src/devtools/ui-prop.vue | 43 ++++++++++++++++++++----------- 6 files changed, 57 insertions(+), 69 deletions(-) delete mode 100644 LICENSE delete mode 100644 meta.json diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 250520e..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Zaporozhets Yura - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index af82871..2e93077 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #说明 -inject在development模式下无法正常使用,暂时的解决办法,注释掉`vue-cli-plugin-browser-extension`代码中的 +inject在development模式下无法正常使用,暂时的解决办法,注释掉`vue-cli-plugin-browser-extension/index.js`代码中的124行: ``` webpackConfig.plugin('extension-reloader').use(ExtensionReloader, [{ entries, ...extensionReloaderOptions }]) ``` diff --git a/meta.json b/meta.json deleted file mode 100644 index 13e1e78..0000000 --- a/meta.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "prompts": { - "name": { - "type": "string", - "required": true, - "label": "Project name" - }, - "description": { - "type": "string", - "required": true, - "label": "Project description", - "default": "A Vue.js project" - }, - "author": { - "type": "string", - "label": "Author" - } - }, - "completeMessage": "To get started:\n\n cd {{destDirName}}\n npm install # or yarn\n npm run dev # or yarn dev\n\n" -} diff --git a/source/src/devtools/inject.ts b/source/src/devtools/inject.ts index 679d71e..5b07f2f 100644 --- a/source/src/devtools/inject.ts +++ b/source/src/devtools/inject.ts @@ -15,7 +15,7 @@ import { Vec2Data, Vec3Data } from "./data"; -import {Msg, Page, PluginEvent} from '@/core/types' +import {Msg, Page, PluginEvent} from "@/core/types" // @ts-ignore typescript-eslint/no-namespace declare namespace cc { @@ -26,7 +26,7 @@ class CCInspector { inspectorGameMemoryStorage: Record = {} init() { - console.log('cc-inspector init ~~~'); + console.log("cc-inspector init ~~~"); let timer = setInterval(() => { if (this._isCocosGame()) { clearInterval(timer) @@ -44,7 +44,7 @@ class CCInspector { } let pluginEvent: PluginEvent = event.data; if (PluginEvent.check(pluginEvent, Page.Content, Page.Inject)) { - console.log(`%c[Inject] ${JSON.stringify(pluginEvent)}`, 'color:green;'); + console.log(`%c[Inject] ${JSON.stringify(pluginEvent)}`, "color:green;"); PluginEvent.finish(pluginEvent) switch (pluginEvent.msg) { case Msg.UrlChange: @@ -114,7 +114,7 @@ class CCInspector { if (!draw) { // @ts-ignore - let node = new cc.Node('draw-node'); + let node = new cc.Node("draw-node"); // @ts-ignore cc.director.getScene().addChild(node); // @ts-ignore @@ -123,7 +123,7 @@ class CCInspector { draw.clear() draw.lineWidth = 10; // @ts-ignore - draw.strokeColor = new cc.Color().fromHEX('#ff0000') + draw.strokeColor = new cc.Color().fromHEX("#ff0000") const {anchorX, anchorY, width, height, x, y} = node; let halfWidth = width / 2; let halfHeight = height / 2; @@ -192,7 +192,7 @@ class CCInspector { rotation: ["rotationX", "rotationY"], anchor: ["anchorX", "anchorY"], size: ["width", "height"], - skew: ['skewX', 'skewY'], + skew: ["skewX", "skewY"], position: ["x", "y", "z"], scale: ["scaleX", "scaleY", "scaleZ"], designResolution: ["width", "height"], // 这个比较特殊,在key下边,其他的都不是在key下 @@ -240,7 +240,7 @@ class CCInspector { const data: ImageData = options.data; const path: Array = options.path; if (ctor && value instanceof ctor) { - if (value.hasOwnProperty('_textureFilename')) { + if (value.hasOwnProperty("_textureFilename")) { data.path = path; //@ts-ignore data.data = `${window.location.origin}/${value._textureFilename}`; @@ -287,7 +287,7 @@ class CCInspector { ctor: cc.Vec3, path: path, data: new Vec3Data(), - keys: ['x', 'y', 'z'], + keys: ["x", "y", "z"], value: propertyValue, })) !info && (info = this._buildVecData({ @@ -295,7 +295,7 @@ class CCInspector { ctor: cc.Vec2, path: path, data: new Vec2Data(), - keys: ['x', 'y'], + keys: ["x", "y"], value: propertyValue })) !info && (info = this._buildImageData({ @@ -308,7 +308,7 @@ class CCInspector { if (!info) { if (typeof propertyValue === "object") { let ctorName = propertyValue.constructor.name; - if (ctorName.startsWith('cc_')) { + if (ctorName.startsWith("cc_")) { info = new EngineData(); info.engineType = ctorName; info.engineName = propertyValue.name; @@ -341,7 +341,7 @@ class CCInspector { let data: ObjectData | ArrayData = options.data; let keys: Array = options.keys; // 剔除_开头的属性 - keys = keys.filter(key => !key.toString().startsWith('_')); + keys = keys.filter(key => !key.toString().startsWith("_")); for (let i = 0; i < keys.length; i++) { let key = keys[i]; let propPath = path.concat(key.toString()); @@ -353,8 +353,23 @@ class CCInspector { return data; } + private getCompName(comp: any): string { + const nameKeys = [ + "__classname__", // 2.4.0 验证通过 + ]; + for (let i = 0; i < nameKeys.length; i++) { + let key = nameKeys[i]; + // 一般来说,这里的name是不会出现假值 + if (comp[key]) { + return comp[key]; + } + } + return comp.constructor.name; + } + _getGroupData(node: any) { - let nodeGroup = new Group(node.constructor.name); + const name = this.getCompName(node); + let nodeGroup = new Group(name); let keys = this._getNodeKeys(node); for (let i = 0; i < keys.length;) { let key = keys[i]; diff --git a/source/src/devtools/propertys.vue b/source/src/devtools/propertys.vue index bb070b6..54e393a 100644 --- a/source/src/devtools/propertys.vue +++ b/source/src/devtools/propertys.vue @@ -83,6 +83,7 @@ export default class properties extends Vue { user-select: none; cursor: pointer; border-bottom: 1px #6d6d6d solid; + background-color: #1da1f7; } .header:hover { diff --git a/source/src/devtools/ui-prop.vue b/source/src/devtools/ui-prop.vue index d21e6f2..87a84ae 100644 --- a/source/src/devtools/ui-prop.vue +++ b/source/src/devtools/ui-prop.vue @@ -10,7 +10,13 @@ :class="fold?'el-icon-caret-right':'el-icon-caret-bottom'" :style="{'visibility':isArrayOrObject()?'visible':'hidden','margin-left':indent*10+'px'}"> -
{{ name }}
+
+ +
{{ name }}
+ {{ name }} +
+
+