mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-20 08:58:41 +00:00
修复另外一个devtools定时器会干扰刷新逻辑的bug
This commit is contained in:
parent
12ddbf8ac9
commit
36a380695a
4
cc-inspector/src/views/devtools/const.ts
Normal file
4
cc-inspector/src/views/devtools/const.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export const PanelMsg = {
|
||||
Show: "Show",
|
||||
Hide: "Hide",
|
||||
};
|
@ -39,14 +39,15 @@ export default defineComponent({
|
||||
};
|
||||
const funcEnableSchedule = (b: boolean) => {
|
||||
if (b) {
|
||||
timer_hierarchy.create();
|
||||
timer.create();
|
||||
} else {
|
||||
timer_hierarchy.clean();
|
||||
timer.clean();
|
||||
}
|
||||
};
|
||||
const timer_hierarchy: Timer = new Timer(() => {
|
||||
const timer: Timer = new Timer(() => {
|
||||
updateTree();
|
||||
});
|
||||
timer.name = "hierarchy";
|
||||
let ins: MousetrapInstance | null = null;
|
||||
function onQuickVisible() {
|
||||
ga.fireEvent(GA_EventName.SpaceVisible);
|
||||
@ -68,7 +69,7 @@ export default defineComponent({
|
||||
Bus.on(BusMsg.ChangeContent, changeContent);
|
||||
Bus.on(BusMsg.ShowPlace, funcShowPlace);
|
||||
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer_hierarchy.create();
|
||||
timer.create(true);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
if (ins) {
|
||||
@ -77,7 +78,7 @@ export default defineComponent({
|
||||
Bus.off(BusMsg.ChangeContent, changeContent);
|
||||
Bus.off(BusMsg.ShowPlace, funcShowPlace);
|
||||
Bus.off(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer_hierarchy.clean();
|
||||
timer.clean();
|
||||
});
|
||||
function _expand(uuid: string) {
|
||||
if (elTree.value) {
|
||||
@ -218,13 +219,13 @@ export default defineComponent({
|
||||
menus.push({
|
||||
name: "fresh auto",
|
||||
callback: () => {
|
||||
timer_hierarchy.create();
|
||||
timer.create();
|
||||
},
|
||||
});
|
||||
menus.push({
|
||||
name: "fresh manual",
|
||||
callback: () => {
|
||||
timer_hierarchy.clean();
|
||||
timer.clean();
|
||||
},
|
||||
});
|
||||
menus.push({
|
||||
|
@ -7,10 +7,14 @@ import { createApp } from "vue";
|
||||
import pluginConfig from "../../../cc-plugin.config";
|
||||
import "../global.less";
|
||||
import App from "./index.vue";
|
||||
import { init } from "./register-panel";
|
||||
export default CCP.init(pluginConfig, {
|
||||
ready: function (rootElement: any, args: any) {
|
||||
init();
|
||||
if (args && args.body) {
|
||||
ccui.uiElement.setBody(args.body);
|
||||
}
|
||||
if (args && args.doc) {
|
||||
ccui.uiElement.setDoc(args.doc);
|
||||
}
|
||||
const app = createApp(App);
|
||||
app.use(ccui);
|
||||
app.use(createPinia());
|
||||
|
@ -63,6 +63,7 @@ export default defineComponent({
|
||||
const timer = new Timer(() => {
|
||||
checkSupport();
|
||||
});
|
||||
timer.name = "devtools";
|
||||
onMounted(() => {
|
||||
ccui.footbar.showTipsArray({
|
||||
tips: [
|
||||
@ -92,7 +93,7 @@ export default defineComponent({
|
||||
},
|
||||
});
|
||||
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer.create();
|
||||
timer.create(true);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
Bus.off(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
|
@ -12,13 +12,13 @@ import ccui from "@xuyanfeng/cc-ui";
|
||||
import { IUiMenuItem } from "@xuyanfeng/cc-ui/types/cc-menu/const";
|
||||
import { defineComponent, onMounted, onUnmounted, ref } from "vue";
|
||||
import { Msg, PluginEvent, RequestNodeInfoData, ResponseSupportData } from "../../core/types";
|
||||
import { ga } from "../../ga";
|
||||
import { GA_EventName } from "../../ga/type";
|
||||
import { bridge } from "./bridge";
|
||||
import { Bus, BusMsg } from "./bus";
|
||||
import { NodeInfoData } from "./data";
|
||||
import { Timer } from "./timer";
|
||||
import Properties from "./ui/propertys.vue";
|
||||
import { ga } from "../../ga";
|
||||
import { GA_EventName } from "../../ga/type";
|
||||
const { CCDock } = ccui.components;
|
||||
export default defineComponent({
|
||||
components: { Properties, CCDock },
|
||||
@ -32,6 +32,7 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
const timer = new Timer(updateNodeInfo);
|
||||
timer.name = "inspector";
|
||||
const treeItemData = ref<NodeInfoData | null>(null);
|
||||
const funcEnableSchedule = (b: boolean) => {
|
||||
if (b) {
|
||||
@ -54,7 +55,7 @@ export default defineComponent({
|
||||
Bus.on(BusMsg.ChangeContent, changeContent);
|
||||
Bus.on(BusMsg.SelectNode, funSelectNode);
|
||||
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
|
||||
timer.create();
|
||||
timer.create(true);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
Bus.off(BusMsg.ChangeContent, changeContent);
|
||||
|
@ -1,34 +1,10 @@
|
||||
import CCP from "cc-plugin/src/ccp/entry-render";
|
||||
import { ChromeConst } from "cc-plugin/src/chrome/const";
|
||||
import { Msg, RequestSupportData } from "../../core/types";
|
||||
import { bridge } from "./bridge";
|
||||
|
||||
export function init() {
|
||||
if (chrome && chrome.devtools) {
|
||||
// 对应的是Elements面板的边栏
|
||||
chrome.devtools.panels.elements.createSidebarPane(CCP.manifest.name, function (sidebar) {
|
||||
sidebar.setObject({ some_data: "some data to show!" });
|
||||
});
|
||||
|
||||
// 创建devtools-panel
|
||||
let iconPath = "";
|
||||
const { icon } = CCP.manifest;
|
||||
if (icon && icon["48"]) {
|
||||
iconPath = icon["48"];
|
||||
}
|
||||
chrome.devtools.panels.create(CCP.manifest.name, iconPath, ChromeConst.html.devtools, (panel: chrome.devtools.panels.ExtensionPanel) => {
|
||||
console.log("[CC-Inspector] Dev Panel Created!");
|
||||
panel.onShown.addListener((window) => {
|
||||
// 面板显示,查询是否是cocos游戏
|
||||
bridge.send(Msg.RequestSupport, {} as RequestSupportData);
|
||||
});
|
||||
panel.onHidden.addListener(() => {
|
||||
// 面板隐藏
|
||||
console.log("panel hide");
|
||||
});
|
||||
panel.onSearch.addListener(function (action, query) {
|
||||
// ctrl+f 查找触发
|
||||
console.log("panel search!");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ import profile from "cc-plugin/src/ccp/profile";
|
||||
import { defineStore } from "pinia";
|
||||
import { ref, toRaw } from "vue";
|
||||
import pluginConfig from "../../../cc-plugin.config";
|
||||
import { PanelMsg } from "./const";
|
||||
export const enum RefreshType {
|
||||
Auto = "auto",
|
||||
Manual = "manual",
|
||||
@ -24,10 +25,19 @@ export class ConfigData {
|
||||
export const appStore = defineStore("app", () => {
|
||||
const config = ref<ConfigData>(new ConfigData());
|
||||
const frameID = ref<number>(0);
|
||||
const pageShow = ref<boolean>(false);
|
||||
return {
|
||||
frameID,
|
||||
pageShow,
|
||||
config,
|
||||
init() {
|
||||
if (chrome.devtools) {
|
||||
window.addEventListener(PanelMsg.Show, () => {
|
||||
pageShow.value = true;
|
||||
});
|
||||
} else {
|
||||
pageShow.value = true;
|
||||
}
|
||||
profile.init(new ConfigData(), pluginConfig);
|
||||
const data = profile.load(`${pluginConfig.manifest.name}.json`) as ConfigData;
|
||||
config.value.refreshType = data.refreshType || RefreshType.Manual;
|
||||
|
@ -1,16 +1,24 @@
|
||||
export class Timer {
|
||||
private timer: number = 0;
|
||||
private timer: number | null = null;
|
||||
private callback: Function | null = null;
|
||||
private duration: number = 0;
|
||||
public name: string = "";
|
||||
constructor(cb: Function = null, duration: number = 300) {
|
||||
this.callback = cb;
|
||||
this.duration = duration;
|
||||
}
|
||||
create() {
|
||||
create(rightNow: boolean = false) {
|
||||
this.clean();
|
||||
this.timer = setInterval(this.callback, this.duration);
|
||||
if (rightNow) {
|
||||
this.callback && this.callback();
|
||||
}
|
||||
}
|
||||
clean() {
|
||||
if (this.timer === null) {
|
||||
return;
|
||||
}
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user