From ed21546e8272a0862b1ebecffe46950f04a0eff8 Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Thu, 27 Oct 2022 04:28:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96=E5=8F=8Abug=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E5=BE=AE=E8=B0=83=E9=83=A8=E5=88=86=E8=A7=92=E8=89=B2=E5=9C=A3?= =?UTF-8?q?=E9=81=97=E7=89=A9=E8=AF=84=E5=88=86=E6=9D=83=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/character/ImgUpload.js | 25 ++++++++++++------------ apps/character/ProfileCommon.js | 7 +++---- apps/stat.js | 2 +- components/common-lib/render.js | 28 ++++++++++++++++++++++++++- models/MysApi.js | 7 ++++++- resources/meta/artifact/artis-mark.js | 13 +++++++------ 6 files changed, 57 insertions(+), 25 deletions(-) diff --git a/apps/character/ImgUpload.js b/apps/character/ImgUpload.js index 607a2ac1..fa93a81c 100644 --- a/apps/character/ImgUpload.js +++ b/apps/character/ImgUpload.js @@ -34,21 +34,22 @@ export async function uploadCharacterImg (e) { imageMessages.push(val) } } - let source - if (e.isGroup) { - // 支持at图片添加,以及支持后发送 - source = (await e.group.getChatHistory(e.source?.seq, 1)).pop() - } else { - source = (await e.friend.getChatHistory((e.source?.time + 1), 1)).pop() - } - if (source) { - for (let val of source.message) { - if (val.type === 'image') { - imageMessages.push(val) + if (imageMessages.length === 0) { + let source + if (e.isGroup) { + // 支持at图片添加,以及支持后发送 + source = (await e.group.getChatHistory(e.source?.seq, 1)).pop() + } else { + source = (await e.friend.getChatHistory((e.source?.time + 1), 1)).pop() + } + if (source) { + for (let val of source.message) { + if (val.type === 'image') { + imageMessages.push(val) + } } } } - if (imageMessages.length <= 0) { e.reply('消息中未找到图片,请将要发送的图片与消息一同发送或引用要添加的图像..') return true diff --git a/apps/character/ProfileCommon.js b/apps/character/ProfileCommon.js index de8b6163..85a80783 100644 --- a/apps/character/ProfileCommon.js +++ b/apps/character/ProfileCommon.js @@ -51,13 +51,12 @@ export async function getTargetUid (e) { } try { - let mys = await MysApi.init(e) + let user = await MysApi.initUser(e) - if (!mys || !mys.uid) { + if (!user || !user.uid) { return false } - - uid = mys.uid + uid = user.uid if (!uid || !uidReg.test(uid)) { e.reply('请先发送【#绑定+你的UID】来绑定查询目标') return false diff --git a/apps/stat.js b/apps/stat.js index 52b9f0f0..15b156e4 100644 --- a/apps/stat.js +++ b/apps/stat.js @@ -396,7 +396,7 @@ async function uploadData (e) { if (!Cfg.get('wiki.abyss', false) && !isMatch) { return false } - let mys = await MysApi.init(e, { auth: 'cookie' }) + let mys = await MysApi.init(e, { auth: 'all' }) if (!mys || !mys.uid) { if (isMatch) { e.reply(`请绑定ck后再使用${e.original_msg || e.msg}`) diff --git a/components/common-lib/render.js b/components/common-lib/render.js index 1ca726b0..207d3821 100644 --- a/components/common-lib/render.js +++ b/components/common-lib/render.js @@ -6,9 +6,35 @@ import { puppeteer } from '../../adapter/index.js' const plugin = 'miao-plugin' const _path = process.cwd() +// 尝试性接入,待稳定后替换 +let runtimeRender = async function (e, path, params, cfg) { + return e.runtime.render('miao-plugin', path, params, { + retType: cfg.retMsgId ? 'msgId' : 'default', + beforeRender ({ data }) { + let resPath = data.pluResPath + const layoutPath = process.cwd() + '/plugins/miao-plugin/resources/common/layout/' + return { + ...data, + _res_path: resPath, + _layout_path: layoutPath, + _tpl_path: process.cwd() + '/plugins/miao-plugin/resources/common/tpl/', + defaultLayout: layoutPath + 'default.html', + elemLayout: layoutPath + 'elem.html', + sys: { + scale: Cfg.scale(cfg.scale || 1), + copyright: `Created By Yunzai-Bot${Version.yunzai} & Miao-Plugin${Version.version}` + } + } + } + }) +} + export default async function (path, params, cfg) { - let [app, tpl] = path.split('/') let { e } = cfg + if (e.runtime) { + return runtimeRender(e, path, params, cfg) + } + let [app, tpl] = path.split('/') let layoutPath = process.cwd() + '/plugins/miao-plugin/resources/common/layout/' let resPath = `../../../../../plugins/${plugin}/resources/` Data.createDir(`data/html/${plugin}/${app}/${tpl}`, 'root') diff --git a/models/MysApi.js b/models/MysApi.js index 89a9384c..cd408771 100644 --- a/models/MysApi.js +++ b/models/MysApi.js @@ -18,7 +18,12 @@ export default class MysApi { cfg = { auth: cfg } } let { auth = 'all' } = cfg - let mys = await YzMysInfo.init(e, auth === 'cookie' ? 'detail' : 'roleIndex') + let mys = false + if (e.runtime) { + mys = await e.runtime.getMysInfo(auth) + } else { + mys = await YzMysInfo.init(e, auth === 'cookie' ? 'detail' : 'roleIndex') + } if (!mys) { return false } diff --git a/resources/meta/artifact/artis-mark.js b/resources/meta/artifact/artis-mark.js index 34b4010f..584a8aff 100644 --- a/resources/meta/artifact/artis-mark.js +++ b/resources/meta/artifact/artis-mark.js @@ -47,7 +47,7 @@ export const usefulAttr = { 申鹤: { hp: 0, atk: 100, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 云堇: { hp: 0, atk: 0, def: 100, cp: 50, cd: 50, mastery: 0, dmg: 40, phy: 0, recharge: 90, heal: 0 }, 荒泷一斗: { hp: 0, atk: 50, def: 100, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 30, heal: 0 }, - 五郎: { hp: 0, atk: 50, def: 100, cp: 50, cd: 50, mastery: 0, dmg: 25, phy: 0, recharge: 90, heal: 0 }, + 五郎: { hp: 0, atk: 75, def: 100, cp: 50, cd: 50, mastery: 0, dmg: 100, phy: 0, recharge: 75, heal: 0 }, 班尼特: { hp: 100, atk: 50, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 80, phy: 0, recharge: 55, heal: 100 }, 枫原万叶: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 行秋: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 75, heal: 0 }, @@ -72,21 +72,21 @@ export const usefulAttr = { 凝光: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 30, heal: 0 }, 北斗: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 刻晴: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 100, recharge: 0, heal: 0 }, - 托马: { hp: 100, atk: 50, def: 0, cp: 50, cd: 50, mastery: 0, dmg: 75, phy: 0, recharge: 90, heal: 0 }, + 托马: { hp: 90, atk: 55, def: 0, cp: 90, cd: 90, mastery: 0, dmg: 90, phy: 0, recharge: 55, heal: 0 }, 迪卢克: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 0, heal: 0 }, 诺艾尔: { hp: 0, atk: 50, def: 90, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 70, heal: 0 }, 旅行者: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 重云: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 0 }, - 七七: { hp: 0, atk: 100, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 60, phy: 70, recharge: 55, heal: 100 }, + 七七: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 55, heal: 100 }, 凯亚: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 30, heal: 0 }, 烟绯: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 30, heal: 0 }, 早柚: { hp: 0, atk: 50, def: 0, cp: 50, cd: 50, mastery: 100, dmg: 80, phy: 0, recharge: 55, heal: 100 }, 安柏: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 100, recharge: 0, heal: 0 }, 丽莎: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 0, heal: 0 }, 埃洛伊: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 0, heal: 0 }, - 辛焱: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 50, phy: 100, recharge: 0, heal: 0 }, - 砂糖: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 50, phy: 0, recharge: 55, heal: 0 }, - 雷泽: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 50, phy: 100, recharge: 0, heal: 0 }, + 辛焱: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 0, heal: 0 }, + 砂糖: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 75, phy: 0, recharge: 55, heal: 0 }, + 雷泽: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 0, heal: 0 }, 夜兰: { hp: 80, atk: 0, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 久岐忍: { hp: 100, atk: 50, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 100 }, 鹿野院平藏: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 30, heal: 0 }, @@ -98,4 +98,5 @@ export const usefulAttr = { 坎蒂丝: { hp: 75, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 妮露: { hp: 80, atk: 0, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 80, phy: 0, recharge: 30, heal: 0 }, 纳西妲: { hp: 0, atk: 55, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 100, phy: 0, recharge: 55, heal: 0 }, + 多莉: { hp: 75, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 75, phy: 0, recharge: 55, heal: 100 } }