From 276dba9b7e8989ed2686ea736cf44596b26c7226 Mon Sep 17 00:00:00 2001 From: Kokomi <102026640+yoimiya-kokomi@users.noreply.github.com> Date: Thu, 23 Feb 2023 01:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E9=9D=A2=E6=9D=BF=E5=9B=BE=E5=BC=80?= =?UTF-8?q?=E5=85=B3=EF=BC=8C=E9=9D=A2=E6=9D=BF=E7=9B=B8=E5=85=B3=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E5=B7=B2=E7=9F=A5Bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/profile/ProfileDetail.js | 10 +++++----- components/common/Render.js | 3 +++ config/system/cfg_system.js | 6 ++++++ models/MysApi.js | 3 +++ models/Player.js | 2 +- models/ProfileData.js | 10 +++++++--- models/ProfileDmg.js | 9 +++++++-- models/profile/ArtisMark.js | 6 ++++-- resources/character/profile-detail.html | 9 +++++---- 9 files changed, 41 insertions(+), 17 deletions(-) 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'}}