diff --git a/CHANGELOG.md b/CHANGELOG.md index de3ae95c..634f5e3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 2.3.1 + +* MiaoApi面板服务更新 + * 使用新版接口获取面板,大幅提高响应速度 + * 使用statsIds存储圣遗物数据,能够更精确的计算角色属性 +* 部分已知问题调整或优化 + * 圣遗物、天赋更新策略及更新逻辑优化 + * `#面板`、`#角色`等页面使用Q版头像 + * 面板更新的提醒文案逻辑优化 + # 2.3.0 * 重写底层面板、角色数据获取与保存逻辑 diff --git a/apps/profile/ProfileList.js b/apps/profile/ProfileList.js index 110d20ef..98b4c714 100644 --- a/apps/profile/ProfileList.js +++ b/apps/profile/ProfileList.js @@ -96,7 +96,8 @@ const ProfileList = { let profile = profiles[id] let char = profile.char let tmp = char.getData('id,face,name,abbr,element,star') - tmp.face = char.getImgs(profile.costume).face + let imgs = char.getImgs(profile.costume) + tmp.face = imgs.qFace || imgs.face tmp.level = profile.level || 1 tmp.cons = profile.cons tmp.isNew = 0 diff --git a/apps/stat/AbyssTeam.js b/apps/stat/AbyssTeam.js index 4586a43d..c025a9e3 100644 --- a/apps/stat/AbyssTeam.js +++ b/apps/stat/AbyssTeam.js @@ -9,7 +9,7 @@ export async function AbyssTeam (e) { return true } let player = Player.create(e) - await player.refreshMysDetail() + await player.refreshMysDetail(2) await player.refreshTalent() let abyssData = await HutaoApi.getAbyssTeam() @@ -23,8 +23,8 @@ export async function AbyssTeam (e) { let data = {} let noAvatar = {} lodash.forEach(avatarData, (avatar) => { - let t = avatar.originalTalent - avatarRet[avatar.id] = Math.min(avatar.level, avatar.weapon?.level || 1) * 100 + Math.max(t?.a, t?.e, t?.q) * 1000 + let t = avatar.originalTalent || {} + avatarRet[avatar.id] = Math.min(avatar.level, (avatar.weapon?.level || 1)) * 100 + Math.max(t?.a || 1, t?.e || 1, t?.q || 1) * 1000 }) let getTeamCfg = (str) => { diff --git a/config/system/profile_system.js b/config/system/profile_system.js index 9ec801ad..e0c8beca 100644 --- a/config/system/profile_system.js +++ b/config/system/profile_system.js @@ -7,7 +7,7 @@ export const miaoApi = { listApi: ({ uid, diyCfg }) => { let qq = /\d{5,12}/.test(diyCfg.qq) ? diyCfg.qq : 'none' let token = diyCfg.token - return `http://miaoapi.cn/profile/data?uid=${uid}&qq=${qq}&token=${token}` + return `http://miaoapi.cn/profile/data?uid=${uid}&qq=${qq}&token=${token}&version=2` } } diff --git a/models/Player.js b/models/Player.js index 8f6097ec..8d54411b 100644 --- a/models/Player.js +++ b/models/Player.js @@ -1,6 +1,6 @@ /** * 用户数据文件 - * 数据存储在/data/userData/${uid}.json 下 + * 数据存储在/data/UserData/${uid}.json 下 * 兼容处理面板户数及Mys数据 * */ @@ -12,7 +12,7 @@ import { AvatarData, ProfileRank, Character } from './index.js' import MysAvatar from './player/MysAvatar.js' import Profile from './player/Profile.js' -Data.createDir('/data/userData', 'root') +Data.createDir('/data/UserData', 'root') export default class Player extends Base { constructor (uid) { diff --git a/models/ProfileReq.js b/models/ProfileReq.js index e59a13d8..29701290 100644 --- a/models/ProfileReq.js +++ b/models/ProfileReq.js @@ -58,20 +58,30 @@ export default class ProfileReq extends Base { async requestProfile (player, serv) { this.serv = serv - let reqParam = await serv.getReqParam(this.uid) + let uid = this.uid + let reqParam = await serv.getReqParam(uid) let cdTime = await this.inCd() if (cdTime && !process.argv.includes('web-debug')) { return this.err(`请求过快,请${cdTime}秒后重试..`) } await this.setCd(20) + let self = this + // 若3秒后还未响应则返回提示 + setTimeout(() => { + if (self._isReq) { + this.msg(`开始获取uid:${uid}的数据,可能会需要一定时间~`) + } + }, 3000) // 发起请求 - logger.mark(`面板请求UID:${this.uid},面板服务:${serv.name}...`) + logger.mark(`面板请求UID:${uid},面板服务:${serv.name}...`) let data = {} try { let params = reqParam.params || {} params.timeout = params.timeout || 1000 * 20 + self._isReq = true let req = await fetch(reqParam.url, params) data = await req.text() + self._isReq = false if (data[0] === '<') { let titleRet = /(.+)<\/title>/.exec(data) if (titleRet && titleRet[1]) { @@ -84,6 +94,7 @@ export default class ProfileReq extends Base { } } catch (e) { console.log('面板请求错误', e) + self._isReq = false data = {} } data = await serv.response(data, this) diff --git a/models/player/MiaoApi.js b/models/player/MiaoApi.js index 3ca3f4f9..905c0882 100644 --- a/models/player/MiaoApi.js +++ b/models/player/MiaoApi.js @@ -10,21 +10,40 @@ export default { if (data.status !== 0) { return req.err(data.msg || 'error', 60) } - data = data.data || {} - if (!data.showAvatarInfoList || data.showAvatarInfoList.length === 0) { - return req.err('empty', 5 * 60) + if (data.version === 2) { + data = data.data || {} + if (!data.avatars || data.avatars.length === 0) { + return req.err('empty', 5 * 60) + } + data.version = 2 + return data + } else { + data = data.data || {} + if (!data.showAvatarInfoList || data.showAvatarInfoList.length === 0) { + return req.err('empty', 5 * 60) + } + return data } - return data }, updatePlayer (player, data) { - player.setBasicData(Data.getData(data, 'name:nickname,face:profilePicture.avatarId,card:nameCardID,level,word:worldLevel,sign:signature')) - lodash.forEach(data.showAvatarInfoList, (ds) => { - let ret = MiaoData.setAvatar(player, ds) - if (ret) { - player._update.push(ret.id) - } - }) + if (data.version === 2) { + player.setBasicData(data) + lodash.forEach(data.avatars, (avatar) => { + let ret = MiaoData.setAvatarNew(player, avatar) + if (ret) { + player._update.push(ret.id) + } + }) + } else { + player.setBasicData(Data.getData(data, 'name:nickname,face:profilePicture.avatarId,card:nameCardID,level,word:worldLevel,sign:signature')) + lodash.forEach(data.showAvatarInfoList, (ds) => { + let ret = MiaoData.setAvatar(player, ds) + if (ret) { + player._update.push(ret.id) + } + }) + } }, // 获取冷却时间 diff --git a/models/player/MiaoData.js b/models/player/MiaoData.js index c43fdc49..3258b2cd 100644 --- a/models/player/MiaoData.js +++ b/models/player/MiaoData.js @@ -22,6 +22,17 @@ let MiaoData = { return avatar }, + setAvatarNew (player, ds) { + let char = Character.get(ds.id) + let avatar = player.getAvatar(ds.id, true) + let talentRet = MiaoData.getTalentNew(char.id, ds.talent) + avatar.setAvatar({ + ...ds, + elem: talentRet.elem + }, 'miao') + return avatar + }, + getWeapon (weapon) { return { name: weapon.name, @@ -31,6 +42,31 @@ let MiaoData = { } }, + getTalentNew (charid, data = {}) { + let char = Character.get(charid) + let { talentId = {}, talentElem = {}, talentKey = {} } = char.meta + let elem = '' + let idx = 0 + let ret = {} + lodash.forEach(data, (level, id) => { + let key + if (talentId[id]) { + let tid = talentId[id] + key = talentKey[tid] + elem = elem || talentElem[tid] + ret[key] = level + } else { + key = ['a', 'e', 'q'][idx] + ret[key] = level + } + idx++ + }) + return { + talent: ret, + elem + } + }, + getTalent (charid, data = {}) { let char = Character.get(charid) let { talentId = {}, talentElem = {}, talentKey = {} } = char.meta diff --git a/resources/character/profile-list.css b/resources/character/profile-list.css index 8e862fab..a68e46dd 100644 --- a/resources/character/profile-list.css +++ b/resources/character/profile-list.css @@ -107,10 +107,9 @@ body, width: 100%; } .cont-footer span { - width: 35%; + width: 50%; } .cont-footer .serv { - width: 65%; text-align: right; } .cont-footer .new-tip:before { diff --git a/resources/character/profile-list.html b/resources/character/profile-list.html index 2cf5e4fe..1a9ab9e6 100644 --- a/resources/character/profile-list.html +++ b/resources/character/profile-list.html @@ -55,14 +55,10 @@ {{if hasNew}} <span class="new-tip">本次更新角色</span> {{else}} - <span></span> + <span>{{if updateTime.profile }} 更新时间:{{updateTime.profile }} {{/if}}</span> {{/if}} <span class="serv"> 当前更新服务:{{servName}} - {{if updateTime.profile }} - <span>,更新时间:{{updateTime.profile }}</span> - {{/if}} - </span> </div> </div> diff --git a/resources/character/profile-list.less b/resources/character/profile-list.less index f68ed1f8..5048c5ad 100644 --- a/resources/character/profile-list.less +++ b/resources/character/profile-list.less @@ -128,11 +128,10 @@ body, .container { width: 100%; span { - width: 35%; + width: 50%; } .serv { - width: 65%; text-align: right; } diff --git a/resources/stat/abyss-team.html b/resources/stat/abyss-team.html index 96ff1e08..46549b79 100644 --- a/resources/stat/abyss-team.html +++ b/resources/stat/abyss-team.html @@ -44,7 +44,7 @@ <div class="card-list"> {{each teamData.teamArr id}} <div - class="card star{{avatars[id].star == 4 ? 4:5}} {{avatars[id].level*1 === 0 ? 'no-character':'has-character'}}"> + class="card star{{avatars[id].star == 4 ? 4:5}} {{ avatars[id].level*1 === 0 ? 'no-character':'has-character'}}"> <img class="role" src="{{_res_path}}{{avatars[id].face}}"/> <span class="cons cons-{{avatars[id].cons}} for-has">{{avatars[id].cons}}</span> <span class="lvl for-has">Lv.{{avatars[id].level}}</span>