mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-13 21:51:03 +00:00
对接Settings,增加测试面板
This commit is contained in:
parent
4da068e358
commit
9035aa93a0
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@ CocosCreatorInspector/src/build
|
|||||||
/source/artifacts/
|
/source/artifacts/
|
||||||
/cc-inspector-v1.2/
|
/cc-inspector-v1.2/
|
||||||
/test/
|
/test/
|
||||||
cc-inspector/.yalc/
|
|
||||||
cc-inspector/node_modules/
|
cc-inspector/node_modules/
|
||||||
cc-inspector/yalc.lock
|
cc-inspector/yalc.lock
|
||||||
cc-inspector/chrome/
|
cc-inspector/chrome/
|
||||||
|
9
cc-inspector/.vscode/settings.json
vendored
9
cc-inspector/.vscode/settings.json
vendored
@ -5,9 +5,16 @@
|
|||||||
"[typescript]": {
|
"[typescript]": {
|
||||||
"editor.tabSize": 2,
|
"editor.tabSize": 2,
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"prettier.printWidth": 800,
|
"prettier.printWidth": 1800,
|
||||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
"editor.defaultFormatter": "vscode.typescript-language-features"
|
||||||
},
|
},
|
||||||
|
"[json]": {
|
||||||
|
"editor.quickSuggestions": {
|
||||||
|
"strings": true
|
||||||
|
},
|
||||||
|
"editor.suggest.insertMode": "replace",
|
||||||
|
"editor.tabSize": 2
|
||||||
|
},
|
||||||
"[vue]": {
|
"[vue]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"editor.tabSize": 2,
|
"editor.tabSize": 2,
|
||||||
|
@ -29,4 +29,4 @@
|
|||||||
"tiny-emitter": "2.1.0",
|
"tiny-emitter": "2.1.0",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ import ccui from "@xuyanfeng/cc-ui";
|
|||||||
import "@xuyanfeng/cc-ui/dist/ccui.css";
|
import "@xuyanfeng/cc-ui/dist/ccui.css";
|
||||||
import "@xuyanfeng/cc-ui/iconfont/iconfont.css";
|
import "@xuyanfeng/cc-ui/iconfont/iconfont.css";
|
||||||
import CCP from "cc-plugin/src/ccp/entry-render";
|
import CCP from "cc-plugin/src/ccp/entry-render";
|
||||||
|
import { createPinia } from 'pinia';
|
||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
import pluginConfig from "../../../cc-plugin.config";
|
import pluginConfig from "../../../cc-plugin.config";
|
||||||
import "../global.less";
|
import "../global.less";
|
||||||
@ -12,6 +13,7 @@ export default CCP.init(pluginConfig, {
|
|||||||
init();
|
init();
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
app.use(ccui);
|
app.use(ccui);
|
||||||
|
app.use(createPinia());
|
||||||
app.mount(rootElement);
|
app.mount(rootElement);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="devtools">
|
<div id="devtools">
|
||||||
<!-- <el-drawer title="settings" direction="btt" @close="onCloseSettings" :visible.sync="showSettings">
|
<Test @valid-game="testValidGame"> </Test>
|
||||||
<div>
|
|
||||||
<SettingsVue></SettingsVue>
|
|
||||||
</div>
|
|
||||||
</el-drawer> -->
|
|
||||||
<div class="head" v-show="iframes.length > 1">
|
<div class="head" v-show="iframes.length > 1">
|
||||||
<div class="label">inspect target:</div>
|
<div class="label">inspect target:</div>
|
||||||
<CCSelect v-model:value="frameID" placeholder="please select ..." @change="onChangeFrame" :data="getFramesData()"> </CCSelect>
|
<CCSelect v-model:value="frameID" placeholder="please select ..." @change="onChangeFrame" :data="getFramesData()"> </CCSelect>
|
||||||
@ -64,6 +60,8 @@
|
|||||||
<i class="iconfont icon_refresh"></i>
|
<i class="iconfont icon_refresh"></i>
|
||||||
</CCButton>
|
</CCButton>
|
||||||
</div>
|
</div>
|
||||||
|
<CCDialog></CCDialog>
|
||||||
|
<CCFootBar :version="version"></CCFootBar>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -72,27 +70,31 @@ import ccui from "@xuyanfeng/cc-ui";
|
|||||||
import { ButtonGroupItem } from "@xuyanfeng/cc-ui/types/cc-button-group/const";
|
import { ButtonGroupItem } from "@xuyanfeng/cc-ui/types/cc-button-group/const";
|
||||||
import { Option } from "@xuyanfeng/cc-ui/types/cc-select/const";
|
import { Option } from "@xuyanfeng/cc-ui/types/cc-select/const";
|
||||||
import { ITreeData } from "@xuyanfeng/cc-ui/types/cc-tree/const";
|
import { ITreeData } from "@xuyanfeng/cc-ui/types/cc-tree/const";
|
||||||
import { defineComponent, nextTick, onMounted, PropType, reactive, ref, toRaw, watch } from "vue";
|
import { _UnwrapAll, Store, storeToRefs } from "pinia";
|
||||||
|
import { defineComponent, nextTick, onMounted, PropType, reactive, Ref, ref, toRaw, watch } from "vue";
|
||||||
|
import PluginConfig from "../../../cc-plugin.config";
|
||||||
import { Msg, Page, PluginEvent } from "../../core/types";
|
import { Msg, Page, PluginEvent } from "../../core/types";
|
||||||
import Bus, { BusMsg } from "./bus";
|
import Bus, { BusMsg } from "./bus";
|
||||||
import { connectBackground } from "./connectBackground";
|
import { connectBackground } from "./connectBackground";
|
||||||
import { EngineData, FrameDetails, Info, NodeInfoData, ObjectData, ObjectItemRequestData, TreeData } from "./data";
|
import { EngineData, FrameDetails, Info, NodeInfoData, ObjectData, ObjectItemRequestData, TreeData } from "./data";
|
||||||
import { RefreshType, settings } from "./settings";
|
import { appStore, RefreshType } from "./store";
|
||||||
|
import Test from "./test.vue";
|
||||||
import properties from "./ui/propertys.vue";
|
import properties from "./ui/propertys.vue";
|
||||||
import SettingsVue from "./ui/settings.vue";
|
import SettingsVue from "./ui/settings.vue";
|
||||||
const { CCTree, CCInput, CCButton, CCInputNumber, CCSelect, CCButtonGroup, CCCheckBox, CCColor, CCDivider } = ccui.components;
|
const { CCTree, CCFootBar, CCDialog, CCInput, CCButton, CCInputNumber, CCSelect, CCButtonGroup, CCCheckBox, CCColor, CCDivider } = ccui.components;
|
||||||
interface FrameInfo {
|
interface FrameInfo {
|
||||||
label: string;
|
label: string;
|
||||||
value: number;
|
value: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { CCTree, CCDivider, CCButtonGroup, properties, SettingsVue, CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor },
|
components: { Test, CCFootBar, CCDialog, CCTree, CCDivider, CCButtonGroup, properties, SettingsVue, CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor },
|
||||||
name: "devtools",
|
name: "devtools",
|
||||||
props: {},
|
props: {},
|
||||||
setup(props, ctx) {
|
setup(props, ctx) {
|
||||||
|
appStore().init();
|
||||||
|
const { config } = storeToRefs(appStore());
|
||||||
const treeItemData = ref<NodeInfoData | null>({ uuid: "", group: [] });
|
const treeItemData = ref<NodeInfoData | null>({ uuid: "", group: [] });
|
||||||
const showSettings = ref<boolean>(false);
|
|
||||||
const isShowDebug = ref<boolean>(true);
|
const isShowDebug = ref<boolean>(true);
|
||||||
const frameID = ref<number>(0);
|
const frameID = ref<number>(0);
|
||||||
const iframes = ref<Array<FrameInfo>>([]);
|
const iframes = ref<Array<FrameInfo>>([]);
|
||||||
@ -108,7 +110,10 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
icon: "icon_settings",
|
icon: "icon_settings",
|
||||||
click: () => {
|
click: () => {
|
||||||
showSettings.value = true;
|
ccui.dialog.showDialog({
|
||||||
|
comp: SettingsVue,
|
||||||
|
title: "Settings",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -391,18 +396,16 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function syncSettings() {
|
function syncSettings() {
|
||||||
if (settings.data) {
|
const { refreshType, refreshTime } = config.value;
|
||||||
const { refreshType, refreshTime } = settings.data;
|
switch (refreshType) {
|
||||||
switch (refreshType) {
|
case RefreshType.Auto: {
|
||||||
case RefreshType.Auto: {
|
btnRefresh.visible = false;
|
||||||
btnRefresh.visible = false;
|
onEnableTreeWatch(true, refreshTime);
|
||||||
onEnableTreeWatch(true, refreshTime);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
case RefreshType.Manual: {
|
||||||
case RefreshType.Manual: {
|
btnRefresh.visible = true;
|
||||||
btnRefresh.visible = true;
|
onEnableTreeWatch(false);
|
||||||
onEnableTreeWatch(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,7 +425,9 @@ export default defineComponent({
|
|||||||
connectBackground.sendMsgToContentScript(Msg.UseFrame, frameID);
|
connectBackground.sendMsgToContentScript(Msg.UseFrame, frameID);
|
||||||
}
|
}
|
||||||
const elLeft = ref<HTMLDivElement>();
|
const elLeft = ref<HTMLDivElement>();
|
||||||
|
const version = ref(PluginConfig.manifest.version);
|
||||||
return {
|
return {
|
||||||
|
version,
|
||||||
buttonGroup,
|
buttonGroup,
|
||||||
elTree,
|
elTree,
|
||||||
memory,
|
memory,
|
||||||
@ -431,11 +436,13 @@ export default defineComponent({
|
|||||||
matchCase,
|
matchCase,
|
||||||
iframes,
|
iframes,
|
||||||
isShowDebug,
|
isShowDebug,
|
||||||
showSettings,
|
|
||||||
expandedKeys,
|
expandedKeys,
|
||||||
treeData,
|
treeData,
|
||||||
treeItemData,
|
treeItemData,
|
||||||
frameID,
|
frameID,
|
||||||
|
testValidGame(b: boolean) {
|
||||||
|
isShowDebug.value = !!b;
|
||||||
|
},
|
||||||
getFramesData(): Option[] {
|
getFramesData(): Option[] {
|
||||||
const frames: FrameInfo[] = toRaw(iframes.value);
|
const frames: FrameInfo[] = toRaw(iframes.value);
|
||||||
const options: Option[] = [];
|
const options: Option[] = [];
|
||||||
@ -471,10 +478,6 @@ export default defineComponent({
|
|||||||
onBtnClickUpdatePage() {
|
onBtnClickUpdatePage() {
|
||||||
connectBackground.sendMsgToContentScript(Msg.Support);
|
connectBackground.sendMsgToContentScript(Msg.Support);
|
||||||
},
|
},
|
||||||
onCloseSettings() {
|
|
||||||
syncSettings();
|
|
||||||
},
|
|
||||||
|
|
||||||
onMemoryTest() {
|
onMemoryTest() {
|
||||||
connectBackground.sendMsgToContentScript(Msg.MemoryInfo);
|
connectBackground.sendMsgToContentScript(Msg.MemoryInfo);
|
||||||
},
|
},
|
||||||
|
@ -1,47 +1,5 @@
|
|||||||
const Key = "settings";
|
|
||||||
|
|
||||||
export const enum RefreshType {
|
|
||||||
Auto = "auto",
|
|
||||||
Manual = "manual",
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SettingsData {
|
|
||||||
refreshType: string;
|
|
||||||
refreshTime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
let defaultData: SettingsData = {
|
|
||||||
refreshTime: 500,
|
|
||||||
refreshType: RefreshType.Manual,
|
|
||||||
}
|
|
||||||
|
|
||||||
class Settings {
|
|
||||||
public data: SettingsData | null = null;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private init() {
|
|
||||||
const data = localStorage.getItem(Key)
|
|
||||||
if (data) {
|
|
||||||
try {
|
|
||||||
this.data = JSON.parse(data)
|
|
||||||
} catch (e) {
|
|
||||||
this.data = defaultData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.data = Object.assign(defaultData, this.data)
|
|
||||||
}
|
|
||||||
|
|
||||||
isManualRefresh() {
|
|
||||||
return this.data?.refreshType === RefreshType.Manual;
|
|
||||||
}
|
|
||||||
|
|
||||||
save() {
|
|
||||||
const str = JSON.stringify(this.data);
|
|
||||||
localStorage.setItem(Key, str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const settings = new Settings();
|
|
||||||
|
35
cc-inspector/src/views/devtools/store.ts
Normal file
35
cc-inspector/src/views/devtools/store.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import profile from "cc-plugin/src/ccp/profile";
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { ref, toRaw } from "vue";
|
||||||
|
import pluginConfig from "../../../cc-plugin.config";
|
||||||
|
export const enum RefreshType {
|
||||||
|
Auto = "auto",
|
||||||
|
Manual = "manual",
|
||||||
|
}
|
||||||
|
export class ConfigData {
|
||||||
|
/**
|
||||||
|
* 刷新类型
|
||||||
|
*/
|
||||||
|
refreshType: string = RefreshType.Manual;
|
||||||
|
/**
|
||||||
|
* 刷新间隔时间,单位ms
|
||||||
|
*/
|
||||||
|
refreshTime: number = 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const appStore = defineStore("app", () => {
|
||||||
|
const config = ref<ConfigData>(new ConfigData());
|
||||||
|
return {
|
||||||
|
config,
|
||||||
|
init() {
|
||||||
|
profile.init(new ConfigData(), pluginConfig);
|
||||||
|
const data = profile.load(`${pluginConfig.manifest.name}.json`) as ConfigData;
|
||||||
|
config.value.refreshType = data.refreshType || RefreshType.Manual;
|
||||||
|
config.value.refreshTime = data.refreshTime || 500;
|
||||||
|
},
|
||||||
|
save() {
|
||||||
|
const cfg = toRaw(config.value);
|
||||||
|
profile.save(cfg);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
39
cc-inspector/src/views/devtools/test.vue
Normal file
39
cc-inspector/src/views/devtools/test.vue
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="show" class="test">
|
||||||
|
<CCSection name="功能测试">
|
||||||
|
<CCButton @click="onClickHasCocosGame">Has CocosGame</CCButton>
|
||||||
|
<CCButton @click="onClickNoCocosGame">No CocosGame</CCButton>
|
||||||
|
</CCSection>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
import ccui from "@xuyanfeng/cc-ui";
|
||||||
|
import { defineComponent, ref } from "vue";
|
||||||
|
const { CCButton, CCSection } = ccui.components;
|
||||||
|
export default defineComponent({
|
||||||
|
name: "test",
|
||||||
|
components: { CCButton, CCSection },
|
||||||
|
emits: ["validGame"],
|
||||||
|
props: {
|
||||||
|
isCocosGame: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const show = ref(__DEV__);
|
||||||
|
return {
|
||||||
|
show,
|
||||||
|
onClickHasCocosGame() {
|
||||||
|
emit("validGame", true);
|
||||||
|
},
|
||||||
|
onClickNoCocosGame() {
|
||||||
|
emit("validGame", false);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style scoped lang="less">
|
||||||
|
.test {
|
||||||
|
color: rgb(192, 56, 56);
|
||||||
|
font-size: 11%;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="prop">
|
<div class="prop">
|
||||||
<PropertyGroup v-for="(group, index) in data.group" :key="index" :group="group"></PropertyGroup>
|
<PropertyGroup v-for="(group, index) in data.group" :key="index" :group="group"></PropertyGroup>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -41,6 +41,7 @@ export default defineComponent({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
#prop {
|
.prop {
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="settings">
|
<div class="settings">
|
||||||
<settings-prop label="refresh">
|
<CCProp name="refresh">
|
||||||
<CCSelect v-model="refreshType" :data="refreshOptions" @change="onCommonSave" style="flex: 1"> </CCSelect>
|
<CCSelect :value="config.refreshType" :data="refreshOptions" @change="onChangeRefreshType" style="flex: 1"> </CCSelect>
|
||||||
</settings-prop>
|
</CCProp>
|
||||||
<settings-prop label="refresh time: " v-show="isRefreshAuto()">
|
<CCProp name="refresh time: " v-show="isRefreshAuto()">
|
||||||
<CCInputNumber style="flex: 1" :min="100" v-model="refreshTime" @change="onCommonSave"></CCInputNumber>
|
<CCInputNumber style="flex: 1" :min="100" :value="config.refreshTime" @change="onChangeRefreshTime"></CCInputNumber>
|
||||||
<span>ms</span>
|
<span style="margin: 0 3px">ms</span>
|
||||||
</settings-prop>
|
</CCProp>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import ccui from "@xuyanfeng/cc-ui";
|
import ccui from "@xuyanfeng/cc-ui";
|
||||||
import { Option } from "@xuyanfeng/cc-ui/types/cc-select/const";
|
import { Option } from "@xuyanfeng/cc-ui/types/cc-select/const";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
import { defineComponent, onMounted, ref, toRaw } from "vue";
|
import { defineComponent, onMounted, ref, toRaw } from "vue";
|
||||||
import { RefreshType, settings } from "../settings";
|
import { appStore, RefreshType } from "../store";
|
||||||
import SettingsProp from "./settings-prop.vue";
|
const { CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCProp, CCColor } = ccui.components;
|
||||||
const { CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor } = ccui.components;
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "settings",
|
name: "settings",
|
||||||
components: {
|
components: {
|
||||||
SettingsProp,
|
CCProp,
|
||||||
CCInput,
|
CCInput,
|
||||||
CCButton,
|
CCButton,
|
||||||
CCInputNumber,
|
CCInputNumber,
|
||||||
@ -34,22 +34,22 @@ export default defineComponent({
|
|||||||
{ label: "auto", value: RefreshType.Auto },
|
{ label: "auto", value: RefreshType.Auto },
|
||||||
{ label: "manual", value: RefreshType.Manual },
|
{ label: "manual", value: RefreshType.Manual },
|
||||||
]);
|
]);
|
||||||
const refreshType = ref(settings.data?.refreshType || "");
|
const { config } = storeToRefs(appStore());
|
||||||
const refreshTime = ref(settings.data?.refreshTime || 500);
|
|
||||||
return {
|
return {
|
||||||
refreshType,
|
config,
|
||||||
refreshTime,
|
|
||||||
refreshOptions,
|
refreshOptions,
|
||||||
isRefreshAuto() {
|
isRefreshAuto() {
|
||||||
return refreshType.value === RefreshType.Auto;
|
return config.value.refreshType === RefreshType.Auto;
|
||||||
},
|
},
|
||||||
onChangeRefreshType() {},
|
onChangeRefreshType(type: RefreshType) {
|
||||||
onCommonSave() {
|
const store = appStore();
|
||||||
if (settings.data) {
|
store.config.refreshType = type;
|
||||||
settings.data.refreshType = toRaw(refreshType.value);
|
store.save();
|
||||||
settings.data.refreshTime = toRaw(refreshTime.value);
|
},
|
||||||
settings.save();
|
onChangeRefreshTime(v: number) {
|
||||||
}
|
const store = appStore();
|
||||||
|
store.config.refreshTime = v;
|
||||||
|
store.save();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -58,5 +58,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.settings {
|
.settings {
|
||||||
|
color: white;
|
||||||
|
background-color: #4d4d4d;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user