From be3072859d194b209f9d85d824e94575a0d51fc9 Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Fri, 7 Oct 2022 21:13:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=8E=86=E4=BC=9A=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E6=9C=AC=E6=97=A5=E5=8F=AF=E5=88=B7=E5=A4=A9=E8=B5=8B=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- apps/wiki/Calendar.js | 35 +++++++-- models/Avatar.js | 4 +- models/Character.js | 6 +- models/Material.js | 29 +++++-- models/character-lib/CharMeta.js | 11 ++- models/character-lib/CharTalent.js | 5 +- models/material-lib/MaterialMeta.js | 24 +++--- resources/wiki/calendar.css | 102 ++++++++++++++++++++++++ resources/wiki/calendar.html | 26 ++++++- resources/wiki/calendar.less | 117 ++++++++++++++++++++++++++++ 11 files changed, 328 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eeb76d5..ffa07c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ * `#日历` 页面样式微调,功能升级 * 日历中会展示角色生日 - * 日历会展示本日可刷天赋角色列表(暂未完成) + * 日历会展示本日可刷天赋角色列表 * 一些已知问题修复 # 2.0.1~2.0.2 diff --git a/apps/wiki/Calendar.js b/apps/wiki/Calendar.js index ce95645b..964688ac 100644 --- a/apps/wiki/Calendar.js +++ b/apps/wiki/Calendar.js @@ -1,6 +1,6 @@ import fetch from 'node-fetch' import moment from 'moment' -import { Character } from '../../models/index.js' +import { Character, Material } from '../../models/index.js' import { Data } from '../../components/index.js' import lodash from 'lodash' @@ -193,21 +193,46 @@ let Cal = { getCharData (dateList) { let charBirth = {} + let charTalent = {} + // 初始化生日数据 lodash.forEach(dateList, (m) => { lodash.forEach(m.date, (d) => { charBirth[`${m.month}-${d}`] = [] }) }) + // 初始化天赋数据 + let now = moment(new Date()) + if (now.hour() < 4) { + now = now.add(-1, 'days') + } + let week = now.weekday() + Material.forEach('talent', (material) => { + let data = material.getData('name,abbr,city,icon,week,cid') + data.chars = [] + charTalent[material.name] = data + }, (ds) => ds.star === 4 && (week === 6 || ds.week === week % 3 + 1)) + // 遍历角色数据 Character.forEach((char) => { - if (charBirth[char.birth]) { - charBirth[char.birth].push(char.getData('id,sName,star,face')) + if (charBirth[char.birth] && (char.isRelease || char.birth !== '1-1')) { + charBirth[char.birth].push(char.getData('id,name:sName,star,face')) } - }, 'release') + let t = char.materials?.talent + if (t && charTalent[t] && !char.isTraveler) { + let data = char.getData('id,name:sName,star,face') + data.weekly = char.getMaterials('weekly')?.icon + charTalent[t].chars.push(data) + } + }, 'official') let charNum = 0 lodash.forEach(charBirth, (charList) => { charNum = Math.max(charNum, charList.length) }) - return { charBirth, charNum } + charTalent = lodash.values(charTalent) + charTalent = lodash.sortBy(charTalent, 'cid') + lodash.forEach(charTalent, (ds) => { + ds.chars = lodash.sortBy(ds.chars, ['star', 'id']).reverse() + }) + return { charBirth, charNum, charTalent } }, getList (ds, target, { startTime, endTime, totalRange, now, timeMap = {} }, isAct = false) { diff --git a/models/Avatar.js b/models/Avatar.js index 6e26a5d5..c418baae 100644 --- a/models/Avatar.js +++ b/models/Avatar.js @@ -148,7 +148,9 @@ export default class Avatar extends Base { } } let ret = char.getAvatarTalent(talent, this.cons, 'original') - ret.id = id + if (ret) { + ret.id = id + } return ret } if (this.profile) { diff --git a/models/Character.js b/models/Character.js index 3a96279f..deefc8d7 100644 --- a/models/Character.js +++ b/models/Character.js @@ -130,8 +130,8 @@ class Character extends Base { return CharMeta.getAttrList(meta.baseAttr, meta.growAttr, this.elemName) } - getMaterials () { - return CharMeta.getMaterials(this) + getMaterials (type = 'all') { + return CharMeta.getMaterials(this, type) } getLvStat () { @@ -266,7 +266,7 @@ class Character extends Base { if (type === 'release' && !char.isRelease) { return true } - if (type === 'official' && !char.isCustom) { + if (type === 'official' && !char.isOfficial) { return true } return fn(char) !== false diff --git a/models/Material.js b/models/Material.js index f505f506..eaad418e 100644 --- a/models/Material.js +++ b/models/Material.js @@ -44,6 +44,10 @@ class Material extends Base { this.meta = meta this.type = meta.type this.star = meta.star + if (this.type === 'talent') { + let talentData = MaterialMeta.getTalentData(this.name) + lodash.extend(this, talentData) + } return this._cache() } @@ -81,13 +85,28 @@ class Material extends Base { } return '' } -} -Material.get = function (name) { - if (mMap[name]) { - return new Material(name) + static get (name) { + if (mMap[name]) { + return new Material(name) + } + return false + } + + static forEach (type = 'all', fn, filter = false) { + if (!lodash.isFunction(filter)) { + filter = () => true + } + lodash.forEach(mMap, (ds, name) => { + if (type !== 'all' && type !== ds.type) { + return true + } + let obj = new Material(name) + if (filter(obj)) { + return fn(obj) !== false + } + }) } - return false } export default Material diff --git a/models/character-lib/CharMeta.js b/models/character-lib/CharMeta.js index 7f29430e..48b4e0f8 100644 --- a/models/character-lib/CharMeta.js +++ b/models/character-lib/CharMeta.js @@ -126,24 +126,27 @@ const CharMeta = { }) return ret }, - getMaterials (char) { + getMaterials (char, type = 'all') { let ds = char.meta.materials let ret = [] lodash.forEach(mKeys, (cfg) => { let title = ds[cfg.key] let mat = Material.get(title) if (!mat) { - return + return true } if (cfg.check && !cfg.check(char)) { - return + return true + } + if (type !== 'all' && mat.type !== type) { + return true } ret.push({ ...mat.getData('label,star,icon,type'), num: cfg.num || mat.getSource() || '' }) }) - return ret + return type === 'all' ? ret : ret[0] }, getLvStat (char) { diff --git a/models/character-lib/CharTalent.js b/models/character-lib/CharTalent.js index c28a5ea4..dec54efc 100644 --- a/models/character-lib/CharTalent.js +++ b/models/character-lib/CharTalent.js @@ -40,7 +40,10 @@ const CharTalent = { } ret[key] = { level, original } }) - return lodash.isEmpty(ret) ? false : ret + if (lodash.isEmpty(ret)) { + return false + } + return ret } } export default CharTalent diff --git a/models/material-lib/MaterialMeta.js b/models/material-lib/MaterialMeta.js index fc5fc777..42af1fe5 100644 --- a/models/material-lib/MaterialMeta.js +++ b/models/material-lib/MaterialMeta.js @@ -2,20 +2,20 @@ import lodash from 'lodash' import { Data } from '../../components/index.js' const talentMeta = { - 自由: { week: 1, city: '蒙德' }, - 繁荣: { week: 1, city: '璃月' }, - 浮世: { week: 1, city: '稻妻' }, - 诤言: { week: 1, city: '须弥' }, + 自由: { week: 1, city: '蒙德', cid: 1 }, + 繁荣: { week: 1, city: '璃月', cid: 2 }, + 浮世: { week: 1, city: '稻妻', cid: 3 }, + 诤言: { week: 1, city: '须弥', cid: 4 }, - 抗争: { week: 2, city: '蒙德' }, - 勤劳: { week: 2, city: '璃月' }, - 风雅: { week: 2, city: '稻妻' }, - 巧思: { week: 2, city: '须弥' }, + 抗争: { week: 2, city: '蒙德', cid: 1 }, + 勤劳: { week: 2, city: '璃月', cid: 2 }, + 风雅: { week: 2, city: '稻妻', cid: 3 }, + 巧思: { week: 2, city: '须弥', cid: 4 }, - 诗文: { week: 3, city: '蒙德' }, - 黄金: { week: 3, city: '璃月' }, - 天光: { week: 3, city: '稻妻' }, - 笃行: { week: 3, city: '须弥' }, + 诗文: { week: 3, city: '蒙德', cid: 1 }, + 黄金: { week: 3, city: '璃月', cid: 2 }, + 天光: { week: 3, city: '稻妻', cid: 3 }, + 笃行: { week: 3, city: '须弥', cid: 4 } } const talentReg = new RegExp(`(${lodash.keys(talentMeta).join('|')})`) diff --git a/resources/wiki/calendar.css b/resources/wiki/calendar.css index b829c3bb..05cc2cb8 100644 --- a/resources/wiki/calendar.css +++ b/resources/wiki/calendar.css @@ -345,4 +345,106 @@ body { .list-mode .now-line { display: none; } +.daily-talent { + display: flex; + flex-wrap: wrap; + margin: 5px 10px 0; + background: rgba(0, 0, 0, 0.5); + padding: 10px 9px 10px; + border-radius: 10px; +} +.daily-talent .item-icon { + overflow: visible; +} +.daily-talent .card { + width: 87px; + height: 105px; + margin: 10px 0 15px; +} +.daily-talent .card .item-icon { + width: 77px; + margin: 0 6px; + height: 82px; + padding-top: 5px; +} +.daily-talent .card .img { + width: 77px; + height: 77px; +} +.daily-talent .card .weekly { + position: absolute; + width: 24px; + height: 24px; + border-radius: 50%; + bottom: -10px; + right: -3px; + background-color: rgba(232, 226, 216, 0.9); + box-shadow: 0 0 2px 0 #000; + overflow: visible; +} +.daily-talent .card .weekly .weekly-icon { + width: 30px; + height: 30px; + margin: -3px; + background-size: contain; + background-position: center; + background-repeat: no-repeat; +} +.daily-talent .card .banner { + height: 20px; + padding-top: 1px; + line-height: 20px; + color: #fff; + position: relative; + margin-bottom: 8px; +} +.daily-talent .card .banner .title { + margin-right: -50px; + width: calc(100% + 50px); + display: flex; + position: absolute; + top: 0; + left: 0; + z-index: 2; + text-shadow: 0 0 1px rgba(0, 0, 0, 0.8), 1px 1px 2px rgba(0, 0, 0, 0.8); + padding-left: 45px; + font-size: 18px; +} +.daily-talent .card .banner .icon { + width: 40px; + height: 40px; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + display: inline-block; + position: absolute; + left: 0; + top: -8px; +} +.daily-talent .card .banner .line { + height: 6px; + width: 100%; + margin-top: 13px; +} +.daily-talent .card .banner .line.first { + margin-left: 35%; + width: 65%; + border-radius: 3px 0 0 3px; +} +.daily-talent .card .banner .line.last { + width: 94%; + border-radius: 0 3px 3px 0; +} +.daily-talent .card .banner.city-1 .line { + background: #37c9b8; +} +.daily-talent .card .banner.city-2 .line { + background: #bca244; +} +.daily-talent .card .banner.city-3 .line { + background: #ac60c9; +} +.daily-talent .card .banner.city-4 .line { + background: #54b640; +} /*# sourceMappingURL=calendar.css.map */ \ No newline at end of file diff --git a/resources/wiki/calendar.html b/resources/wiki/calendar.html index 8df60e15..dc935273 100644 --- a/resources/wiki/calendar.html +++ b/resources/wiki/calendar.html @@ -29,7 +29,7 @@
- {{char.sName.length>=4?char.sName:`${char.sName}生日`}} + {{char.name.length>=4?char.name:`${char.name}生日`}}
{{char.name}} @@ -92,4 +92,28 @@
当前时间:{{nowTime}}
+
+ {{each charTalent talent}} + + {{each talent.chars char idx}} +
+ +
+
+
+
+
+
+
+ {{/each}} + {{/each}} +
{{/block}} \ No newline at end of file diff --git a/resources/wiki/calendar.less b/resources/wiki/calendar.less index 05fbbe21..88175526 100644 --- a/resources/wiki/calendar.less +++ b/resources/wiki/calendar.less @@ -453,4 +453,121 @@ body { .now-line { display: none; } +} + +@width: 77px; + +.daily-talent { + display: flex; + flex-wrap: wrap; + margin: 5px 10px 0; + background: rgba(0, 0, 0, .5); + padding: 10px 9px 10px; + border-radius: 10px; + + + .item-icon { + overflow: visible; + } + + .card { + width: @width + 10px; + height: @width + 28px; + margin: 10px 0 15px; + + + .item-icon { + width: @width; + margin: 0 6px; + height: @width + 5px; + padding-top: 5px; + } + + .img { + width: @width; + height: @width; + } + + .weekly { + position: absolute; + width: 24px; + height: 24px; + border-radius: 50%; + bottom: -10px; + right: -3px; + background-color: rgba(232, 226, 216, 0.9); + box-shadow: 0 0 2px 0 #000; + overflow: visible; + + .weekly-icon { + width: 30px; + height: 30px; + margin: -3px; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + } + } + + .banner { + height: 20px; + padding-top: 1px; + line-height: 20px; + color: #fff; + position: relative; + margin-bottom: 8px; + + .title { + margin-right: -50px; + width: calc(100% + 50px); + display: flex; + position: absolute; + top: 0; + left: 0; + z-index: 2; + text-shadow: 0 0 1px rgba(0, 0, 0, .8), 1px 1px 2px rgba(0, 0, 0, .8); + padding-left: 45px; + font-size: 18px; + } + + .icon { + width: 40px; + height: 40px; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + display: inline-block; + position: absolute; + left: 0; + top: -8px; + } + + .line { + height: 6px; + width: 100%; + margin-top: 13px; + + &.first { + margin-left: 35%; + width: 65%; + border-radius: 3px 0 0 3px; + } + + &.last { + width: 94%; + border-radius: 0 3px 3px 0; + } + } + + .city(@name, @bg) { + &.city-@{name} .line { + background: @bg; + } + } + .city(1, #37c9b8); + .city(2, #bca244); + .city(3, #ac60c9); + .city(4, #54b640); + } + } } \ No newline at end of file