diff --git a/apps/character/avatar-card.js b/apps/character/avatar-card.js index 1755128f..0476662f 100644 --- a/apps/character/avatar-card.js +++ b/apps/character/avatar-card.js @@ -62,21 +62,28 @@ async function renderCard (e, ds, renderType = 'card') { // 计算皇冠个数 data.crownNum = lodash.filter(lodash.map(data.talent, (d) => d.original), (d) => d >= 10).length } + } else { + data = char.getData('id,name,sName') } let width = 600 + let imgCss = '' + let scale = 1.2 if (bg.mode === 'left') { - width = 600 * bg.width / bg.height + const height = 480 + width = height * bg.width / bg.height + imgCss = `img.bg{width:auto;height:${height}px;}` + scale = 1.45 } // 渲染图像 let msgRes = await Common.render('character/character-card', { saveId: uid, uid, bg, - widthStyle: ``, + widthStyle: ``, mode: bg.mode, custom, data - }, { e, scale: 1.4, retMsgId: true }) + }, { e, scale, retMsgId: true }) if (msgRes && msgRes.message_id) { // 如果消息发送成功,就将message_id和图片路径存起来,1小时过期 await redis.set(`miao:original-picture:${msgRes.message_id}`, bg.img, { EX: 3600 }) diff --git a/components/Data.js b/components/Data.js index 3fdafb03..08759177 100644 --- a/components/Data.js +++ b/components/Data.js @@ -91,6 +91,11 @@ let Data = { return {} }, + async importDefault (file, root) { + let ret = await Data.importModule(file, root) + return ret.default || {} + }, + async import (name) { return await Data.importModule(`components/optional-lib/${name}.js`) }, diff --git a/models/Artifact.js b/models/Artifact.js index d758960f..a03b0ec1 100644 --- a/models/Artifact.js +++ b/models/Artifact.js @@ -3,6 +3,7 @@ import lodash from 'lodash' import { Data } from '../components/index.js' let artisMap = {} +const abbr = await Data.importDefault('resources/meta/reliquaries/abbr.js') async function init () { let artis = Data.readJSON('resources/meta/reliquaries/data.json') @@ -14,46 +15,6 @@ async function init () { await init() -const abbr = { - 炽烈的炎之魔女: '魔女', - 昔日宗室之仪: '宗室', - 翠绿之影: '风套', - 千岩牢固: '千岩', - 流浪大地的乐团: '乐团', - 绝缘之旗印: '绝缘', - 被怜爱的少女: '少女', - 沉沦之心: '水套', - 角斗士的终幕礼: '角斗', - 冰风迷途的勇士: '冰套', - 逆飞的流星: '逆飞', - 苍白之火: '苍白', - 华馆梦醒形骸记: '华馆', - 战狂: '战狂', - 悠古的磐岩: '岩套', - 渡过烈火的贤人: '渡火', - 游医: '游医', - 教官: '教官', - 冒险家: '冒险', - 追忆之注连: '追忆', - 海染砗磲: '海染', - 如雷的盛怒: '如雷', - 染血的骑士道: '染血', - 平息鸣雷的尊者: '平雷', - 流放者: '流放', - 学士: '学士', - 行者之心: '行者', - 幸运儿: '幸运', - 勇士之心: '勇士', - 守护之心: '守护', - 武人: '武人', - 赌徒: '赌徒', - 奇迹: '奇迹', - 辰砂往生录: '辰砂', - 来歆余响: '余响', - 深林的记忆: '草套', - 饰金之梦: '饰金' -} - let Artifact = { // 根据圣遗物名称获取套装 diff --git a/models/Material.js b/models/Material.js index 054ac51c..47c526a2 100644 --- a/models/Material.js +++ b/models/Material.js @@ -4,6 +4,7 @@ import { Data } from '../components/index.js' import MaterialMeta from './material-lib/MaterialMeta.js' let data = Data.readJSON('resources/meta/material/data.json') +let abbr = await Data.importDefault('resources/meta/material/abbr.js') let mMap = {} let getItem = (ds) => { mMap[ds.name] = { @@ -44,10 +45,11 @@ class Material extends Base { } get abbr () { + let name = this.name if (this.type === 'talent') { - return Data.regRet(/「(.+)」/, this.name, 1) || this.name + return Data.regRet(/「(.+)」/, name, 1) || name } - return this.name + return abbr[name] || name } get title () { diff --git a/models/Weapon.js b/models/Weapon.js index b4171eb1..cd58401d 100644 --- a/models/Weapon.js +++ b/models/Weapon.js @@ -1,9 +1,10 @@ import lodash from 'lodash' import Base from './Base.js' import { Data } from '../components/index.js' -import WeaponMeta from './weapon/WeaponMeta.js' let data = Data.readJSON('resources/meta/weapons/data.json') +let abbr = await Data.importDefault('resources/meta/weapon/abbr.js') + let wData = {} lodash.forEach(data, (ds) => { wData[ds.name] = ds @@ -28,7 +29,7 @@ class Weapon extends Base { } get abbr () { - return WeaponMeta.getAbbr(this.name) + return abbr[this.name] || this.name } get title () { diff --git a/resources/character/character-card.css b/resources/character/character-card.css index 0067aada..c8178baf 100644 --- a/resources/character/character-card.css +++ b/resources/character/character-card.css @@ -299,30 +299,32 @@ body { background: url('../common/item/artifact-icon.webp') center no-repeat; background-size: 60% auto; } -.bottom-mode { - width: 600px; -} -.bottom-mode .char-title { - padding-top: 20px; -} -.bottom-mode .char-lv { - padding-top: 5px; -} -.bottom-mode .copyright { +.copyright { font-size: 12px; position: absolute; bottom: 0; margin: 0; right: 0; height: 25px; + left: 0; line-height: 25px; padding: 0 10px; + background: rgba(0, 0, 0, 0.5); + text-align: right; + z-index: 4; } -.bottom-mode .copyright.data-source { +.copyright.data-source { border-top: 1px solid rgba(255, 255, 255, 0.3); left: 0; text-align: left; - background: rgba(0, 0, 0, 0.5); + background: none; + z-index: 5; +} +.bottom-mode .char-title { + padding-top: 20px; +} +.bottom-mode .char-lv { + padding-top: 5px; } .bottom-mode .char-detail { position: absolute; @@ -365,31 +367,13 @@ body { padding-top: 5px; } .left-mode { - height: 600px; width: auto; } .left-mode .container { width: auto; } -.left-mode img.bg { - width: auto; - height: 600px; -} -.left-mode .copyright { - font-size: 12px; - position: absolute; - bottom: 0; - margin: 0; - right: 0; - height: 25px; - line-height: 25px; - padding: 0 10px; -} .left-mode .copyright.data-source { border-top: 1px solid rgba(255, 255, 255, 0.3); - left: 0; - text-align: left; - background: rgba(0, 0, 0, 0.5); } .left-mode .char-detail { position: absolute; diff --git a/resources/character/character-card.html b/resources/character/character-card.html index 6f1216ac..c8fcbede 100644 --- a/resources/character/character-card.html +++ b/resources/character/character-card.html @@ -10,7 +10,7 @@