diff --git a/src/api_s2c/user/ApiChangeInfo.ts b/src/api_s2c/user/ApiChangeInfo.ts index fdb78f5..cc04798 100644 --- a/src/api_s2c/user/ApiChangeInfo.ts +++ b/src/api_s2c/user/ApiChangeInfo.ts @@ -8,11 +8,13 @@ export default async function (call: ApiCall) { // if (call.req.type == 'model' && !call.req.pos) return call.error(globalThis.lng.shiwu_6); - const active = (await G.mongodb.collection('playerInfo', 'playerInfo').findOne({ + let active = (await G.mongodb.collection('playerInfo', 'playerInfo').findOne({ uid: call.uid, type: 'playerInfo' }))?.active || {}; const fmtId = UserShared.getInfoId(call.req.type, call.req.id); + if (R.values(active).length == 0) active = UserShared.getActive(fmtId, call.conn.gud, call.req.type, call.req.id) + const isMeet = UserShared.chechIsActive(fmtId, { lv: call.conn.gud.lv, vip: call.conn.gud.vip, diff --git a/src/shared/public/user.ts b/src/shared/public/user.ts index 26b3bc5..11fcf6c 100644 --- a/src/shared/public/user.ts +++ b/src/shared/public/user.ts @@ -4,6 +4,22 @@ export class UserShared { return Array.from(arguments).filter(s => s != '').join('_'); } + // todo active始终为空,暂时获取对应的avtive,解决打包上线的圣诞版本, + // 后续要理清数据格式,填入playerinfo的active,包括user/infoOpen接口的返回 + static getActive(fmtId, player, type, id?) { + switch (type) { + case 'head': + return {[fmtId]: player.head?.time} + case 'headFrame': + return {[fmtId]: player.headFrames[id]} + case 'chatFrame': + return {[fmtId]: player.chatFrames[id]} + case 'model': + return {[fmtId]: player.model?.[id]?.time} + } + return {} + } + /** * 判断头像之类是否激活 * @param id 请使用 UserShared.getInfo 转化后的id @@ -18,8 +34,9 @@ export class UserShared { if (conf.cond[0] == 'lv') return collection.lv >= conf.cond[1]; else if (conf.cond[0] == 'vip') return collection.vip >= conf.cond[1]; else if (conf.cond[0] == 'hero') return collection.lsyx[conf.cond[1]] > 0; - else if (conf.cond[0] == 'time') return collection.active[fmtId] == -1 || collection.active[fmtId] > G.time; - else if (conf.cond[0] == 'model') return Object.values(collection.model).find(i=>i.id==conf.cond[1]); + // else if (conf.cond[0] == 'time') return collection.active[fmtId] == -1 || collection.active[fmtId] > G.time; + else if (conf.cond[0] == 'time') return conf.cond[1] == -1 || collection.active[fmtId] > G.time; + else if (conf.cond[0] == 'model') return Object.values(collection.model).find(i => i.id == conf.cond[1]); else return false; } } \ No newline at end of file