diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e71593e..7eeb76d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,18 @@ -# 2.0.2 +# 2.0.3 + +* `#日历` 页面样式微调,功能升级 + * 日历中会展示角色生日 + * 日历会展示本日可刷天赋角色列表(暂未完成) +* 一些已知问题修复 + +# 2.0.1~2.0.2 * 添加 纳西妲、莱依拉 的天赋及命座数据 * 可通过 `#草神天赋``#草神命座``#草神图鉴`查看 -* 优化character的进入判定逻辑,防止一些额外的log触发 -* 角色相关命令在V3下会联合V3的角色别名一同查询 - -# 2.0.1 - * 支持Enka获取3.1新角色及新武器的数据 * 新角色及新武器暂未支持伤害计算,稍晚会升级 -* 补充坎蒂丝、赛诺的角色图像 +* 优化character的进入判定逻辑,防止一些额外的log触发 +* 角色相关命令在V3下会联合V3的角色别名一同查询 # 2.0.0 diff --git a/apps/character.js b/apps/character.js index c2f46ff0..ffba3f15 100644 --- a/apps/character.js +++ b/apps/character.js @@ -1,9 +1,9 @@ import { Common, App } from '../components/index.js' import { Character } from '../models/index.js' -import { renderAvatar } from './character/avatar-card.js' -import { uploadCharacterImg } from './character/character-img-upload.js' -import { wife, wifeReg } from './character/avatar-wife.js' -import { getOriginalPicture } from './character/utils.js' +import { renderAvatar } from './character/AvatarCard.js' +import { uploadCharacterImg } from './character/ImgUpload.js' +import { wife, wifeReg } from './character/AvatarWife.js' +import { getOriginalPicture } from './character/ProfileUtils.js' let app = App.init({ id: 'character', diff --git a/apps/character/avatar-card.js b/apps/character/AvatarCard.js similarity index 97% rename from apps/character/avatar-card.js rename to apps/character/AvatarCard.js index e525d068..acd190c7 100644 --- a/apps/character/avatar-card.js +++ b/apps/character/AvatarCard.js @@ -14,7 +14,7 @@ export async function renderAvatar (e, avatar, renderType = 'card') { let mys = await MysApi.init(e) if (!mys) return true uid = mys.uid - if (!char.isArrive) { + if (!char.isRelease) { avatar = { id: char.id, name: char.name, detail: false } } else { let profile = Profile.get(uid, char.id, true) @@ -52,8 +52,8 @@ async function renderCard (e, ds, renderType = 'card') { let uid = e.uid || (e.targetUser && e.targetUser.uid) let data = {} let custom = char.isCustom - let arrive = char.isArrive - if (arrive) { + let isRelease = char.isRelease + if (isRelease) { let mys = await MysApi.init(e) let avatar = new Avatar(ds, uid, mys.isSelfCookie) data = avatar.getData('id,name,sName,level,fetter,cons,weapon,elem,artis,artisSet,imgs,dataSourceName,updateTime') @@ -83,7 +83,7 @@ async function renderCard (e, ds, renderType = 'card') { widthStyle: ``, mode: bg.mode, custom, - arrive, + isRelease, data }, { e, scale, retMsgId: true }) if (msgRes && msgRes.message_id) { diff --git a/apps/character/avatar-wife.js b/apps/character/AvatarWife.js similarity index 98% rename from apps/character/avatar-wife.js rename to apps/character/AvatarWife.js index e3e73a06..00301db6 100644 --- a/apps/character/avatar-wife.js +++ b/apps/character/AvatarWife.js @@ -2,7 +2,7 @@ import lodash from 'lodash' import { Cfg } from '../../components/index.js' import { Character, MysApi } from '../../models/index.js' -import { getAvatarList, renderAvatar } from './avatar-card.js' +import { getAvatarList, renderAvatar } from './AvatarCard.js' const relationMap = { wife: { diff --git a/apps/character/character-img-upload.js b/apps/character/ImgUpload.js similarity index 100% rename from apps/character/character-img-upload.js rename to apps/character/ImgUpload.js diff --git a/apps/character/profile-artis.js b/apps/character/ProfileArtis.js similarity index 96% rename from apps/character/profile-artis.js rename to apps/character/ProfileArtis.js index ae8d0024..4c3ac0cc 100644 --- a/apps/character/profile-artis.js +++ b/apps/character/ProfileArtis.js @@ -4,7 +4,7 @@ * */ import lodash from 'lodash' import { Profile, Common } from '../../components/index.js' -import { getTargetUid, profileHelp, autoGetProfile } from './profile-common.js' +import { getTargetUid, profileHelp, autoGetProfile } from './ProfileCommon.js' import { Artifact, Character } from '../../models/index.js' /* diff --git a/apps/character/profile-common.js b/apps/character/ProfileCommon.js similarity index 99% rename from apps/character/profile-common.js rename to apps/character/ProfileCommon.js index 1c8094bf..de8b6163 100644 --- a/apps/character/profile-common.js +++ b/apps/character/ProfileCommon.js @@ -3,7 +3,7 @@ * */ import lodash from 'lodash' import { segment } from 'oicq' -import { profileList } from './profile-list.js' +import { profileList } from './ProfileList.js' import { Profile, Version } from '../../components/index.js' import { Character, MysApi } from '../../models/index.js' diff --git a/apps/character/profile-detail.js b/apps/character/ProfileDetail.js similarity index 98% rename from apps/character/profile-detail.js rename to apps/character/ProfileDetail.js index b6a6ee36..e691bd67 100644 --- a/apps/character/profile-detail.js +++ b/apps/character/ProfileDetail.js @@ -1,5 +1,5 @@ import lodash from 'lodash' -import { autoRefresh } from './profile-common.js' +import { autoRefresh } from './ProfileCommon.js' import { Common, Format, Profile } from '../../components/index.js' import { MysApi, Avatar } from '../../models/index.js' diff --git a/apps/character/profile-list.js b/apps/character/ProfileList.js similarity index 95% rename from apps/character/profile-list.js rename to apps/character/ProfileList.js index d8e75193..fcb9975e 100644 --- a/apps/character/profile-list.js +++ b/apps/character/ProfileList.js @@ -1,5 +1,5 @@ import lodash from 'lodash' -import { autoRefresh, getTargetUid } from './profile-common.js' +import { autoRefresh, getTargetUid } from './ProfileCommon.js' import { Common, Profile } from '../../components/index.js' export async function profileList (e) { diff --git a/apps/character/profile-stat.js b/apps/character/ProfileStat.js similarity index 100% rename from apps/character/profile-stat.js rename to apps/character/ProfileStat.js diff --git a/apps/character/utils.js b/apps/character/ProfileUtils.js similarity index 100% rename from apps/character/utils.js rename to apps/character/ProfileUtils.js diff --git a/apps/help.js b/apps/help.js index a1ed458b..1766f9cf 100644 --- a/apps/help.js +++ b/apps/help.js @@ -1,7 +1,7 @@ import lodash from 'lodash' import fs from 'fs' import { Cfg, Version, Common, Data, App } from '../components/index.js' -import Theme from './help/theme.js' +import HelpTheme from './help/HelpTheme.js' let app = App.init({ id: 'help', @@ -74,7 +74,7 @@ async function help (e) { helpGroup.push(group) }) - let themeData = await Theme.getThemeData(diyCfg.helpCfg || {}, sysCfg.helpCfg || {}) + let themeData = await HelpTheme.getThemeData(diyCfg.helpCfg || {}, sysCfg.helpCfg || {}) return await Common.render('help/index', { helpCfg: helpConfig, helpGroup, diff --git a/apps/help/theme.js b/apps/help/HelpTheme.js similarity index 93% rename from apps/help/theme.js rename to apps/help/HelpTheme.js index 99bc3fc0..7d36a5ec 100644 --- a/apps/help/theme.js +++ b/apps/help/HelpTheme.js @@ -2,7 +2,7 @@ import lodash from 'lodash' import fs from 'fs' import { Data } from '../../components/index.js' -let Theme = { +let HelpTheme = { async getThemeCfg (theme, exclude) { let dirPath = './plugins/miao-plugin/resources/help/theme/' let ret = [] @@ -37,7 +37,7 @@ let Theme = { let colCount = Math.min(5, Math.max(parseInt(helpConfig?.colCount) || 3, 2)) let colWidth = Math.min(500, Math.max(100, parseInt(helpConfig?.colWidth) || 265)) let width = Math.min(2500, Math.max(800, colCount * colWidth + 30)) - let theme = await Theme.getThemeCfg(diyStyle.theme || sysStyle.theme, diyStyle.themeExclude || sysStyle.themeExclude) + let theme = await HelpTheme.getThemeCfg(diyStyle.theme || sysStyle.theme, diyStyle.themeExclude || sysStyle.themeExclude) let themeStyle = theme.style || {} let ret = [` body{background-image:url(${theme.bg});width:${width}px;} @@ -65,4 +65,4 @@ let Theme = { } } } -export default Theme +export default HelpTheme diff --git a/apps/poke.js b/apps/poke.js index 051364f7..a838051c 100644 --- a/apps/poke.js +++ b/apps/poke.js @@ -1,5 +1,5 @@ import { App } from '../components/index.js' -import { pokeWife } from './character/avatar-wife.js' +import { pokeWife } from './character/AvatarWife.js' let app = App.init({ id: 'poke', diff --git a/apps/profile.js b/apps/profile.js index 254d49c9..70e00e61 100644 --- a/apps/profile.js +++ b/apps/profile.js @@ -1,11 +1,11 @@ import { Common, Cfg, App } from '../components/index.js' import { Character } from '../models/index.js' -import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/profile-common.js' -import { profileArtis, profileArtisList } from './character/profile-artis.js' -import { renderProfile } from './character/profile-detail.js' -import { profileStat } from './character/profile-stat.js' -import { profileList } from './character/profile-list.js' -import { enemyLv } from './character/utils.js' +import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/ProfileCommon.js' +import { profileArtis, profileArtisList } from './character/ProfileArtis.js' +import { renderProfile } from './character/ProfileDetail.js' +import { profileStat } from './character/ProfileStat.js' +import { profileList } from './character/ProfileList.js' +import { enemyLv } from './character/ProfileUtils.js' let app = App.init({ id: 'profile', @@ -126,7 +126,7 @@ export async function profileDetail (e) { e.reply('自定义角色暂不支持此功能') return true } - if (!char.isArrive) { + if (!char.isRelease) { e.reply('角色尚未实装') return true } diff --git a/apps/wiki.js b/apps/wiki.js index e5b7f9ba..bc73b965 100644 --- a/apps/wiki.js +++ b/apps/wiki.js @@ -1,6 +1,6 @@ import { segment } from 'oicq' import lodash from 'lodash' -import Calendar from './wiki/calendar.js' +import Calendar from './wiki/Calendar.js' import { Format, Cfg, Common, App } from '../components/index.js' import { Character } from '../models/index.js' import CharWiki from './wiki/CharWiki.js' diff --git a/apps/wiki/calendar.js b/apps/wiki/Calendar.js similarity index 93% rename from apps/wiki/calendar.js rename to apps/wiki/Calendar.js index 99a10f5f..ce95645b 100644 --- a/apps/wiki/calendar.js +++ b/apps/wiki/Calendar.js @@ -117,6 +117,7 @@ let Cal = { let dateList = [] let month = 0 let date = [] + let week = [] let startDate, endDate @@ -131,16 +132,20 @@ let Cal = { if (month !== m && date.length > 0) { dateList.push({ month, - date + date, + week }) date = [] + week = [] month = m } date.push(d) + week.push(temp.weekday()) if (idx === 12) { dateList.push({ month, - date + date, + week }) endDate = temp.format('YYYY-MM-DD') } @@ -159,6 +164,7 @@ let Cal = { } }, + // 深渊日历信息 getAbyssCal (s1, e1) { let now = moment() let check = [] @@ -185,6 +191,25 @@ let Cal = { return ret }, + getCharData (dateList) { + let charBirth = {} + lodash.forEach(dateList, (m) => { + lodash.forEach(m.date, (d) => { + charBirth[`${m.month}-${d}`] = [] + }) + }) + Character.forEach((char) => { + if (charBirth[char.birth]) { + charBirth[char.birth].push(char.getData('id,sName,star,face')) + } + }, 'release') + let charNum = 0 + lodash.forEach(charBirth, (charList) => { + charNum = Math.max(charNum, charList.length) + }) + return { charBirth, charNum } + }, + getList (ds, target, { startTime, endTime, totalRange, now, timeMap = {} }, isAct = false) { let type = isAct ? 'activity' : 'normal' let id = ds.ann_id @@ -322,6 +347,7 @@ let Cal = { return { ...dl, + ...Cal.getCharData(dl.dateList), list: ret, abyss, charMode: `char-${charCount}-${charOld}`, diff --git a/models/Character.js b/models/Character.js index 2714d8d2..3a96279f 100644 --- a/models/Character.js +++ b/models/Character.js @@ -12,7 +12,11 @@ import CharTalent from './character-lib/CharTalent.js' import CharId from './character-lib/CharId.js' import CharMeta from './character-lib/CharMeta.js' -let { abbrMap, wifeMap, idSort } = CharId +let { abbrMap, wifeMap, idSort, idMap } = CharId + +let getMeta = function (name) { + return Data.readJSON(`resources/meta/character/${name}/data.json`) +} class Character extends Base { constructor ({ id, name = '', elem = '' }) { @@ -38,12 +42,13 @@ class Character extends Base { // 默认获取的数据 _dataKey = 'id,name,abbr,title,star,elem,allegiance,weapon,birthday,astro,cncv,jpcv,ver,desc,talentCons' - // 是否为自定义角色 - get isCustom () { - return !/[12]0\d{6}/.test(this._id) + // 是否为官方角色 + get isOfficial () { + return /[12]0\d{6}/.test(this._id) } - get isArrive () { + // 是否为实装官方角色 + get isRelease () { if (this.isCustom) { return false } @@ -53,10 +58,16 @@ class Character extends Base { return true } + // 是否为自定义角色 + get isCustom () { + return !/[12]0\d{6}/.test(this._id) + } + get id () { return this.isCustom ? this._id : this._id * 1 } + // 获取短名字 get sName () { let name = this.name let abbr = this.abbr @@ -86,6 +97,7 @@ class Character extends Base { return CharId.getElemName(this.elem) } + // 获取角色描述 get desc () { return CharMeta.getDesc(this.meta.desc || '') } @@ -126,6 +138,7 @@ class Character extends Base { return CharMeta.getLvStat(this) } + // 获取生日 get birthday () { let birth = this.birth if (!birth) { @@ -195,6 +208,8 @@ class Character extends Base { return this._detail } + // 设置旅行者数据 + // TODO:迁移至Avatar setTraveler (uid = '') { if (this.isTraveler && uid && uid.toString().length === 9) { Data.setCacheJSON(`miao:uid-traveler:${uid}`, { @@ -204,6 +219,7 @@ class Character extends Base { } } + // 获取旅行者数据 async getTraveler (uid) { if (this.isTraveler) { let tData = await Data.getCacheJSON(`miao:uid-traveler:${uid}`) @@ -234,34 +250,52 @@ class Character extends Base { } return await this.getTraveler(uid) } -} -let getMeta = function (name) { - return Data.readJSON(`resources/meta/character/${name}/data.json`) -} - -Character.get = function (val) { - let id = CharId.getId(val) - if (!id) { - return false + // 基于角色名获取Character + static get (val) { + let id = CharId.getId(val) + if (!id) { + return false + } + return new Character(id) } - return new Character(id) -} -Character.getAvatar = async function (name, uid) { - let char = Character.get(name) - return await char.getTraveler(uid) -} -Character.getAbbr = function () { - return abbrMap -} + static forEach (fn, type = 'all') { + lodash.forEach(idMap, (name, id) => { + let char = Character.get({ id, name }) + if (type === 'release' && !char.isRelease) { + return true + } + if (type === 'official' && !char.isCustom) { + return true + } + return fn(char) !== false + }) + } -Character.checkWifeType = function (charid, type) { - return !!wifeMap[type][charid] -} + // 基于角色名获取Character + // 当获取角色为旅行者时,会考虑当前uid的账号情况返回对应旅行者 + static async getAvatar (name, uid) { + let char = Character.get(name) + return await char.getTraveler(uid) + } -Character.sortIds = function (arr) { - return arr.sort((a, b) => (idSort[a] || 300) - (idSort[b] || 300)) + // 获取别名数据 + // TODO:待废弃 + static getAbbr () { + return abbrMap + } + + // 检查wife类型 + // TODO:待废弃 + static checkWifeType (charid, type) { + return !!wifeMap[type][charid] + } + + // 获取排序ID + static sortIds (arr) { + return arr.sort((a, b) => (idSort[a] || 300) - (idSort[b] || 300)) + } } export default Character diff --git a/models/ProfileDmg.js b/models/ProfileDmg.js index 15391a6a..841eedcc 100644 --- a/models/ProfileDmg.js +++ b/models/ProfileDmg.js @@ -2,7 +2,7 @@ import fs from 'fs' import lodash from 'lodash' import Base from './Base.js' import { Character } from './index.js' -import { attrMap } from './profile-lib/calc-meta.js' +import { attrMap } from './profile-lib/DmgCalcMeta.js' import DmgBuffs from './profile-lib/DmgBuffs.js' import DmgAttr from './profile-lib/DmgAttr.js' import DmgCalc from './profile-lib/DmgCalc.js' diff --git a/models/character-lib/CharId.js b/models/character-lib/CharId.js index f6dfed28..6d4a293a 100644 --- a/models/character-lib/CharId.js +++ b/models/character-lib/CharId.js @@ -1,3 +1,6 @@ +/* +* 角色别名及角色ID相关 +* */ import lodash from 'lodash' import { Data } from '../../components/index.js' import { charPosIdx, elemAlias } from './CharMeta.js' diff --git a/models/character-lib/CharImg.js b/models/character-lib/CharImg.js index bee0c1f7..95af637c 100644 --- a/models/character-lib/CharImg.js +++ b/models/character-lib/CharImg.js @@ -1,3 +1,6 @@ +/* +* 角色照片及角色图像资源相关 +* */ import fs from 'fs' import lodash from 'lodash' import sizeOf from 'image-size' diff --git a/models/character-lib/CharMeta.js b/models/character-lib/CharMeta.js index 80142518..7f29430e 100644 --- a/models/character-lib/CharMeta.js +++ b/models/character-lib/CharMeta.js @@ -1,3 +1,6 @@ +/* +* 角色资料数据相关 +* */ import lodash from 'lodash' import { Material } from '../index.js' import { Format, Data } from '../../components/index.js' diff --git a/models/character-lib/CharTalent.js b/models/character-lib/CharTalent.js index 48badeb1..c28a5ea4 100644 --- a/models/character-lib/CharTalent.js +++ b/models/character-lib/CharTalent.js @@ -1,3 +1,6 @@ +/* +* 角色天赋相关处理 +* */ import lodash from 'lodash' const CharTalent = { diff --git a/models/profile-lib/DmgAttr.js b/models/profile-lib/DmgAttr.js index d0120335..34eeafc0 100644 --- a/models/profile-lib/DmgAttr.js +++ b/models/profile-lib/DmgAttr.js @@ -1,7 +1,7 @@ /* * 伤害计算 - 属性计算 * */ -import { attrMap, eleMap } from './calc-meta.js' +import { attrMap, eleMap } from './DmgCalcMeta.js' import lodash from 'lodash' import DmgMastery from './DmgMastery.js' import { Format } from '../../components/index.js' diff --git a/models/profile-lib/DmgCalc.js b/models/profile-lib/DmgCalc.js index baf1233d..3a66757d 100644 --- a/models/profile-lib/DmgCalc.js +++ b/models/profile-lib/DmgCalc.js @@ -1,7 +1,7 @@ /* * 伤害计算 - 计算伤害 * */ -import { eleBaseDmg } from './calc-meta.js' +import { eleBaseDmg } from './DmgCalcMeta.js' import DmgMastery from './DmgMastery.js' let DmgCalc = { diff --git a/models/profile-lib/calc-meta.js b/models/profile-lib/DmgCalcMeta.js similarity index 100% rename from models/profile-lib/calc-meta.js rename to models/profile-lib/DmgCalcMeta.js diff --git a/models/profile-lib/DmgMastery.js b/models/profile-lib/DmgMastery.js index d1273901..47d34425 100644 --- a/models/profile-lib/DmgMastery.js +++ b/models/profile-lib/DmgMastery.js @@ -1,4 +1,4 @@ -import { erType } from './calc-meta.js' +import { erType } from './DmgCalcMeta.js' let DmgMastery = { getMultiple (type = 'zf', mastery = 0) { diff --git a/resources/wiki/calendar.css b/resources/wiki/calendar.css index 3c796ba0..b829c3bb 100644 --- a/resources/wiki/calendar.css +++ b/resources/wiki/calendar.css @@ -58,22 +58,64 @@ body { .cal-bg td.date { width: 7.692%; } +.cal-bg td.date span { + display: block; + line-height: 18px; +} +.cal-bg td.date span.date-week { + line-height: 12px; + font-size: 12px; + color: #888; +} .cal-bg td.date.current-date { background: #d3bc8e; border: 1px solid #d3bc8e; color: #000; } +.cal-bg td.date.current-date span.date-week { + color: #000; +} .cal-bg td.line { background: rgba(0, 0, 0, 0.4); + vertical-align: top; } .cal-bg td.line.current-date { background: rgba(211, 188, 142, 0.4); } +.cal-bg .card { + width: 65px; + height: 76px; + margin: 8px auto -4px; +} +.cal-bg .card .img { + height: 60px; +} +.cal-bg .card .char-name { + position: absolute; + bottom: 0; + left: 0; + right: 0; + line-height: 17px; + font-size: 12px; + background: #e8e2d8; +} .cal-list { position: relative; padding-top: 80px; overflow: hidden; } +.cal-list.char-num-0 { + padding-top: 80px; +} +.cal-list.char-num-1 { + padding-top: 160px; +} +.cal-list.char-num-2 { + padding-top: 240px; +} +.cal-list.char-num-3 { + padding-top: 320px; +} .cal-list .cal-item { margin-bottom: 15px; border-radius: 5px; diff --git a/resources/wiki/calendar.html b/resources/wiki/calendar.html index 0bf74955..8df60e15 100644 --- a/resources/wiki/calendar.html +++ b/resources/wiki/calendar.html @@ -5,6 +5,7 @@ {{/block}} {{block 'main'}} +{{set weekName = '一二三四五六日'.split('')}}
{{dn}}日 | + {{each dateList d}}{{each d.date dn di}} ++ {{dn}}日 + 周{{weekName[d.week[di]]}} + | {{/each}} {{/each}}
+ |
+ {{each charBirth[`${d.month}-${dn}`] char}}
+
+
+ {{char.name}}
+ {{/each}}
+
+ |
{{/each}} {{/each}}