优化多个frame的inspect target的逻辑

This commit is contained in:
xu_yanfeng
2025-01-08 16:37:12 +08:00
parent 0c5279e8e2
commit a20b913e37
11 changed files with 52 additions and 62 deletions

View File

@@ -8,6 +8,7 @@ export enum BusMsg {
* 开关定时器,方便测试
*/
EnableSchedule = "EnableSchedule",
ChangeContent = "ChangeContent",
SelectNode = "SelectNode",
}

View File

@@ -25,10 +25,16 @@ export enum CompType {
Button = "cc.Button",
BlockInputEvents = "cc.BlockInputEvents",
Scene = "cc.Scene",
Animation = "cc.Animation",
}
export function getSimpleProperties(typeName: string): string[] {
const config = {};
config[CompType.Animation] = [
"defaultClip", //
"clips",
"playOnLoad",
];
config[CompType.Scene] = [
"autoReleaseAssets",
"position",

View File

@@ -16,7 +16,7 @@ import { IUiMenuItem } from "@xuyanfeng/cc-ui/types/cc-menu/const";
import Mousetrap, { MousetrapInstance } from "mousetrap";
import { storeToRefs } from "pinia";
import { defineComponent, nextTick, onMounted, onUnmounted, ref, toRaw, watch } from "vue";
import { Msg, PluginEvent, RequestTreeInfoData, ResponseSetPropertyData } from "../../core/types";
import { Msg, PluginEvent, RequestTreeInfoData, RequestUseFrameData, ResponseSetPropertyData } from "../../core/types";
import { bridge } from "./bridge";
import { Bus, BusMsg } from "./bus";
import { EngineData, TreeData } from "./data";
@@ -48,12 +48,17 @@ export default defineComponent({
bridge.send(Msg.RequestVisible, selectedUUID);
}
}
function changeContent(data: RequestUseFrameData) {
treeData.value = [];
selectedUUID = null;
}
onMounted(() => {
if (elTree.value) {
const el = toRaw(elTree.value);
ins = new Mousetrap(el.treeElement);
ins.bind(["space"], onQuickVisible, "keydown");
}
Bus.on(BusMsg.ChangeContent, changeContent);
Bus.on(BusMsg.ShowPlace, funcShowPlace);
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
timer.create();
@@ -62,6 +67,7 @@ export default defineComponent({
if (ins) {
ins.unbind(["space"], "keydown");
}
Bus.off(BusMsg.ChangeContent, changeContent);
Bus.off(BusMsg.ShowPlace, funcShowPlace);
Bus.off(BusMsg.EnableSchedule, funcEnableSchedule);
timer.clean();

View File

@@ -74,7 +74,9 @@ export default defineComponent({
const tabID = chrome.devtools.inspectedWindow.tabId;
chrome.scripting.executeScript({ files: ["js/execute.js"], target: { tabId: tabID } }, (results: chrome.scripting.InjectionResult[]) => {});
}
ccui.footbar.showTipsArray({
tips: ["press space in the hierarchy to quickly control the display and hiding of nodes"],
});
function _inspectedCode() {
let injectCode = "";
chrome.devtools.inspectedWindow.eval(injectCode, (result, isException) => {
@@ -120,12 +122,6 @@ export default defineComponent({
value: item.frameID,
};
});
// 第一次获取到frame配置后自动获取frame数据
if (frameID === null && iframes.value.length > 0 && !iframes.value.find((el) => el.value === frameID.value)) {
frameID.value = iframes[0].value;
onChangeFrame();
}
});
const memory = ref<{
@@ -148,6 +144,7 @@ export default defineComponent({
function onChangeFrame() {
const id = Number(toRaw(frameID.value));
bridge.send(Msg.RequestUseFrame, { id } as RequestUseFrameData);
Bus.emit(BusMsg.ChangeContent, { id } as RequestUseFrameData);
}
const elLeft = ref<HTMLDivElement>();
const version = ref(PluginConfig.manifest.version);

View File

@@ -26,7 +26,6 @@ export default defineComponent({
console.log(`update node info: ${selectedUUID}`);
bridge.send(Msg.RequestNodeInfo, { uuid: selectedUUID } as RequestNodeInfoData);
} else {
// TODO: 需要检查当前的这个节点是否有效
treeItemData.value = null;
}
}
@@ -44,12 +43,19 @@ export default defineComponent({
selectedUUID = uuid;
updateNodeInfo();
};
function changeContent() {
selectedUUID = null;
treeItemData.value = null;
}
onMounted(() => {
Bus.on(BusMsg.ChangeContent, changeContent);
Bus.on(BusMsg.SelectNode, funSelectNode);
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
timer.create();
});
onUnmounted(() => {
Bus.off(BusMsg.ChangeContent, changeContent);
Bus.off(BusMsg.SelectNode, funSelectNode);
Bus.off(BusMsg.EnableSchedule, funcEnableSchedule);
timer.clean();

View File

@@ -9,6 +9,7 @@
<script lang="ts">
import { defineComponent, PropType, toRaw } from "vue";
import { Bus, BusMsg } from "../bus";
import { CompType } from "../comp";
import { EngineData } from "../data";
export default defineComponent({
name: "property-engine",
@@ -25,18 +26,11 @@ export default defineComponent({
Bus.emit(BusMsg.ShowPlace, toRaw(props.data));
},
getEngineTypeIcon() {
switch (props.data.engineType) {
case "cc_Sprite": {
return "icon_picture";
}
case "cc_Label": {
return "icon_text";
}
case "cc_Node": {
return "icon_node";
}
}
return "icon_unknown";
const map = {};
map[CompType.Spirte] = "icon_picture";
map[CompType.Label] = "icon_text";
map[CompType.Node] = "icon_node";
return map[props.data.engineType] || "icon_unknown";
},
};
},

View File

@@ -75,8 +75,9 @@ export default defineComponent({
}
.url {
padding: 0 5px;
flex: 1;
color: white;
color: gray;
font-weight: normal;
font-size: 12px;
overflow: hidden;