aozhiwei 944fb8ff43 1
2022-04-13 14:54:37 +08:00

58 lines
1.1 KiB
JavaScript

const utils = require('j7/utils');
class BaseWrap {
#writeLock = false;
constructor(json, metaClass) {
this._json = json;
//this._metaClass = metaClass;
this._metaName = metaClass['wrapClassName'];
}
lock() {
//this.#writeLock = true;
}
_getHandler() {
return {
get: (obj, prop) => {
if (prop in obj._json) {
let val = obj._json[prop];
if (utils.isArray(val)) {
return new Proxy(val, {
set: () => {
console.log(33333);
}
});
} else if (utils.isObject(val)) {
return new Proxy(val, {
set: () => {
console.log(33333);
}
});
} else {
return val;
}
}
return prop in obj ? obj[prop] : null;
},
set: (obj, prop, val) => {
if (this.#writeLock) {
console.log(111111);
} else {
Reflect.set(obj, prop, val);
}
return true;
}
};
}
getMetaName() {
return this._metaName;
}
}
exports.BaseWrap = BaseWrap;