修正Class Proxy导致的部分属性获取失败的问题

This commit is contained in:
yoimiya-kokomi 2022-09-11 21:10:38 +08:00
parent c9fe04952e
commit 3eba7b7c31
3 changed files with 13 additions and 24 deletions

View File

@ -5,17 +5,18 @@ let reFn = {}
export default class Base { export default class Base {
constructor () { constructor () {
return new Proxy(this, { let proxy = new Proxy(this, {
get (self, key) { get (self, key, receiver) {
if (key in self) { if (key in self) {
return self[key] return Reflect.get(self, key, receiver)
} }
if (self._get) { if (self._get) {
return self._get(key) return self._get.call(receiver, key)
} }
return (self._meta || self._data || self.meta || {})[key] return (self._meta || self._data || self.meta || {})[key]
} }
}) })
return proxy
} }
getData (arrList = '', cfg = {}) { getData (arrList = '', cfg = {}) {

View File

@ -125,7 +125,6 @@ export default class ProfileArtis extends Base {
return false return false
} }
}) })
console.log(attr, pos, mainAttr, check)
return check return check
} }

View File

@ -8,26 +8,15 @@ let artisBuffs = {}
let DmgBuffs = { let DmgBuffs = {
// 圣遗物Buff // 圣遗物Buff
getArtisBuffs (artis) { getArtisBuffs (artis = {}) {
if (!artis) {
return []
}
let buffs = artisBuffs let buffs = artisBuffs
let setMap = {}
lodash.forEach(artis, (arti, name) => {
if (lodash.isNumber(arti)) {
setMap[name] = arti
} else {
if (arti && arti.set) {
let name = arti.set
setMap[name] = (setMap[name] || 0) + 1
}
}
})
let retBuffs = [] let retBuffs = []
lodash.forEach(setMap, (count, setName) => { lodash.forEach(artis, (v, k) => {
if (count >= 2 && buffs[setName + 2]) { if (buffs[k + v]) {
retBuffs.push(buffs[setName + 2]) retBuffs.push(buffs[k + v])
}
if (count >= 4 && buffs[setName + 4]) {
retBuffs.push(buffs[setName + 4])
} }
}) })
return retBuffs return retBuffs
@ -55,7 +44,7 @@ let DmgBuffs = {
getBuffs (profile, buffs = []) { getBuffs (profile, buffs = []) {
let weaponBuffs = DmgBuffs.getWeaponBuffs(profile.weapon?.name || '') let weaponBuffs = DmgBuffs.getWeaponBuffs(profile.weapon?.name || '')
let artisBuffs = DmgBuffs.getArtisBuffs(profile.artis || {}) let artisBuffs = DmgBuffs.getArtisBuffs(profile.artis)
buffs = lodash.concat(buffs, weaponBuffs, artisBuffs) buffs = lodash.concat(buffs, weaponBuffs, artisBuffs)
let mKey = { let mKey = {
zf: '蒸发', zf: '蒸发',