mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-19 16:38:41 +00:00
修复没有off带来的问题
This commit is contained in:
parent
8d5b8240cc
commit
1000b60f20
@ -9,6 +9,7 @@ export enum BusMsg {
|
||||
* 开关定时器,方便测试
|
||||
*/
|
||||
EnableSchedule = "EnableSchedule",
|
||||
SelectNode = "SelectNode",
|
||||
}
|
||||
|
||||
export const Bus = new TinyEmitter();
|
||||
|
@ -14,7 +14,7 @@
|
||||
import ccui from "@xuyanfeng/cc-ui";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { defineComponent, nextTick, onMounted, onUnmounted, ref, toRaw, watch } from "vue";
|
||||
import { Msg, PluginEvent, RequestNodeInfoData, RequestTreeInfoData, ResponseSetPropertyData } from "../../core/types";
|
||||
import { Msg, PluginEvent, RequestTreeInfoData, ResponseSetPropertyData } from "../../core/types";
|
||||
import { bridge } from "./bridge";
|
||||
import { Bus, BusMsg } from "./bus";
|
||||
import { EngineData, TreeData } from "./data";
|
||||
@ -26,24 +26,28 @@ export default defineComponent({
|
||||
components: { CCButtonGroup, CCInput, CCTree, CCDock },
|
||||
setup() {
|
||||
onMounted(() => {});
|
||||
Bus.on(BusMsg.ShowPlace, (data: EngineData) => {
|
||||
const funcShowPlace = (data: EngineData) => {
|
||||
console.log(toRaw(data));
|
||||
_expand(data.engineUUID);
|
||||
});
|
||||
Bus.on(BusMsg.EnableSchedule, (b: boolean) => {
|
||||
};
|
||||
const funcEnableSchedule = (b: boolean) => {
|
||||
if (b) {
|
||||
timer.create();
|
||||
} else {
|
||||
timer.clean();
|
||||
}
|
||||
});
|
||||
};
|
||||
const timer: Timer = new Timer(() => {
|
||||
updateTree();
|
||||
});
|
||||
onMounted(() => {
|
||||
Bus.on(BusMsg.ShowPlace, funcShowPlace);
|
||||
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer.create();
|
||||
});
|
||||
onUnmounted(() => {
|
||||
Bus.off(BusMsg.ShowPlace, funcShowPlace);
|
||||
Bus.off(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer.clean();
|
||||
});
|
||||
function _expand(uuid: string) {
|
||||
@ -93,11 +97,6 @@ export default defineComponent({
|
||||
const matchCase = ref<boolean>(false);
|
||||
const elTree = ref<typeof CCTree>();
|
||||
const treeData = ref<TreeData[]>([]);
|
||||
function updateNodeInfo() {
|
||||
if (selectedUUID) {
|
||||
bridge.send(Msg.RequestNodeInfo, { uuid: selectedUUID } as RequestNodeInfoData);
|
||||
}
|
||||
}
|
||||
let selectedUUID: string | null = null;
|
||||
bridge.on(Msg.ResponseTreeInfo, (event: PluginEvent) => {
|
||||
let data: Array<TreeData> = event.data;
|
||||
@ -139,6 +138,10 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
const expandedKeys = ref<Array<string>>([]);
|
||||
function updateSelect(uuid: string | null) {
|
||||
selectedUUID = uuid;
|
||||
Bus.emit(BusMsg.SelectNode, uuid);
|
||||
}
|
||||
return {
|
||||
expandedKeys,
|
||||
elTree,
|
||||
@ -147,14 +150,13 @@ export default defineComponent({
|
||||
matchCase,
|
||||
frameID,
|
||||
handleNodeUnclick() {
|
||||
selectedUUID = null;
|
||||
updateSelect(null);
|
||||
},
|
||||
handleNodeClick(data: TreeData | null) {
|
||||
if (data) {
|
||||
selectedUUID = data.id;
|
||||
updateNodeInfo();
|
||||
updateSelect(data.id);
|
||||
} else {
|
||||
selectedUUID = null;
|
||||
updateSelect(null);
|
||||
}
|
||||
},
|
||||
onNodeExpand(data: TreeData) {
|
||||
|
@ -60,9 +60,11 @@ export default defineComponent({
|
||||
checkSupport();
|
||||
});
|
||||
onMounted(() => {
|
||||
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer.create();
|
||||
});
|
||||
onUnmounted(() => {
|
||||
Bus.off(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer.clean();
|
||||
});
|
||||
// 问题:没有上下文的权限,只能操作DOM
|
||||
@ -82,13 +84,13 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
}
|
||||
Bus.on(BusMsg.EnableSchedule, (b: boolean) => {
|
||||
const funcEnableSchedule = (b: boolean) => {
|
||||
if (b) {
|
||||
timer.create();
|
||||
} else {
|
||||
timer.clean();
|
||||
}
|
||||
});
|
||||
};
|
||||
bridge.on(Msg.ResponseTreeInfo, (event: PluginEvent) => {
|
||||
let data: Array<TreeData> = event.data;
|
||||
isShowDebug.value = true;
|
||||
|
@ -7,17 +7,50 @@
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import ccui from "@xuyanfeng/cc-ui";
|
||||
import { defineComponent, ref } from "vue";
|
||||
import { Msg, PluginEvent, RequestObjectData, ResponseObjectData, ResponseSupportData } from "../../core/types";
|
||||
import { defineComponent, onMounted, onUnmounted, ref } from "vue";
|
||||
import { Msg, PluginEvent, RequestNodeInfoData, RequestObjectData, ResponseObjectData, ResponseSupportData } from "../../core/types";
|
||||
import { bridge } from "./bridge";
|
||||
import { Bus, BusMsg } from "./bus";
|
||||
import { NodeInfoData, ObjectData } from "./data";
|
||||
import { Timer } from "./timer";
|
||||
import Properties from "./ui/propertys.vue";
|
||||
const { CCDock } = ccui.components;
|
||||
export default defineComponent({
|
||||
components: { Properties, CCDock },
|
||||
setup() {
|
||||
function updateNodeInfo() {
|
||||
if (selectedUUID) {
|
||||
console.log(`update node info: ${selectedUUID}`);
|
||||
bridge.send(Msg.RequestNodeInfo, { uuid: selectedUUID } as RequestNodeInfoData);
|
||||
} else {
|
||||
// TODO: 需要检查当前的这个节点是否有效
|
||||
treeItemData.value = null;
|
||||
}
|
||||
}
|
||||
const timer = new Timer(updateNodeInfo);
|
||||
const treeItemData = ref<NodeInfoData | null>(null);
|
||||
const funcEnableSchedule = (b: boolean) => {
|
||||
if (b) {
|
||||
timer.create();
|
||||
} else {
|
||||
timer.clean();
|
||||
}
|
||||
};
|
||||
let selectedUUID: string | null = null;
|
||||
const funSelectNode = (uuid: string | null) => {
|
||||
selectedUUID = uuid;
|
||||
updateNodeInfo();
|
||||
};
|
||||
onMounted(() => {
|
||||
Bus.on(BusMsg.SelectNode, funSelectNode);
|
||||
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer.create();
|
||||
});
|
||||
onUnmounted(() => {
|
||||
Bus.off(BusMsg.SelectNode, funSelectNode);
|
||||
Bus.off(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer.clean();
|
||||
});
|
||||
bridge.on(Msg.ResponseSupport, (event: PluginEvent) => {
|
||||
let data: ResponseSupportData = event.data;
|
||||
const isCocosGame: boolean = data.support;
|
||||
@ -41,7 +74,6 @@ export default defineComponent({
|
||||
* 请求属性的列表,如果一个属性请求失败,会阻断后续的相同请求,因为都已经失败了,就没必要再响应请求了
|
||||
*/
|
||||
const requestList: Array<{ id: string; cb: Function }> = [];
|
||||
|
||||
bridge.on(Msg.ResponseObjectItemData, (event: PluginEvent) => {
|
||||
const requestData: ResponseObjectData = event.data;
|
||||
if (requestData.id !== null) {
|
||||
@ -59,8 +91,6 @@ export default defineComponent({
|
||||
requestList.push({ id: data.id, cb });
|
||||
bridge.send(Msg.RequestObjectItemData, data as RequestObjectData);
|
||||
});
|
||||
// TODO: 需要检查当前的这个节点是否有效
|
||||
// treeItemData.value = null;
|
||||
return {
|
||||
treeItemData,
|
||||
};
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import ccui from "@xuyanfeng/cc-ui";
|
||||
import { defineComponent, PropType, ref, toRaw, watch } from "vue";
|
||||
import { defineComponent, onMounted, onUnmounted, PropType, ref, toRaw, watch } from "vue";
|
||||
import { Msg, RequestLogData } from "../../../core/types";
|
||||
import { bridge } from "../bridge";
|
||||
import { Bus, BusMsg } from "../bus";
|
||||
@ -23,16 +23,7 @@ import UiProp from "./ui-prop.vue";
|
||||
const { CCInput, CCSection, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor } = ccui.components;
|
||||
export default defineComponent({
|
||||
name: "property-group",
|
||||
components: {
|
||||
UiProp,
|
||||
CCSection,
|
||||
CCInput,
|
||||
CCButton,
|
||||
CCInputNumber,
|
||||
CCSelect,
|
||||
CCCheckBox,
|
||||
CCColor,
|
||||
},
|
||||
components: { UiProp, CCSection, CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor },
|
||||
props: {
|
||||
group: {
|
||||
type: Object as PropType<Group>,
|
||||
@ -42,8 +33,14 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
setup(props, context) {
|
||||
Bus.on(BusMsg.FoldAllGroup, (b: boolean) => {
|
||||
const funcFoldAllGroup = (b: boolean) => {
|
||||
fold.value = b;
|
||||
};
|
||||
onMounted(() => {
|
||||
Bus.on(BusMsg.FoldAllGroup, funcFoldAllGroup);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
Bus.off(BusMsg.FoldAllGroup, funcFoldAllGroup);
|
||||
});
|
||||
const fold = ref(false);
|
||||
watch(
|
||||
|
Loading…
x
Reference in New Issue
Block a user