diff --git a/cc-inspector/.vscode/settings.json b/cc-inspector/.vscode/settings.json
index 41ddf0d..96f8e9d 100644
--- a/cc-inspector/.vscode/settings.json
+++ b/cc-inspector/.vscode/settings.json
@@ -10,5 +10,13 @@
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
- "files.refactoring.autoSave": false
+ "files.refactoring.autoSave": false,
+ "search.exclude": {
+ "**/node_modules": true,
+ "**/bower_components": true,
+ "**/*.code-search": true,
+ "chrome": true,
+ "yarn-error.log": true,
+ "yarn.lock": true
+ }
}
diff --git a/cc-inspector/package.json b/cc-inspector/package.json
index f08d8b8..40ee893 100644
--- a/cc-inspector/package.json
+++ b/cc-inspector/package.json
@@ -8,7 +8,7 @@
"@types/lodash": "^4.14.176",
"@types/node": "16.11.12",
"@types/uuid": "^8.3.1",
- "@xuyanfeng/cc-ui": "^0.2.14",
+ "@xuyanfeng/cc-ui": "file:.yalc/@xuyanfeng/cc-ui",
"cc-plugin": "file:.yalc/cc-plugin"
},
"name": "cc-plugin-demo",
@@ -25,8 +25,8 @@
},
"version": "1.0.0",
"dependencies": {
- "uuid": "^8.3.2",
+ "lodash": "^4.17.21",
"tiny-emitter": "2.1.0",
- "lodash": "^4.17.21"
+ "uuid": "^8.3.2"
}
}
diff --git a/cc-inspector/src/views/devtools/data.ts b/cc-inspector/src/views/devtools/data.ts
index 2936554..4405f7f 100644
--- a/cc-inspector/src/views/devtools/data.ts
+++ b/cc-inspector/src/views/devtools/data.ts
@@ -26,9 +26,20 @@ export class Info {
constructor() {
this.id = v4();
}
- public isEnum(): boolean {
- return false;
- }
+ public isEnum(): boolean { return false; }
+ public isVec2(): boolean { return false; }
+ public isVec3(): boolean { return false; }
+ public isBool(): boolean { return false; }
+ public isText(): boolean { return false; }
+ public isString(): boolean { return false; }
+ public isColor(): boolean { return false; }
+ public isInvalid(): boolean { return false; }
+ public isNumber(): boolean { return false; }
+ public isArrayOrObject(): boolean { return false; }
+ public isArray(): boolean { return false; }
+ public isObject(): boolean { return false; }
+ public isImage(): boolean { return false; }
+ public isEngine(): boolean { return false; }
}
export class TextData extends Info {
@@ -36,6 +47,7 @@ export class TextData extends Info {
super();
this.type = DataType.Text;
}
+ public isText(): boolean { return true; }
}
export interface ObjectItemRequestData {
@@ -57,6 +69,7 @@ export class EngineData extends Info {
super();
this.type = DataType.Engine;
}
+ public isEngine(): boolean { return true; }
}
export class ArrayData extends Info {
@@ -71,6 +84,7 @@ export class ArrayData extends Info {
this.data.push(info);
return this;
}
+ public isArray(): boolean { return true; }
}
export class ObjectDataItem extends Info {
@@ -83,6 +97,7 @@ export class ObjectData extends Info {
super();
this.type = DataType.Object;
}
+ public isObject(): boolean { return true; }
}
export class InvalidData extends Info {
@@ -93,6 +108,7 @@ export class InvalidData extends Info {
this.data = data;
this.type = DataType.Invalid;
}
+ public isInvalid(): boolean { return true; }
}
export class ColorData extends Info {
@@ -101,6 +117,7 @@ export class ColorData extends Info {
this.type = DataType.Color;
this.data = color;
}
+ public isColor(): boolean { return true; }
}
export class StringData extends Info {
@@ -109,6 +126,7 @@ export class StringData extends Info {
this.type = DataType.String;
this.data = data;
}
+ public isString(): boolean { return true; }
}
export class NumberData extends Info {
@@ -117,6 +135,7 @@ export class NumberData extends Info {
this.type = DataType.Number;
this.data = data;
}
+ public isNumber(): boolean { return true; }
}
export class BoolData extends Info {
@@ -125,6 +144,7 @@ export class BoolData extends Info {
this.type = DataType.Bool;
this.data = bol;
}
+ public isBool(): boolean { return true; }
}
export class Vec2Data extends Info {
@@ -141,6 +161,9 @@ export class Vec2Data extends Info {
this.data.push(info);
return this;
}
+ public isVec2(): boolean {
+ return true;
+ }
}
export class Vec3Data extends Info {
@@ -157,6 +180,9 @@ export class Vec3Data extends Info {
this.data.push(info);
return this;
}
+ public isVec3(): boolean {
+ return true;
+ }
}
export class ImageData extends Info {
@@ -168,6 +194,7 @@ export class ImageData extends Info {
this.data = null;
return this;
}
+ public isImage(): boolean { return true; }
}
export class EnumData extends Info {
diff --git a/cc-inspector/src/views/devtools/index.vue b/cc-inspector/src/views/devtools/index.vue
index 8b02897..0ca167d 100644
--- a/cc-inspector/src/views/devtools/index.vue
+++ b/cc-inspector/src/views/devtools/index.vue
@@ -7,24 +7,18 @@
-->
inspect target:
-
-
-
-
+
- 内存测试
+ 内存测试
JS堆栈限制: {{ memory.performance.jsHeapSizeLimit }}
@@ -34,30 +28,25 @@
-
+
+
+
+
+
-
-
-
-
-
-
@@ -35,13 +25,24 @@
import { defineComponent, onMounted, ref, toRaw } from "vue";
import { RefreshType, settings } from "../settings";
import SettingsProp from "./settings-prop.vue";
-
+import { Option } from "@xuyanfeng/cc-ui/types/cc-select/const";
+import ccui from "@xuyanfeng/cc-ui";
+const { CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor } =
+ ccui.components;
export default defineComponent({
name: "settings",
- components: { SettingsProp },
+ components: {
+ SettingsProp,
+ CCInput,
+ CCButton,
+ CCInputNumber,
+ CCSelect,
+ CCCheckBox,
+ CCColor,
+ },
props: {},
setup(props, ctx) {
- const refreshOptions = ref
>([
+ const refreshOptions = ref>([
{ label: "auto", value: RefreshType.Auto },
{ label: "manual", value: RefreshType.Manual },
]);
diff --git a/cc-inspector/src/views/devtools/ui/ui-prop.vue b/cc-inspector/src/views/devtools/ui/ui-prop.vue
index 3936691..5565dcd 100644
--- a/cc-inspector/src/views/devtools/ui/ui-prop.vue
+++ b/cc-inspector/src/views/devtools/ui/ui-prop.vue
@@ -27,29 +27,30 @@
>
-
+
-
+
{{ value.data }}
-
-
-
+
-
-
+
+ >
-
+
-
-
-
-
-
+
-
-
-
+
-
-
-
-
-
-
-
+
-
+
-
{{ value.engineType }}
+
{{ value["engineType"] }}
-
{{ value.engineName }}
-
{{ value["engineName"] }}
+
+ >
-
+
{{ value.data }}
-
Array({{ value.data.length }})
+
+ Array({{ value.data.length }})
+
@@ -172,7 +165,7 @@
:key="index"
:indent="indent + 1"
:value="arr.value"
- :name="getName(isArray(), arr)"
+ :name="getName(value.isArray(), arr)"
>
@@ -194,109 +187,98 @@ import { DataType, EngineData, EnumData, Info, Property } from "../data";
import { connectBackground } from "../connectBackground";
import { Msg } from "../../../core/types";
import Bus, { BusMsg } from "../bus";
+import { Option } from "@xuyanfeng/cc-ui/types/cc-select/const";
+import ccui from "@xuyanfeng/cc-ui";
+const { CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor } =
+ ccui.components;
export default defineComponent({
name: "UiProp",
+ components: {
+ CCInput,
+ CCButton,
+ CCInputNumber,
+ CCSelect,
+ CCCheckBox,
+ CCColor,
+ },
props: {
- name: {
- type: String,
- default: "",
- },
- indent: {
- type: Number,
- default: 0,
- },
- arrow: {
- type: Boolean,
- default: true,
- },
+ name: { type: String, default: "" },
+ indent: { type: Number, default: 0 },
+ arrow: { type: Boolean, default: true },
+ step: { type: Number, default: 1 },
value: {
type: Object as PropType,
default: () => {},
},
- step: {
- type: Number,
- default: 1,
- },
},
-
- setup(props, ctx) {
+ setup(props, { emit }) {
+ const { value, step } = props;
+ const fold = ref(true);
let clientX: number = 0;
-
onMounted(() => {
watchValue();
});
function watchValue() {
- this.fold = true;
- if (this.isArray()) {
- this.subData = this.value.data;
+ fold.value = true;
+ if (value.isArray()) {
+ subData.value = value.data;
} else {
- this.subData = null;
+ subData.value = null;
}
}
- const fold = ref(true);
watch(props.value, () => {
watchValue();
});
const subData = ref([]);
+ const propText = ref();
+ function _onMouseMove(event: MouseEvent) {
+ let x = event.clientX;
+ let calcStep = step || 0;
+ if (x > clientX) {
+ calcStep = Math.abs(calcStep);
+ } else {
+ calcStep = -Math.abs(calcStep);
+ }
+ emit("movestep", calcStep);
+ clientX = x;
+ }
+
+ function _onMouseUp(event: MouseEvent) {
+ document.removeEventListener("mousemove", _onMouseMove);
+ document.removeEventListener("mouseup", _onMouseUp);
+ document.removeEventListener("onselectstart", _onSelect);
+ }
+ function _onSelect() {
+ return false;
+ }
return {
fold,
+ propText,
subData,
- isInvalid() {
- return this.value && this.value.type === DataType.Invalid;
- },
- isString() {
- return this.value && this.value.type === DataType.String;
- },
- isText() {
- return this.value && this.value.type === DataType.Text;
- },
- isNumber() {
- return this.value && this.value.type === DataType.Number;
- },
- isVec2() {
- return this.value && this.value.type === DataType.Vec2;
- },
- isVec3() {
- return this.value && this.value.type === DataType.Vec3;
- },
- isEnum() {
- return this.value && this.value.type === DataType.Enum;
- },
- isBool() {
- return this.value && this.value.type === DataType.Bool;
- },
- isColor() {
- return this.value && this.value.type === DataType.Color;
+ getEnumValues(data: any): Option[] {
+ const value: EnumData = data;
+ const ret: Option[] = [];
+ value.values.map((item) => {
+ ret.push({
+ label: item.name,
+ value: item.value,
+ });
+ });
+ return ret;
},
isArrayOrObject() {
- return (
- this.value &&
- (this.value.type === DataType.Array ||
- this.value.type === DataType.Object)
- );
- },
- isObject() {
- return this.value && this.value.type === DataType.Object;
- },
- isArray() {
- return this.value && this.value.type === DataType.Array;
- },
- isImage() {
- return this.value && this.value.type === DataType.Image;
+ return value && (value.isArray() || value.isObject());
},
isImageValid() {
- return !!this.value.data;
- },
- isEngine() {
- return this.value && this.value.type === DataType.Engine;
+ return !!value.data;
},
onPlaceInTree() {
- Bus.emit(BusMsg.ShowPlace, this.value);
+ Bus.emit(BusMsg.ShowPlace, value);
},
isShowTooltip() {
- const el: HTMLDivElement = this.$refs.propText as HTMLDivElement;
+ const el: HTMLDivElement = propText.value as HTMLDivElement;
if (el) {
if (el.scrollWidth > el.offsetWidth) {
// 出现了省略号
@@ -306,8 +288,7 @@ export default defineComponent({
return false;
},
getEngineTypeIcon() {
- const value = this.value as EngineData;
- switch (value.engineType) {
+ switch ((value as EngineData).engineType) {
case "cc_Sprite": {
return "el-icon-picture-outline";
}
@@ -329,21 +310,20 @@ export default defineComponent({
}
},
onClickFold() {
- if (this.isObject() && this.fold && !this.subData) {
+ if (value.isObject() && fold && !subData) {
// 请求object的item数据
- Bus.emit(BusMsg.RequestObjectData, this.value, (info: Property[]) => {
- this.fold = false;
- this.subData = info;
+ Bus.emit(BusMsg.RequestObjectData, value, (info: Property[]) => {
+ fold.value = false;
+ subData.value = info;
});
} else {
- this.fold = !this.fold;
+ fold.value = !fold.value;
}
},
-
onShowValueInConsole() {
- if (Array.isArray(this.value.path)) {
- let uuid = this.value.path[0];
- let key = this.value.path[1]; // todo 暂时只支持一级key
+ if (Array.isArray(value.path)) {
+ let uuid = value.path[0];
+ let key = value.path[1]; // todo 暂时只支持一级key
if (uuid && key) {
chrome.devtools.inspectedWindow.eval(
`window.CCInspector.logValue('${uuid}','${key}')`
@@ -351,46 +331,24 @@ export default defineComponent({
}
}
},
-
onChangeValue() {
- if (!this.value.readonly) {
- connectBackground.postMessageToBackground(
- Msg.SetProperty,
- this.value
- );
+ if (!value.readonly) {
+ connectBackground.postMessageToBackground(Msg.SetProperty, value);
}
},
onPropNameMouseDown(event: MouseEvent) {
- document.addEventListener("mousemove", this._onMouseMove);
- document.addEventListener("mouseup", this._onMouseUp);
- document.addEventListener("onselectstart", this._onSelect);
+ document.addEventListener("mousemove", _onMouseMove);
+ document.addEventListener("mouseup", _onMouseUp);
+ document.addEventListener("onselectstart", _onSelect);
},
-
colorReverse(OldColorValue: string) {
OldColorValue = "0x" + OldColorValue.replace(/#/g, "");
var str = "000000" + (0xffffff - parseInt(OldColorValue)).toString(16);
return "#" + str.substring(str.length - 6, str.length);
},
- _onMouseMove(event: MouseEvent) {
- let x = event.clientX;
- let calcStep = this.step || 0;
- if (x > this.clientX) {
- calcStep = Math.abs(calcStep);
- } else {
- calcStep = -Math.abs(calcStep);
- }
- this.$emit("movestep", calcStep);
- this.clientX = x;
- },
-
- _onMouseUp(event: MouseEvent) {
- document.removeEventListener("mousemove", this._onMouseMove);
- document.removeEventListener("mouseup", this._onMouseUp);
- document.removeEventListener("onselectstart", this._onSelect);
- },
- _onSelect() {
- return false;
- },
+ _onMouseMove,
+ _onMouseUp,
+ _onSelect,
};
},
});
diff --git a/cc-inspector/src/views/popup/index.vue b/cc-inspector/src/views/popup/index.vue
index 5e9fbae..ab5582a 100644
--- a/cc-inspector/src/views/popup/index.vue
+++ b/cc-inspector/src/views/popup/index.vue
@@ -3,10 +3,10 @@
@@ -43,9 +43,12 @@
import { defineComponent, onMounted, ref, provide, nextTick } from "vue";
import CCP from "cc-plugin/src/ccp/entry-render";
import { ChromeConst } from "cc-plugin/src/chrome/const";
+import ccui from "@xuyanfeng/cc-ui";
+const { CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor } =
+ ccui.components;
export default defineComponent({
name: "popup",
- components: {},
+ components: {CCInput, CCButton, CCInputNumber, CCSelect, CCCheckBox, CCColor},
setup(props, ctx) {
const title = ref(CCP.manifest.name);
const version = ref(CCP.manifest.version);