修正一些数据异常导致的#角色卡片错误

This commit is contained in:
yoimiya-kokomi 2022-09-19 05:12:03 +08:00
parent 6f250dcf4a
commit 008a34d711
3 changed files with 4 additions and 68 deletions

View File

@ -30,7 +30,7 @@ export async function renderAvatar (e, avatar, renderType = 'card') {
avatar = { id: char.id, name: char.name, detail: false }
} else {
let profile = Profile.get(uid, char.id, true)
if (profile) {
if (profile && profile.hasData) {
// 优先使用Profile数据
avatar = profile
} else {
@ -101,69 +101,6 @@ async function renderCard (e, ds, renderType = 'card') {
return true
}
/*
* 获取角色数据
* */
function getCharacterData (data, char) {
let list = []
let set = {}
let artiEffect = []
let avatar = new Avatar(data)
if (!avatar) {
return {}
}
let ret = avatar.getData('dataType,dataSourceName,name,abbr,level,weapon')
console.log(ret)
let w = data.weapon || {}
let weapon = {
type: 'weapon',
name: w.name || '',
abbr: abbr[w.name] || w.name || '',
level: w.level || 1,
affix: w.affix || w.affix_level || 0
}
let artis = data?.artis?.artis || data.reliquaries
if (artis) {
lodash.forEach(artis, (val) => {
let setCfg = Artifact.getSetByArti(val.name)
if (!setCfg) {
return
}
let setName = setCfg.name
if (set[setName]) {
set[setName]++
if (set[setName] === 2) {
artiEffect.push('2件套' + setCfg.effect['2'])
}
if (set[setName] === 4) {
artiEffect.push('4件套' + setCfg.name)
}
} else {
set[setName] = 1
}
})
if (artiEffect.length === 0) {
artiEffect = ['无套装效果']
}
}
let reliquaries = list[0]
return {
name: char.name,
abbr: char.abbr,
level: Data.def(data.lv, data.level),
fetter: data.fetter,
cons: Data.def(data.cons, data.actived_constellation_num),
weapon,
artiEffect,
reliquaries
}
}
export async function getAvatarList (e, type, MysApi) {
let data = await MysApi.getCharacter()
if (!data) return false

View File

@ -49,8 +49,8 @@ export default class Avatar extends Base {
}
get artis () {
if (this.isProfile) {
return this.meta.artis
if (this.isProfile && this.meta?.artis) {
return this.meta.artis.toJSON()
}
if (this._artis) {
return this._artis

View File

@ -37,7 +37,7 @@
{{set talent = data.talent }}
{{set keys = ['a','e','q'] }}
{{ if talent.a && talent.a.level }}
{{ if talent && talent.a && talent.a.level }}
<div class="cont talent-cont elem-{{data.elem}}">
{{each keys key}}
<div class="talent-item">
@ -66,7 +66,6 @@
<div class="item">
<div class="item-icon"
style="background-image:url({{_res_path}}meta/reliquaries/icon/{{arti.name}}.png)"></div>
<span></span>
<span class="lv">{{arti.level}}</span>
</div>
{{/each}}