From 5fe63f489605da42c3ae70abbeb418b50c6af03d Mon Sep 17 00:00:00 2001 From: Kokomi <102026640+yoimiya-kokomi@users.noreply.github.com> Date: Tue, 7 Feb 2023 02:08:12 +0800 Subject: [PATCH] =?UTF-8?q?*=20=E4=B8=BA`#=E5=96=B5=E5=96=B5=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE`=E5=A2=9E=E5=8A=A0=E6=9B=B4=E5=A4=9A=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9=20=20=20=20=20*=20=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E9=9D=A2=E6=9D=BF=E6=9B=BF=E6=8D=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20=20=20=20=20*=20=E5=85=81=E8=AE=B8=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E9=9D=9E=E5=AE=9E=E8=A3=85=E8=A7=92=E8=89=B2=E8=B5=84?= =?UTF-8?q?=E6=96=99=EF=BC=8C=E5=85=B3=E9=97=AD=E5=8F=AF=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E9=9D=9E=E5=AE=9E=E8=A3=85=E8=A7=92=E8=89=B2=E8=B5=84=E6=96=99?= =?UTF-8?q?=E5=8F=8A=E9=9D=A2=E6=9D=BF=E6=9B=BF=E6=8D=A2=20=20=20=20=20*?= =?UTF-8?q?=20=E5=8F=AF=E9=80=89=E6=8B=A9=E9=9D=A2=E6=9D=BF=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=EF=BC=8C=E5=8F=AF=E9=80=89=E5=96=B5=E5=96=B5Api?= =?UTF-8?q?=E4=BC=98=E5=85=88=EF=BC=88=E9=9C=80=E5=85=B7=E5=A4=87Token?= =?UTF-8?q?=EF=BC=89=E6=88=96Enka=E4=BC=98=E5=85=88=20*=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=BF=AA=E5=B8=8C=E9=9B=85=E3=80=81=E7=B1=B3=E5=8D=A1?= =?UTF-8?q?=E7=9A=84=E6=9C=80=E6=96=B0=E5=A4=A9=E8=B5=8B=E4=B8=8E=E5=91=BD?= =?UTF-8?q?=E5=BA=A7=E6=95=B0=E6=8D=AE=20*=20=E5=85=A8=E9=87=8F=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=80=9A=E8=BF=87=E5=B1=9E=E6=80=A7=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=BE=97=E5=88=B0=E7=9A=84=E9=9D=A2=E6=9D=BF=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 + apps/admin.js | 1 - apps/profile.js | 17 +- apps/profile/ProfileDetail.js | 4 +- apps/wiki.js | 4 + components/Cfg.js | 9 +- components/cfg-lib/cfg-data.js | 25 +- config/cfg_default.js | 50 --- config/system/cfg_system.js | 92 +++-- config/system/profile_system.js | 10 - models/ProfileData.js | 5 +- models/ProfileServ.js | 11 +- resources/admin/index.css | 4 +- resources/admin/index.less | 4 +- resources/character/profile-detail.html | 2 +- resources/meta/character/米卡/data.json | 10 +- resources/meta/character/米卡/detail.json | 236 +++++------ resources/meta/character/迪希雅/data.json | 6 +- .../meta/character/迪希雅/detail.json | 382 +++++++++++++----- tools/char-data.js | 2 +- 20 files changed, 512 insertions(+), 371 deletions(-) delete mode 100644 config/cfg_default.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 78a7f9e9..978c0b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 2.2.2 + +* 为`#喵喵设置`增加更多配置项 + * 允许禁用面板替换功能 + * 允许禁用非实装角色资料,关闭可禁用非实装角色资料及面板替换 + * 可选择面板服务,可选喵喵Api优先(需具备Token)或Enka优先 +* 更新迪希雅、米卡的最新天赋与命座数据 +* 全量使用通过属性计算得到的面板数据,移除相关配置项 + # 2.2.1 * 增加瑶瑶伤害计算 diff --git a/apps/admin.js b/apps/admin.js index 2c938279..c77bac84 100644 --- a/apps/admin.js +++ b/apps/admin.js @@ -2,7 +2,6 @@ import fs from 'fs' import lodash from 'lodash' import { exec } from 'child_process' import { Cfg, Common, Data, App } from '../components/index.js' -import { MysApi } from '../models/index.js' let keys = lodash.map(Cfg.getCfgSchemaMap(), (i) => i.key) let app = App.init({ diff --git a/apps/profile.js b/apps/profile.js index 49452373..05c1e067 100644 --- a/apps/profile.js +++ b/apps/profile.js @@ -1,4 +1,4 @@ -import { Common, App, Data } from '../components/index.js' +import { Common, App, Data, Cfg } from '../components/index.js' import { Character } from '../models/index.js' import { getTargetUid, getProfile, profileHelp } from './profile/ProfileCommon.js' import { profileArtis, profileArtisList } from './profile/ProfileArtis.js' @@ -125,6 +125,10 @@ export async function profileDetail (e) { let changeMsg = msg let pc = ProfileChange.matchMsg(msg) if (pc && pc.char && pc.change) { + if (!Cfg.get('profileChange')) { + e.reply('面板替换功能已禁用...') + return true + } e.uid = pc.uid || e.runtime.uid profileChange = ProfileChange.getProfile(e.uid, pc.char, pc.change) if (profileChange && profileChange.char) { @@ -183,9 +187,14 @@ export async function profileDetail (e) { e.reply('自定义角色暂不支持此功能') return true } - if (!char.isRelease && !profileChange) { - e.reply('角色尚未实装') - return true + if (!char.isRelease) { + if (!profileChange) { + e.reply('角色尚未实装') + return true + } else if (Cfg.get('notReleasedData') === false) { + e.reply('未实装角色面板已禁用...') + return true + } } if (mode === 'profile' || mode === 'dmg') { diff --git a/apps/profile/ProfileDetail.js b/apps/profile/ProfileDetail.js index 7ed792fc..dfeb1061 100644 --- a/apps/profile/ProfileDetail.js +++ b/apps/profile/ProfileDetail.js @@ -97,10 +97,10 @@ export async function renderProfile (e, char, mode = 'profile', params = {}) { let artisKeyTitle = ProfileArtis.getArtisKeyTitle() let imgs = char.getImgs(profile.costume) // 渲染图像 - let msgRes = await Common.render('character/profile-detail', { + let msgRes = await Common.render('character/profile-detail', { save_id: uid, uid, - data: avatar.getData('name,abbr,cons,level,weapon,talent,dataSource,updateTime,_attrCalc'), + data: avatar.getData('name,abbr,cons,level,weapon,talent,dataSource,updateTime'), attr, elem: char.elem, dmgData, diff --git a/apps/wiki.js b/apps/wiki.js index cdf9ddb3..f3ae3115 100644 --- a/apps/wiki.js +++ b/apps/wiki.js @@ -81,6 +81,10 @@ async function wiki (e) { e.reply('暂不支持自定义角色') return true } + if (!char.isRelease && Cfg.get('notReleasedData') === false) { + e.reply('未实装角色资料已禁用...') + return true + } let lvs = [] for (let i = 1; i <= 15; i++) { lvs.push('Lv' + i) diff --git a/components/Cfg.js b/components/Cfg.js index 3a66fdb6..ea4394ca 100644 --- a/components/Cfg.js +++ b/components/Cfg.js @@ -7,15 +7,8 @@ const _cfgPath = `${_path}/plugins/miao-plugin/components/` let cfg = {} try { - if (fs.existsSync(_cfgPath + 'cfg.json')) { - cfg = await cfgData.loadOldData() - cfgData.saveCfg(cfg) - fs.unlinkSync(_cfgPath + 'cfg.json') - } else { - cfg = await cfgData.getCfg() - cfgData.saveCfg(cfg) - } cfg = await cfgData.getCfg() + cfgData.saveCfg(cfg) } catch (e) { // do nth } diff --git a/components/cfg-lib/cfg-data.js b/components/cfg-lib/cfg-data.js index d7d759ca..856732a4 100644 --- a/components/cfg-lib/cfg-data.js +++ b/components/cfg-lib/cfg-data.js @@ -4,23 +4,6 @@ import { Data } from '../index.js' import fs from 'node:fs' let cfgData = { - async loadOldData () { - const _path = process.cwd() - const _cfgPath = `${_path}/plugins/miao-plugin/components/` - if (!fs.existsSync(_cfgPath + 'cfg.json')) { - return false - } - let old = Data.readJSON('/components/cfg.json') - let cfg = await Data.importModule('/config/cfg.js') - let ret = {} - lodash.forEach(cfgSchema, (cfgGroup) => { - lodash.forEach(cfgGroup.cfg, (cfgItem, cfgKey) => { - ret[cfgKey] = Data.def(cfg[cfgKey], cfgItem.oldCfgKey ? Data.getVal(old, cfgItem.oldCfgKey) : undefined, cfgItem.def) - }) - }) - return ret - }, - saveCfg (cfg) { let ret = [] lodash.forEach(cfgSchema, (cfgGroup) => { @@ -38,7 +21,13 @@ let cfgData = { }, async getCfg () { - return lodash.toPlainObject(await Data.importModule('/config/cfg.js')) + let ret = lodash.toPlainObject(await Data.importModule('/config/cfg.js')) + lodash.forEach(cfgSchema, (cfgGroup) => { + lodash.forEach(cfgGroup.cfg, (cfgItem, cfgKey) => { + ret[cfgKey] = Data.def(ret[cfgKey], cfgItem.def) + }) + }) + return ret }, getCfgSchemaMap () { diff --git a/config/cfg_default.js b/config/cfg_default.js deleted file mode 100644 index 8e0e0de9..00000000 --- a/config/cfg_default.js +++ /dev/null @@ -1,50 +0,0 @@ -/** ************ 【玩家&老婆卡片展示】 ************* */ -// 使用喵喵版角色卡片作为默认角色卡片功能 -export const avatarCard = true - -// 面板查询 -export const avatarProfile = true - -// 群面板排名 -export const groupRank = false - -// 可选值5~30,建议15。设置高排名人数会提高图片的长度,图片较大可能会影响渲染与发送速度 -export const rankNumber = 15 - -// 可选值4~100,建议28,最终圣遗物数量取决于面板内圣遗物数量。设置高圣遗物数量会提高图片的长度,图片较大可能会影响渲染与发送速度 -export const artisNumber = 28 - -// 使用【#上传深渊】功能取代【#深渊】功能,默认关闭 -export const uploadAbyssData = false - -// 使用【#面板练度统计】功能取代【#练度统计】功能,默认关闭 -export const profileStat = false - -// 老婆查询 -export const avatarWife = true - -// 戳一戳卡片 -export const avatarPoke = true - -// 数字分组 -export const commaGroup = 3 - -/** ************ 【角色资料与信息查询】 ************* */ -// #刻晴图鉴 的图鉴信息 -export const charWiki = true - -// #刻晴天赋/#刻晴命座 的天赋信息 -export const charWikiTalent = true - -// 角色图片 -export const charPic = true - -// 启用后会启用角色图及增量包中的小清新图像,勇士啊,你准备好了吗 -export const charPicSe = false - -/** ************ 【系统设置】 ************* */ -// 可选值50~200,建议100。设置高精度会提高图片的精细度,但因图片较大可能会影响渲染与发送速度 -export const renderScale = 100 - -// 开启后将使用喵喵版帮助作为Yunzai的默认帮助 -export const help = false diff --git a/config/system/cfg_system.js b/config/system/cfg_system.js index f8ca6a0b..6f86f3cc 100644 --- a/config/system/cfg_system.js +++ b/config/system/cfg_system.js @@ -1,20 +1,22 @@ export const cfgSchema = { - char: { - title: '玩家&老婆卡片展示', + profile: { + title: '角色面板相关设置', cfg: { - avatarCard: { - title: '角色查询', - key: '角色', - def: true, - desc: '使用喵喵版角色卡片作为默认角色卡片功能', - showDesc: false, - oldCfgKey: 'char.char' - }, avatarProfile: { title: '面板查询', - key: '面板', - def: true, - oldCfgKey: 'char.profile' + key: '面板查询', + def: true + }, + profileChange: { + title: '面板替换', + key: '面板替换', + def: true + }, + profileStat: { + title: '面板练度统计', + key: '练度统计', + def: false, + desc: '使用【#面板练度统计】功能取代【#练度统计】功能,默认关闭' }, groupRank: { title: '群面板排名', @@ -22,12 +24,6 @@ export const cfgSchema = { def: false, desc: '群内的面板伤害及圣遗物排名与查看功能,默认关闭。请根据群友心理素质自行决定是否开启' }, - teamCalc: { - title: '组队伤害', - key: '组队', - def: false, - desc: '组队伤害,测试阶段。开启后请重启喵喵' - }, groupRankLimit: { title: '排名限制', key: '限制', @@ -43,6 +39,20 @@ export const cfgSchema = { input: (n) => Math.min(30, Math.max(5, (n * 1 || 15))), desc: '可选值5~30,建议15。设置高排名人数会提高图片的长度,图片较大可能会影响渲染与发送速度' }, + profileServ: { + title: '面板服务', + key: '面板服务', + type: 'num', + def: 2, + input: (n) => n * 1 === 1 ? 1 : 2, + desc: '面板服务优先选择:1:自动(具备有效Token时优先喵喵Api,否则Enka),2:Enka服务优先' + }, + teamCalc: { + title: '组队加成伤害', + key: '组队', + def: false, + desc: '伤害计算包含组队Buff。目前为测试阶段,数据可能不准确,请慎重开启。数据为固定Buff而非真实面板数据,最终计算数值可能有偏差。开启后请重启喵喵' + }, artisNumber: { title: '圣遗物列表数量', key: '圣遗物数量', @@ -50,32 +60,34 @@ export const cfgSchema = { def: 28, input: (n) => Math.min(100, Math.max(4, (n * 1 || 28))), desc: '可选值4~100,建议28,最终圣遗物数量取决于面板内圣遗物数量。设置高圣遗物数量会提高图片的长度,图片较大可能会影响渲染与发送速度' + } + } + }, + char: { + title: '玩家&老婆卡片展示', + cfg: { + avatarCard: { + title: '角色查询', + key: '角色', + def: true, + desc: '使用喵喵版角色卡片作为默认角色卡片功能', + showDesc: false }, uploadAbyssData: { title: '上传深渊', key: '深渊', def: false, - oldCfgKey: 'wiki.abyss', desc: '使用【#上传深渊】功能取代【#深渊】功能,默认关闭' }, - profileStat: { - title: '面板练度统计', - key: '练度统计', - def: false, - oldCfgKey: 'profile.stat', - desc: '使用【#面板练度统计】功能取代【#练度统计】功能,默认关闭' - }, avatarWife: { title: '老婆查询', key: '老婆', - def: true, - oldCfgKey: 'char.wife' + def: true }, avatarPoke: { title: '戳一戳卡片', key: '戳一戳', - def: true, - oldCfgKey: 'char.poke' + def: true } } }, @@ -93,21 +105,23 @@ export const cfgSchema = { title: '角色图鉴-天赋', key: '天赋', def: true, - oldCfgKey: 'wiki.wiki', showDesc: false, desc: '#刻晴天赋/#刻晴命座 的天赋信息' }, + notReleasedData: { + title: '未实装角色数据', + key: '未实装', + def: true + }, charPic: { title: '角色图片', key: '图片', - def: true, - oldCfgKey: 'wiki.pic' + def: true }, charPicSe: { title: '小清新角色图', key: '小清新', def: false, - oldCfgKey: 'char.se', desc: '启用后会启用角色图及增量包中的小清新图像,勇士啊,你准备好了吗' } } @@ -121,14 +135,12 @@ export const cfgSchema = { type: 'num', def: 100, input: (n) => Math.min(200, Math.max(50, (n * 1 || 100))), - oldCfgKey: 'sys.scale', desc: '可选值50~200,建议100。设置高精度会提高图片的精细度,但因图片较大可能会影响渲染与发送速度' }, help: { title: '喵喵作为默认帮助', key: '帮助', def: false, - oldCfgKey: 'sys.help', desc: '开启后将使用喵喵版帮助作为Yunzai的默认帮助,默认关闭' }, commaGroup: { @@ -137,12 +149,6 @@ export const cfgSchema = { def: 3, type: 'num', desc: '根据语言习惯设置数字分组,如千位组设为3,万位组设为4' - }, - attrCalc: { - title: '面板计算属性', - key: '计算', - def: false, - desc: '使用基于武器&圣遗物计算的面板属性取代服务读取的面板数据,可规避双水buff等导致的一些面板数据错误。开启后部分角色属性可能会轻微变化,请根据需求开启关闭' } } } diff --git a/config/system/profile_system.js b/config/system/profile_system.js index a9f712c0..9ec801ad 100644 --- a/config/system/profile_system.js +++ b/config/system/profile_system.js @@ -3,16 +3,6 @@ * 如需自定义配置请复制修改上一级profile_default.js * */ -export const getProfileServ = ({ uid, serv, diyCfg }) => { - let { Miao, Enka } = serv - let token = diyCfg?.miaoApi?.token - let qq = diyCfg?.miaoApi?.qq - if (qq && token && token.length === 32 && !/^test/.test(token)) { - return Miao - } - return Enka -} - export const miaoApi = { listApi: ({ uid, diyCfg }) => { let qq = /\d{5,12}/.test(diyCfg.qq) ? diyCfg.qq : 'none' diff --git a/models/ProfileData.js b/models/ProfileData.js index 04a534d1..f086f849 100644 --- a/models/ProfileData.js +++ b/models/ProfileData.js @@ -1,7 +1,7 @@ import lodash from 'lodash' import Base from './Base.js' import moment from 'moment' -import { Data, Cfg } from '../components/index.js' +import { Data } from '../components/index.js' import { Character, ProfileArtis, ProfileDmg } from './index.js' import AttrCalc from './profile-lib/AttrCalc.js' @@ -21,7 +21,7 @@ export default class ProfileData extends Base { ds.talent && this.setTalent(ds.talent) this.artis = new ProfileArtis(this.id, this.elem) ds.artis && this.setArtis(ds.artis) - if (attrCalc && Cfg.get('attrCalc') && this.hasData) { + if (attrCalc && this.hasData) { this.calcAttr() } } @@ -37,7 +37,6 @@ export default class ProfileData extends Base { calcAttr () { this._attr = AttrCalc.create(this) this.attr = this._attr.calc() - this._attrCalc = true } setBasic (ds = {}) { diff --git a/models/ProfileServ.js b/models/ProfileServ.js index 6b492c06..18631c9a 100644 --- a/models/ProfileServ.js +++ b/models/ProfileServ.js @@ -1,6 +1,6 @@ import lodash from 'lodash' import Base from './Base.js' -import { Data } from '../components/index.js' +import { Data, Cfg } from '../components/index.js' let { sysCfg, diyCfg } = await Data.importCfg('profile') @@ -85,5 +85,12 @@ export default class ProfileServ extends Base { } ProfileServ.getServ = function ({ uid, serv }) { - return (diyCfg.getProfileServ || sysCfg.getProfileServ)({ uid, serv, diyCfg }) + let { Miao, Enka } = serv + let token = diyCfg?.miaoApi?.token + let qq = diyCfg?.miaoApi?.qq + + if (qq && token && token.length === 32 && !/^test/.test(token) && Cfg.get('profileServ') === 1) { + return Miao + } + return Enka } diff --git a/resources/admin/index.css b/resources/admin/index.css index edf01540..4098b4cc 100644 --- a/resources/admin/index.css +++ b/resources/admin/index.css @@ -1,11 +1,11 @@ body { transform: scale(1); - width: 700px; + width: 660px; } .container { background: url("./imgs/bg.png") #000144 left top no-repeat; background-size: 700px auto; - width: 700px; + width: 660px; } .head-box { margin: 0 0 80px 0; diff --git a/resources/admin/index.less b/resources/admin/index.less index 856e2bab..5c7acf74 100644 --- a/resources/admin/index.less +++ b/resources/admin/index.less @@ -1,12 +1,12 @@ body { transform: scale(1); - width: 700px; + width: 660px; } .container { background: url("./imgs/bg.png") #000144 left top no-repeat; background-size: 700px auto; - width:700px; + width:660px; } .head-box { diff --git a/resources/character/profile-detail.html b/resources/character/profile-detail.html index 426f467e..869524bb 100644 --- a/resources/character/profile-detail.html +++ b/resources/character/profile-detail.html @@ -56,7 +56,7 @@