diff --git a/apps/profile/ProfileDetail.js b/apps/profile/ProfileDetail.js index e1607820..f93a79c0 100644 --- a/apps/profile/ProfileDetail.js +++ b/apps/profile/ProfileDetail.js @@ -160,9 +160,7 @@ let ProfileDetail = { let artisDetail = profile.getArtisMark() let artisKeyTitle = ProfileArtis.getArtisKeyTitle() - let costumeSplash = profile.costumeSplash - // 渲染图像 - let msgRes = await Common.render('character/profile-detail', { + let renderData = { save_id: uid, uid, data: profile.getData('name,abbr,cons,level,weapon,talent,dataSource,updateTime,imgs,costumeSplash'), @@ -175,12 +173,14 @@ let ProfileDetail = { mode, wCfg, changeProfile: e._profileMsg - }, { e, scale: 1.6, retMsgId: true }) + } + // 渲染图像 + let msgRes = await Common.render('character/profile-detail', renderData, { e, scale: 1.6, retMsgId: true }) if (msgRes && msgRes.message_id) { // 如果消息发送成功,就将message_id和图片路径存起来,3小时过期 await redis.set(`miao:original-picture:${msgRes.message_id}`, JSON.stringify({ type: 'profile', - img: costumeSplash + img: renderData?.data?.costumeSplash }), { EX: 3600 * 3 }) } return true diff --git a/components/common/Render.js b/components/common/Render.js index 75ccebc4..d87be2a3 100644 --- a/components/common/Render.js +++ b/components/common/Render.js @@ -21,6 +21,9 @@ export default async function (path, params, cfg) { sys: { scale: Cfg.scale(cfg.scale || 1), copyright: `Created By Yunzai-Bot${Version.yunzai} & Miao-Plugin${Version.version}` + }, + pageGotoParams: { + waitUntil: 'networkidle2' } } } diff --git a/config/system/cfg_system.js b/config/system/cfg_system.js index 6a4734c0..b272f7cb 100644 --- a/config/system/cfg_system.js +++ b/config/system/cfg_system.js @@ -76,6 +76,12 @@ export const cfgSchema = { input: (n) => n * 1 === 1 ? 1 : 2, desc: '面板服务优先选择:1:自动(具备有效Token时优先喵喵Api,否则Enka),2:Enka服务优先' }, + costumeSplash: { + title: '使用自定义面板插图', + key: '面板图', + def: true, + desc: '开启彩蛋图(三皇冠/ACE/满命)及自定义面板图,关闭使用官方立绘' + }, teamCalc: { title: '组队加成伤害', key: '组队', diff --git a/models/MysApi.js b/models/MysApi.js index 2d8cd899..00e6c613 100644 --- a/models/MysApi.js +++ b/models/MysApi.js @@ -90,6 +90,9 @@ export default class MysApi { } let e = this.e let mys = await this.getMysApi(e, api, { log: false }) + if (!mys) { + return false + } let mysInfo = this.mysInfo || {} // 暂时先在plugin侧阻止错误,防止刷屏 e._original_reply = e._original_reply || e.reply diff --git a/models/Player.js b/models/Player.js index 8d54411b..e9863b61 100644 --- a/models/Player.js +++ b/models/Player.js @@ -27,7 +27,7 @@ export default class Player extends Base { } this.uid = uid this.reload() - return this._cache() + return this._cache(100) } get hasProfile () { diff --git a/models/ProfileData.js b/models/ProfileData.js index 1a7020be..d689543c 100644 --- a/models/ProfileData.js +++ b/models/ProfileData.js @@ -1,6 +1,6 @@ import lodash from 'lodash' import AvatarData from './AvatarData.js' -import { Data } from '../components/index.js' +import { Data, Cfg } from '../components/index.js' import { ProfileArtis, ProfileDmg } from './index.js' import AttrCalc from './profile/AttrCalc.js' import CharImg from './character/CharImg.js' @@ -18,14 +18,18 @@ export default class ProfileData extends AvatarData { return this.isProfile } - get imgs(){ - return this.char.getImgs(this.costume) + get imgs () { + return this.char.getImgs(this.costume) || {} } get costumeSplash () { let costume = this._costume costume = this.char.checkCostume(costume) ? '2' : '' + if (!Cfg.get('costumeSplash', true)) { + return this.char.getImgs(this._costume).splash + } + let nPath = `meta/character/${this.name}` let isSuper = false let talent = this.talent ? lodash.map(this.talent, (ds) => ds.original).join('') : '' diff --git a/models/ProfileDmg.js b/models/ProfileDmg.js index 6882c811..0a84bf68 100644 --- a/models/ProfileDmg.js +++ b/models/ProfileDmg.js @@ -193,10 +193,15 @@ export default class ProfileDmg extends Base { detail = detailMap[0] } + if (lodash.isFunction(detail)) { + let { attr } = DmgAttr.calcAttr({ originalAttr, buffs, meta }) + let ds = lodash.merge({ talent }, DmgAttr.getDs(attr, meta)) + detail = detail({ ...ds, attr, profile }) + } dmgDetail = { title: detail.title, - userIdx: detail.userIdx, - basicRet: lodash.merge({}, ret[detail.userIdx]), + userIdx: detail.userIdx || defDmgIdx, + basicRet: lodash.merge({}, ret[detail.userIdx] || ret[defDmgIdx]), attr: [] } diff --git a/models/profile/ArtisMark.js b/models/profile/ArtisMark.js index 470bf9e2..61a3b2aa 100644 --- a/models/profile/ArtisMark.js +++ b/models/profile/ArtisMark.js @@ -241,8 +241,10 @@ let ArtisMark = { hasAttr (artis) { for (let idx = 1; idx <= 5; idx++) { let ds = artis[idx] - if (ds && (!ds.name || !ds.main || !ds.attrs || !ds?.main?.key)) { - return false + if (ds) { + if (!ds.name || !ds.main || !ds.attrs || !ds?.main?.key) { + return false + } } } return true diff --git a/resources/character/profile-detail.html b/resources/character/profile-detail.html index e3c0b1f8..3e5e5860 100644 --- a/resources/character/profile-detail.html +++ b/resources/character/profile-detail.html @@ -8,7 +8,8 @@ {{set dataSource = data.dataSource}} {{set talentMap = {a: '普攻', e: '战技', q: '爆发'} }} -{{set {imgs,costumeSplash} = data }} +{{set {imgs, costumeSplash} = data }} +{{set imgs = imgs || {} }} {{block 'main'}}
@@ -142,7 +143,7 @@ -{{ set {dmgRet, dmgCfg, enemyName, dmgMsg, dmgData} = dmgCalc }} +{{ set {dmgRet, dmgCfg, enemyLv, enemyName, dmgMsg, dmgData} = dmgCalc }}
{{if mode === "profile"}}
@@ -152,7 +153,7 @@
{{/if}} - {{if dmgData.length > 0}} + {{if dmgData?.length > 0}}
伤害计算目标为{{enemyLv}}级{{enemyName||'小宝'}},如需调整等级可使用 #敌人等级{{enemyLv}} 来进行设置 @@ -188,7 +189,7 @@
{{if mode === "dmg"}} - {{if dmgCfg && dmgCfg.attr && dmgCfg.attr.length>0 && dmgRet && dmgRet.length >3}} + {{if dmgCfg && dmgCfg.attr && dmgCfg.attr.length>0 && dmgRet}}
词条伤害计算#{{data.abbr}}伤害{{dmgCfg.userIdx+1}}: 当前计算为[{{dmgCfg.title}}]