适配新版MihomoApi

This commit is contained in:
Kokomi 2023-06-08 16:45:07 +08:00
parent 7adf52be39
commit 11b793019c
2 changed files with 21 additions and 21 deletions

View File

@ -38,7 +38,7 @@ export const hutaoApi = {
export const homoApi = { export const homoApi = {
url: 'https://api.mihomo.me/sr_info', url: 'https://api.mihomo.me/sr_info',
userAgent: 'Miao-Plugin/3.1', // userAgent: 'Miao-Plugin/3.1',
listApi: ({ url, uid, diyCfg }) => { listApi: ({ url, uid, diyCfg }) => {
return `${url}/${uid}` return `${url}/${uid}`
} }

View File

@ -16,17 +16,17 @@ export default {
// 处理服务返回 // 处理服务返回
async response (data, req) { async response (data, req) {
if (!data.PlayerDetailInfo) { if (!data.detailInfo) {
return req.err('error', 60) return req.err('error', 60)
} }
let ds = data.PlayerDetailInfo let ds = data.detailInfo
let ac = ds.AssistAvatar let ac = ds.assistAvatarDetail
let avatars = {} let avatars = {}
if (ac && !lodash.isEmpty(ac)) { if (ac && !lodash.isEmpty(ac)) {
avatars[ac.AvatarID] = ac avatars[ac.AvatarID] = ac
} }
lodash.forEach(ds.DisplayAvatarList, (ds) => { lodash.forEach(ds.avatarDetailList, (ds) => {
avatars[ds.AvatarID] = ds avatars[ds.avatarId] = ds
}) })
if (lodash.isEmpty(avatars)) { if (lodash.isEmpty(avatars)) {
@ -58,18 +58,18 @@ export default {
const HomoData = { const HomoData = {
setAvatar (player, data) { setAvatar (player, data) {
let char = Character.get(data.AvatarID) let char = Character.get(data.avatarId)
if (!char) { if (!char) {
return false return false
} }
let avatar = player.getAvatar(char.id, true) let avatar = player.getAvatar(char.id, true)
let setData = { let setData = {
level: data.Level, level: data.Level,
promote: data.Promotion, promote: data.promotion,
cons: data.Rank || 0, cons: data.rank || 0,
weapon: Data.getData(data.EquipmentID, 'id:ID,promote:Promotion,level:Level,affix:Rank'), weapon: Data.getData(data.equipment, 'id:tid,promote:promotion,level,affix:rank'),
...HomoData.getTalent(data.BehaviorList, char), ...HomoData.getTalent(data.skillTreeList, char),
artis: HomoData.getArtis(data.RelicList) artis: HomoData.getArtis(data.relicList)
} }
avatar.setAvatar(setData, 'homo') avatar.setAvatar(setData, 'homo')
return avatar return avatar
@ -78,11 +78,11 @@ const HomoData = {
let talent = {} let talent = {}
let trees = [] let trees = []
lodash.forEach(ds, (d) => { lodash.forEach(ds, (d) => {
let key = char.getTalentKey(d.BehaviorID) let key = char.getTalentKey(d.pointId)
if (key || d.Level > 1) { if (key || d.Level > 1) {
talent[key || d.BehaviorID] = d.Level talent[key || d.pointId] = d.level
} else { } else {
trees.push(d.BehaviorID) trees.push(d.pointId)
} }
}) })
return { talent, trees } return { talent, trees }
@ -91,16 +91,16 @@ const HomoData = {
let ret = {} let ret = {}
lodash.forEach(artis, (ds) => { lodash.forEach(artis, (ds) => {
let tmp = { let tmp = {
id: ds.ID, id: ds.tid,
level: ds.Level || 1, level: ds.level || 1,
mainId: ds.MainAffixID, mainId: ds.mainAffixId,
attrIds: [] attrIds: []
} }
lodash.forEach(ds.RelicSubAffix, (s) => { lodash.forEach(ds.subAffixList, (s) => {
if (!s.SubAffixID) { if (!s.affixId) {
return true return true
} }
tmp.attrIds.push([s.SubAffixID, s.Cnt, s.Step || 0].join(',')) tmp.attrIds.push([s.affixId, s.cnt, s.step || 0].join(','))
}) })
ret[ds.Type] = tmp ret[ds.Type] = tmp
}) })