2024-01-05 16:45:23 +08:00
|
|
|
|
<template>
|
2024-01-09 12:02:47 +08:00
|
|
|
|
<div id="devtools">
|
2025-01-07 17:52:21 +08:00
|
|
|
|
<Test v-if="false"> </Test>
|
2024-01-09 12:02:47 +08:00
|
|
|
|
<div class="head" v-show="iframes.length > 1">
|
|
|
|
|
<div class="label">inspect target:</div>
|
2024-12-12 20:13:50 +08:00
|
|
|
|
<CCSelect v-model:value="frameID" @change="onChangeFrame" :data="getFramesData()"> </CCSelect>
|
2024-01-09 12:02:47 +08:00
|
|
|
|
</div>
|
2024-12-28 14:25:23 +08:00
|
|
|
|
<div v-if="isShowDebug" class="find">
|
2024-12-27 21:08:26 +08:00
|
|
|
|
<Hierarchy></Hierarchy>
|
2024-01-23 22:25:32 +08:00
|
|
|
|
<CCDivider></CCDivider>
|
2024-12-27 21:08:26 +08:00
|
|
|
|
<Inspector></Inspector>
|
2024-01-09 12:02:47 +08:00
|
|
|
|
</div>
|
2024-12-27 19:51:51 +08:00
|
|
|
|
<Find v-if="!isShowDebug"></Find>
|
2024-12-09 19:25:06 +08:00
|
|
|
|
<CCDialog></CCDialog>
|
2024-12-28 16:24:16 +08:00
|
|
|
|
<CCMenu></CCMenu>
|
2024-12-09 19:25:06 +08:00
|
|
|
|
<CCFootBar :version="version"></CCFootBar>
|
2024-01-09 12:02:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
2024-01-09 15:33:34 +08:00
|
|
|
|
import ccui from "@xuyanfeng/cc-ui";
|
2024-12-09 16:23:58 +08:00
|
|
|
|
import { Option } from "@xuyanfeng/cc-ui/types/cc-select/const";
|
2024-12-27 14:23:27 +08:00
|
|
|
|
import { storeToRefs } from "pinia";
|
2024-12-28 14:25:23 +08:00
|
|
|
|
import { defineComponent, onMounted, onUnmounted, ref, toRaw } from "vue";
|
2024-12-09 19:25:06 +08:00
|
|
|
|
import PluginConfig from "../../../cc-plugin.config";
|
2025-01-10 15:22:32 +08:00
|
|
|
|
import { Msg, Page, PluginEvent, RequestUseFrameData, ResponseSupportData, ResponseUseFrameData } from "../../core/types";
|
|
|
|
|
import { ga } from "../../ga";
|
|
|
|
|
import { GA_Button } from "../../ga/type";
|
2024-12-24 21:09:13 +08:00
|
|
|
|
import { bridge } from "./bridge";
|
2024-12-27 21:08:26 +08:00
|
|
|
|
import { Bus, BusMsg } from "./bus";
|
|
|
|
|
import { FrameDetails, NodeInfoData, TreeData } from "./data";
|
2024-12-27 19:51:51 +08:00
|
|
|
|
import Find from "./find.vue";
|
2024-12-27 21:08:26 +08:00
|
|
|
|
import Hierarchy from "./hierarchy.vue";
|
|
|
|
|
import Inspector from "./inspector.vue";
|
|
|
|
|
import { appStore } from "./store";
|
2024-12-09 21:37:07 +08:00
|
|
|
|
import Test from "./test/test.vue";
|
2024-12-28 14:25:23 +08:00
|
|
|
|
import { Timer } from "./timer";
|
2024-12-10 10:34:27 +08:00
|
|
|
|
import Properties from "./ui/propertys.vue";
|
2024-12-09 16:23:58 +08:00
|
|
|
|
import SettingsVue from "./ui/settings.vue";
|
2024-12-28 14:25:23 +08:00
|
|
|
|
import { checkSupport } from "./util";
|
2024-12-28 16:24:16 +08:00
|
|
|
|
const { CCTree, CCFootBar, CCMenu, CCDialog, CCInput, CCButton, CCInputNumber, CCSelect, CCButtonGroup, CCCheckBox, CCColor, CCDivider } = ccui.components;
|
2024-01-09 15:33:34 +08:00
|
|
|
|
interface FrameInfo {
|
|
|
|
|
label: string;
|
|
|
|
|
value: number;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-09 12:02:47 +08:00
|
|
|
|
export default defineComponent({
|
2024-12-28 16:24:16 +08:00
|
|
|
|
components: { Find, Inspector, CCMenu, Hierarchy, Test, CCFootBar, CCDialog, CCTree, CCDivider, CCButtonGroup, Properties, SettingsVue, CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor },
|
2024-01-09 15:33:34 +08:00
|
|
|
|
name: "devtools",
|
|
|
|
|
props: {},
|
2024-01-09 12:02:47 +08:00
|
|
|
|
setup(props, ctx) {
|
2025-01-10 15:22:32 +08:00
|
|
|
|
ga.openView(Page.Devtools);
|
2024-12-09 19:25:06 +08:00
|
|
|
|
appStore().init();
|
2024-12-15 19:59:51 +08:00
|
|
|
|
const isShowDebug = ref<boolean>(false);
|
2024-01-09 15:33:34 +08:00
|
|
|
|
const iframes = ref<Array<FrameInfo>>([]);
|
2024-12-27 21:08:26 +08:00
|
|
|
|
const { config, frameID } = storeToRefs(appStore());
|
2025-01-17 09:57:11 +08:00
|
|
|
|
const timer = new Timer();
|
|
|
|
|
timer.onWork = () => {
|
2024-12-28 14:25:23 +08:00
|
|
|
|
checkSupport();
|
2025-01-17 09:57:11 +08:00
|
|
|
|
};
|
2025-01-15 14:38:53 +08:00
|
|
|
|
timer.name = "devtools";
|
2024-12-28 14:25:23 +08:00
|
|
|
|
onMounted(() => {
|
2025-01-08 16:38:43 +08:00
|
|
|
|
ccui.footbar.showTipsArray({
|
2025-01-08 17:51:18 +08:00
|
|
|
|
tips: [
|
|
|
|
|
"Press space in the hierarchy to quickly control the display and hiding of nodes", //
|
|
|
|
|
"If you encounter any problems during use, please feel free to contact me",
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
ccui.footbar.registerCmd({
|
|
|
|
|
icon: "github",
|
|
|
|
|
cb: () => {
|
|
|
|
|
window.open("https://github.com/tidys/cc-inspector-chrome");
|
2025-01-10 15:22:32 +08:00
|
|
|
|
ga.clickButton(GA_Button.Github);
|
2025-01-08 17:51:18 +08:00
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
ccui.footbar.registerCmd({
|
|
|
|
|
icon: "qq",
|
|
|
|
|
cb: () => {
|
|
|
|
|
window.open("https://jq.qq.com/?_wv=1027&k=5SdPdy2");
|
2025-01-10 15:22:32 +08:00
|
|
|
|
ga.clickButton(GA_Button.QQ);
|
2025-01-08 17:51:18 +08:00
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
ccui.footbar.registerCmd({
|
|
|
|
|
icon: "support",
|
|
|
|
|
cb: () => {
|
|
|
|
|
window.open("https://github.com/tidys/cc-inspector-chrome/issues");
|
2025-01-10 15:22:32 +08:00
|
|
|
|
ga.clickButton(GA_Button.Issues);
|
2025-01-08 17:51:18 +08:00
|
|
|
|
},
|
2025-01-08 16:38:43 +08:00
|
|
|
|
});
|
2024-12-28 15:05:05 +08:00
|
|
|
|
Bus.on(BusMsg.EnableSchedule, funcEnableSchedule);
|
2025-01-15 14:38:53 +08:00
|
|
|
|
timer.create(true);
|
2024-12-28 14:25:23 +08:00
|
|
|
|
});
|
|
|
|
|
onUnmounted(() => {
|
2024-12-28 15:05:05 +08:00
|
|
|
|
Bus.off(BusMsg.EnableSchedule, funcEnableSchedule);
|
2024-12-28 14:25:23 +08:00
|
|
|
|
timer.clean();
|
|
|
|
|
});
|
2024-01-09 12:02:47 +08:00
|
|
|
|
// 问题:没有上下文的权限,只能操作DOM
|
|
|
|
|
function _executeScript(para: Object) {
|
2024-02-26 09:07:01 +08:00
|
|
|
|
// chrome.tabs.executeScript()//v2版本使用的函数
|
|
|
|
|
const tabID = chrome.devtools.inspectedWindow.tabId;
|
|
|
|
|
chrome.scripting.executeScript({ files: ["js/execute.js"], target: { tabId: tabID } }, (results: chrome.scripting.InjectionResult[]) => {});
|
2024-01-09 12:02:47 +08:00
|
|
|
|
}
|
2025-01-08 16:38:43 +08:00
|
|
|
|
|
2024-12-28 15:05:05 +08:00
|
|
|
|
const funcEnableSchedule = (b: boolean) => {
|
2024-12-28 14:25:23 +08:00
|
|
|
|
if (b) {
|
|
|
|
|
timer.create();
|
|
|
|
|
} else {
|
|
|
|
|
timer.clean();
|
|
|
|
|
}
|
2024-12-28 15:05:05 +08:00
|
|
|
|
};
|
2024-12-28 14:25:23 +08:00
|
|
|
|
bridge.on(Msg.ResponseTreeInfo, (event: PluginEvent) => {
|
|
|
|
|
let data: Array<TreeData> = event.data;
|
2024-12-27 21:08:26 +08:00
|
|
|
|
isShowDebug.value = true;
|
2024-01-09 12:02:47 +08:00
|
|
|
|
});
|
2024-12-28 14:25:23 +08:00
|
|
|
|
bridge.on(Msg.ResponseSupport, (event: PluginEvent) => {
|
|
|
|
|
let data: ResponseSupportData = event.data;
|
2024-12-27 21:08:26 +08:00
|
|
|
|
const isCocosGame: boolean = data.support;
|
|
|
|
|
isShowDebug.value = isCocosGame;
|
2024-01-09 12:02:47 +08:00
|
|
|
|
});
|
2025-01-08 16:38:43 +08:00
|
|
|
|
bridge.on(Msg.ResponseUseFrame, (event: PluginEvent) => {
|
|
|
|
|
const data: ResponseUseFrameData = event.data;
|
|
|
|
|
frameID.value = data.id;
|
|
|
|
|
});
|
2024-12-28 14:25:23 +08:00
|
|
|
|
bridge.on(Msg.ResponseNodeInfo, (event: PluginEvent) => {
|
|
|
|
|
let eventData: NodeInfoData = event.data;
|
2024-12-27 21:08:26 +08:00
|
|
|
|
isShowDebug.value = true;
|
2024-12-10 10:34:27 +08:00
|
|
|
|
});
|
2025-01-06 14:21:06 +08:00
|
|
|
|
bridge.on(Msg.ResponseError, (event: PluginEvent) => {
|
|
|
|
|
const err: string = event.data;
|
|
|
|
|
ccui.footbar.showError(err);
|
|
|
|
|
});
|
2024-12-28 14:25:23 +08:00
|
|
|
|
bridge.on(Msg.ResponseUpdateFrames, (event: PluginEvent) => {
|
|
|
|
|
let resFrames: FrameDetails[] = event.data;
|
2024-12-27 21:08:26 +08:00
|
|
|
|
iframes.value = resFrames.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
label: item.url,
|
|
|
|
|
value: item.frameID,
|
|
|
|
|
};
|
|
|
|
|
});
|
2024-01-09 12:02:47 +08:00
|
|
|
|
});
|
2024-12-27 21:08:26 +08:00
|
|
|
|
|
2024-01-09 12:02:47 +08:00
|
|
|
|
// el-tree的渲染key
|
|
|
|
|
const defaultProps = ref<{ children: string; label: string }>({
|
|
|
|
|
children: "children",
|
|
|
|
|
label: "name",
|
|
|
|
|
});
|
|
|
|
|
|
2024-01-09 15:33:34 +08:00
|
|
|
|
function onChangeFrame() {
|
2024-12-27 14:14:38 +08:00
|
|
|
|
const id = Number(toRaw(frameID.value));
|
2024-12-27 19:20:22 +08:00
|
|
|
|
bridge.send(Msg.RequestUseFrame, { id } as RequestUseFrameData);
|
2025-01-08 16:37:12 +08:00
|
|
|
|
Bus.emit(BusMsg.ChangeContent, { id } as RequestUseFrameData);
|
2024-01-09 15:33:34 +08:00
|
|
|
|
}
|
|
|
|
|
const elLeft = ref<HTMLDivElement>();
|
2024-12-09 19:25:06 +08:00
|
|
|
|
const version = ref(PluginConfig.manifest.version);
|
2024-01-09 12:02:47 +08:00
|
|
|
|
return {
|
2024-12-09 19:25:06 +08:00
|
|
|
|
version,
|
2024-01-09 12:02:47 +08:00
|
|
|
|
defaultProps,
|
2024-12-27 21:08:26 +08:00
|
|
|
|
frameID,
|
2024-01-09 15:33:34 +08:00
|
|
|
|
iframes,
|
|
|
|
|
isShowDebug,
|
2024-12-28 14:25:23 +08:00
|
|
|
|
|
2024-01-09 15:33:34 +08:00
|
|
|
|
getFramesData(): Option[] {
|
|
|
|
|
const frames: FrameInfo[] = toRaw(iframes.value);
|
|
|
|
|
const options: Option[] = [];
|
|
|
|
|
frames.forEach((frame) => {
|
|
|
|
|
options.push({
|
|
|
|
|
label: frame.label,
|
|
|
|
|
value: frame.value,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
return options;
|
|
|
|
|
},
|
2024-01-23 22:25:32 +08:00
|
|
|
|
|
2024-01-09 15:33:34 +08:00
|
|
|
|
onChangeFrame,
|
2024-01-09 12:02:47 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
|
|
#devtools {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
overflow: hidden;
|
2024-12-10 10:34:27 +08:00
|
|
|
|
background-color: #5c5c5c;
|
|
|
|
|
color: white;
|
2024-12-12 20:13:50 +08:00
|
|
|
|
|
2024-01-09 12:02:47 +08:00
|
|
|
|
.head {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
align-items: center;
|
2024-12-12 20:13:50 +08:00
|
|
|
|
padding: 2px 0;
|
2024-01-09 12:02:47 +08:00
|
|
|
|
border-bottom: solid 1px grey;
|
|
|
|
|
|
|
|
|
|
.label {
|
2024-12-12 20:13:50 +08:00
|
|
|
|
color: white;
|
|
|
|
|
font-size: 12px;
|
2024-01-09 12:02:47 +08:00
|
|
|
|
margin: 0 3px;
|
2024-12-12 20:13:50 +08:00
|
|
|
|
margin-right: 5px;
|
|
|
|
|
user-select: none;
|
2024-01-09 12:02:47 +08:00
|
|
|
|
}
|
2024-01-05 16:45:23 +08:00
|
|
|
|
}
|
2024-01-09 12:02:47 +08:00
|
|
|
|
|
|
|
|
|
.find {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex: 1;
|
|
|
|
|
flex-direction: row;
|
2024-12-28 16:24:16 +08:00
|
|
|
|
overflow: hidden;
|
2024-01-09 12:02:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|