mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
MiaoApi面板服务逻辑更新
This commit is contained in:
parent
b600d3799a
commit
d02a675649
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,3 +1,13 @@
|
||||
# 2.3.1
|
||||
|
||||
* MiaoApi面板服务更新
|
||||
* 使用新版接口获取面板,大幅提高响应速度
|
||||
* 使用statsIds存储圣遗物数据,能够更精确的计算角色属性
|
||||
* 部分已知问题调整或优化
|
||||
* 圣遗物、天赋更新策略及更新逻辑优化
|
||||
* `#面板`、`#角色`等页面使用Q版头像
|
||||
* 面板更新的提醒文案逻辑优化
|
||||
|
||||
# 2.3.0
|
||||
|
||||
* 重写底层面板、角色数据获取与保存逻辑
|
||||
|
@ -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
|
||||
|
@ -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) => {
|
||||
|
@ -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`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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>(.+)<\/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)
|
||||
|
@ -10,14 +10,32 @@ export default {
|
||||
if (data.status !== 0) {
|
||||
return req.err(data.msg || 'error', 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
|
||||
}
|
||||
},
|
||||
|
||||
updatePlayer (player, data) {
|
||||
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)
|
||||
@ -25,6 +43,7 @@ export default {
|
||||
player._update.push(ret.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 获取冷却时间
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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>
|
||||
|
@ -128,11 +128,10 @@ body, .container {
|
||||
width: 100%;
|
||||
|
||||
span {
|
||||
width: 35%;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.serv {
|
||||
width: 65%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user