3.8.5 warn消除不掉,只能剔除检索该属性

This commit is contained in:
xu_yanfeng 2025-01-25 18:17:56 +08:00
parent ef970e9d4c
commit 915f144986

View File

@ -5,13 +5,12 @@ import { ArrayData, BoolData, ColorData, DataType, EngineData, Group, ImageData,
import { InjectEvent } from "./event"; import { InjectEvent } from "./event";
import { Hint } from "./hint"; import { Hint } from "./hint";
import { injectView } from "./inject-view"; import { injectView } from "./inject-view";
import { inspectTarget } from "./inspect-list";
import { getValue, trySetValueWithConfig } from "./setValue"; import { getValue, trySetValueWithConfig } from "./setValue";
import { BuildArrayOptions, BuildImageOptions, BuildObjectOptions, BuildVecOptions } from "./types"; import { BuildArrayOptions, BuildImageOptions, BuildObjectOptions, BuildVecOptions } from "./types";
import { isHasProperty } from "./util"; import { isHasProperty } from "./util";
import { inspectTarget } from "./inspect-list";
declare const cc: any; declare const cc: any;
export class Inspector extends InjectEvent { export class Inspector extends InjectEvent {
inspectorGameMemoryStorage: Record<string, any> = {}; inspectorGameMemoryStorage: Record<string, any> = {};
private hint: Hint = new Hint(this); private hint: Hint = new Hint(this);
@ -280,9 +279,15 @@ export class Inspector extends InjectEvent {
return keys; return keys;
} }
_getNodeKeys(node: any) { isExcludeProperty(node: any, key: string) {
// 3.x变成了getter const mapArray = [
let excludeProperty = [ {
type: cc.UITransformComponent || cc.UITransform,
keys: ["priority"],
},
{
type: null, // null 表示所有适配类型
keys: [
"children", "children",
"quat", "quat",
"node", "node",
@ -311,7 +316,27 @@ export class Inspector extends InjectEvent {
"internalPreload", "internalPreload",
"internalOnLoad", "internalOnLoad",
"internalStart", "internalStart",
],
},
]; ];
for (let i = 0; i < mapArray.length; i++) {
const { type, keys } = mapArray[i];
if (type === null) {
if (keys.find((v) => v === key)) {
return true;
}
} else {
if (node instanceof type) {
if (keys.find((v) => v === key)) {
return true;
}
}
}
}
return false;
}
_getNodeKeys(node: any) {
// 3.x变成了getter
const keyHidden = this.getAllPropertyDescriptors(node); const keyHidden = this.getAllPropertyDescriptors(node);
const keyVisible1 = Object.keys(node); // Object不走原型链 const keyVisible1 = Object.keys(node); // Object不走原型链
let keyVisible2: string[] = []; let keyVisible2: string[] = [];
@ -321,7 +346,7 @@ export class Inspector extends InjectEvent {
} }
let allKeys: string[] = uniq(keyHidden.concat(keyVisible1, keyVisible2)).sort(); let allKeys: string[] = uniq(keyHidden.concat(keyVisible1, keyVisible2)).sort();
allKeys = allKeys.filter((key) => { allKeys = allKeys.filter((key) => {
return !key.startsWith("_") && !excludeProperty.includes(key); return !key.startsWith("_") && !this.isExcludeProperty(node, key);
}); });
allKeys = allKeys.filter((key) => { allKeys = allKeys.filter((key) => {