mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-06-06 16:24:01 +00:00
readonly
This commit is contained in:
parent
700e03e0a9
commit
d1ee49e3d4
@ -15,6 +15,7 @@ export enum DataType {
|
|||||||
export class Info {
|
export class Info {
|
||||||
public type: DataType = DataType.Number;
|
public type: DataType = DataType.Number;
|
||||||
public data: any;
|
public data: any;
|
||||||
|
public readonly: boolean = false;
|
||||||
public path: Array<string> = [];// 属性对应的路径
|
public path: Array<string> = [];// 属性对应的路径
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,8 @@ class CCInspector {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_genInfoData(propertyValue: any, path: any) {
|
_genInfoData(node: any, key: string, path: any) {
|
||||||
|
let propertyValue = node[key];
|
||||||
let info = null;
|
let info = null;
|
||||||
switch (typeof propertyValue) {
|
switch (typeof propertyValue) {
|
||||||
case "boolean":
|
case "boolean":
|
||||||
@ -220,6 +221,7 @@ class CCInspector {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (info) {
|
if (info) {
|
||||||
|
info.readonly = this._isReadonly(node, key)
|
||||||
info.path = path;
|
info.path = path;
|
||||||
} else {
|
} else {
|
||||||
console.error(`暂不支持的属性值`, propertyValue);
|
console.error(`暂不支持的属性值`, propertyValue);
|
||||||
@ -256,7 +258,7 @@ class CCInspector {
|
|||||||
pairValues.forEach((el: string) => {
|
pairValues.forEach((el: string) => {
|
||||||
if (el in node) {
|
if (el in node) {
|
||||||
let propertyPath = [node.uuid, el];
|
let propertyPath = [node.uuid, el];
|
||||||
let vecData = this._genInfoData(node[el], propertyPath);
|
let vecData = this._genInfoData(node, el, propertyPath);
|
||||||
if (vecData) {
|
if (vecData) {
|
||||||
info && info.add(new Property(el, vecData));
|
info && info.add(new Property(el, vecData));
|
||||||
}
|
}
|
||||||
@ -273,7 +275,7 @@ class CCInspector {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let propertyPath = [node.uuid, key];
|
let propertyPath = [node.uuid, key];
|
||||||
let info = this._genInfoData(propertyValue, propertyPath);
|
let info = this._genInfoData(node, key, propertyPath);
|
||||||
if (info) {
|
if (info) {
|
||||||
nodeGroup.addProperty(new Property(key, info));
|
nodeGroup.addProperty(new Property(key, info));
|
||||||
}
|
}
|
||||||
@ -314,22 +316,26 @@ class CCInspector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isReadonly(base: Object, key: string): boolean {
|
||||||
|
let obj = Object.getPrototypeOf(base);
|
||||||
|
if (obj) {
|
||||||
|
let ret = Object.getOwnPropertyDescriptor(obj, key)
|
||||||
|
if (ret && ret.set) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return this._isReadonly(obj, key)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setValue(uuid: string, key: string, value: string) {
|
setValue(uuid: string, key: string, value: string) {
|
||||||
let nodeOrComp = this.inspectorGameMemoryStorage[uuid];
|
let nodeOrComp = this.inspectorGameMemoryStorage[uuid];
|
||||||
if (nodeOrComp && key in nodeOrComp) {
|
if (nodeOrComp && key in nodeOrComp) {
|
||||||
debugger
|
if (this._isReadonly(nodeOrComp, key)) {
|
||||||
|
console.warn(`值不允许修改`);
|
||||||
function circleFind(base: Object): boolean {
|
} else {
|
||||||
let obj = Object.getPrototypeOf(base);
|
|
||||||
let ret = Object.getOwnPropertyDescriptor(obj, key)
|
|
||||||
if (ret && ret.set) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return circleFind(obj)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (circleFind(nodeOrComp)) {
|
|
||||||
nodeOrComp[key] = value;
|
nodeOrComp[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,15 @@
|
|||||||
<div class="text">{{ name }}</div>
|
<div class="text">{{ name }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="value">
|
<div class="value">
|
||||||
<el-input v-if="isString()" v-model="value.data" @change="onChangeValue"></el-input>
|
<el-input v-if="isString()" v-model="value.data"
|
||||||
|
:disabled="value.readonly"
|
||||||
|
@change="onChangeValue">
|
||||||
|
</el-input>
|
||||||
<el-input v-if="isText()"
|
<el-input v-if="isText()"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:autosize="{minRows:3,maxRows:5}"
|
:autosize="{minRows:3,maxRows:5}"
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
|
:disabled="value.readonly"
|
||||||
@change="onChangeValue"
|
@change="onChangeValue"
|
||||||
v-model="value.data">
|
v-model="value.data">
|
||||||
</el-input>
|
</el-input>
|
||||||
@ -16,6 +20,7 @@
|
|||||||
style="width: 100%;text-align: left"
|
style="width: 100%;text-align: left"
|
||||||
v-model="value.data"
|
v-model="value.data"
|
||||||
:step="step"
|
:step="step"
|
||||||
|
:disabled="value.readonly"
|
||||||
@change="onChangeValue"
|
@change="onChangeValue"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
></el-input-number>
|
></el-input-number>
|
||||||
@ -28,16 +33,26 @@
|
|||||||
|
|
||||||
</ui-prop>
|
</ui-prop>
|
||||||
</div>
|
</div>
|
||||||
<el-select v-model="value.data" v-if="isEnum()" style="width: 100%;" @change="onChangeValue">
|
<el-select v-model="value.data"
|
||||||
|
:disabled="value.readonly"
|
||||||
|
v-if="isEnum()" style="width: 100%;"
|
||||||
|
@change="onChangeValue">
|
||||||
<el-option v-for="(opt, index) in value.values"
|
<el-option v-for="(opt, index) in value.values"
|
||||||
:key="index"
|
:key="index"
|
||||||
:label="opt.name"
|
:label="opt.name"
|
||||||
:value="opt.value">
|
:value="opt.value">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-checkbox v-model="value.data" v-if="isBool()" @change="onChangeValue"></el-checkbox>
|
<el-checkbox v-model="value.data"
|
||||||
|
v-if="isBool()"
|
||||||
|
:disabled="value.readonly"
|
||||||
|
@change="onChangeValue">
|
||||||
|
</el-checkbox>
|
||||||
<div class="color" v-if="isColor()">
|
<div class="color" v-if="isColor()">
|
||||||
<el-color-picker style="position: absolute;" v-model="value.data" @change="onChangeValue"></el-color-picker>
|
<el-color-picker style="position: absolute;"
|
||||||
|
:disabled="value.readonly"
|
||||||
|
v-model="value.data" @change="onChangeValue">
|
||||||
|
</el-color-picker>
|
||||||
<div class="hex" :style="{color:colorReverse(value.data)}">{{ value.data }}</div>
|
<div class="hex" :style="{color:colorReverse(value.data)}">{{ value.data }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isArrayOrObject()" class="array-object">
|
<div v-if="isArrayOrObject()" class="array-object">
|
||||||
@ -131,7 +146,9 @@ export default class UiProp extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onChangeValue() {
|
onChangeValue() {
|
||||||
connectBackground.postMessageToBackground(Msg.SetProperty, this.value);
|
if (!this.value.readonly) {
|
||||||
|
connectBackground.postMessageToBackground(Msg.SetProperty, this.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Prop({default: 1})
|
@Prop({default: 1})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user