From e59b3ded99c301bc57ad995603cf5b41583d84aa Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Mon, 22 Aug 2022 21:38:34 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=96=B5=E5=96=B5=E6=97=A5=E5=8E=86=20?= =?UTF-8?q?=E9=80=82=E9=85=8D3.0=E6=B4=BB=E5=8A=A8=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wiki/calendar.js | 48 ++++++++++++++++++++++++++------- components/profile-data/enka.js | 2 +- components/profile-data/miao.js | 2 +- resources/wiki/calendar.css | 16 +++++------ resources/wiki/calendar.html | 14 +++++----- resources/wiki/calendar.less | 11 ++++++-- 6 files changed, 63 insertions(+), 30 deletions(-) diff --git a/apps/wiki/calendar.js b/apps/wiki/calendar.js index cbd663e4..ac54f0e6 100644 --- a/apps/wiki/calendar.js +++ b/apps/wiki/calendar.js @@ -11,7 +11,7 @@ const ignoreIds = [495, // 有奖问卷调查开启! 762 // 《原神》公平运营声明 ] -const ignoreReg = /(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查|版本更新通知|更新时间说明|预下载功能|周边限时|周边上新)/ +const ignoreReg = /(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查|版本更新通知|更新时间说明|预下载功能|周边限时|周边上新|角色演示)/ const fulltimeReg = /(魔神任务)/ let Cal = { @@ -94,6 +94,17 @@ let Cal = { } }) } + let miaoApi = 'http://miaoapi.cn/api/calendar' + try { + request2 = await fetch(miaoApi) + let data = await request2.json() + if (data && data.status === 0 && data.data) { + lodash.forEach(data.data, (ds, id) => { + timeMap[id] = ds + }) + } + } catch (e) { + } await redis.set('cache:calendar:detail', JSON.stringify(timeMap), { EX: 60 * 10 }) } return { listData, timeMap } @@ -181,7 +192,7 @@ let Cal = { let extra = { sort: isAct ? 5 : 10 } let detail = timeMap[id] || {} - if (ignoreIds.includes(id) || ignoreReg.test(title)) { + if (ignoreIds.includes(id) || ignoreReg.test(title) || detail.display === false) { return } @@ -198,13 +209,14 @@ let Cal = { extra.character = regRet[1] extra.elem = char.elem extra.sort = 1 - } else if (/纪行/.test(title)) { - type = 'pass' - } else if (title === '深渊') { - type = 'abyss' } + } else if (/纪行/.test(title)) { + type = 'pass' + } else if (title === '深渊') { + type = 'abyss' } + let getDate = (d1, d2) => moment(d1 && d1.length > 6 ? d1 : d2) let sDate = getDate(detail.start, ds.start_time) let eDate = getDate(detail.end, ds.end_time) @@ -220,10 +232,10 @@ let Cal = { let label = '' if (fulltimeReg.test(title) || eDate - sDate > 365 * 24 * 3600 * 1000) { if (sDate < now) { - left = 0 - width = 100 + label = sDate.format('MM-DD HH:mm') + ' 后永久有效' + } else { + label = '永久有效' } - label = '永久有效' } else if (now > sDate && eDate > now) { label = eDate.format('MM-DD HH:mm') + ' (' + moment.duration(eDate - now).humanize() + '后结束)' if (width > (isAct ? 38 : 55)) { @@ -240,6 +252,7 @@ let Cal = { id, title, type, + mergeStatus: ['activity', 'normal'].includes(type) ? 1 : 0, banner, icon: ds.tag_icon, left, @@ -279,6 +292,7 @@ let Cal = { let charCount = 0 let charOld = 0 let weaponCount = 0 + let ret = [] lodash.forEach(list, (li) => { if (li.type === 'character') { charCount++ @@ -289,11 +303,25 @@ let Cal = { weaponCount++ li.idx = weaponCount } + if (li.mergeStatus === 1) { + lodash.forEach(list, (li2) => { + if (li2.mergeStatus === 1 && li.left + li.width <= li2.left) { + li.mergeStatus = 2 + li2.mergeStatus = 2 + ret.push([li, li2]) + return false + } + }) + } + if (li.mergeStatus !== 2) { + li.mergeStatus = 2 + ret.push([li]) + } }) return { ...dl, - list, + list: ret, abyss, charMode: `char-${charCount}-${charOld}`, nowTime: now.format('YYYY-MM-DD HH:mm'), diff --git a/components/profile-data/enka.js b/components/profile-data/enka.js index 9f3ee364..64bc4230 100644 --- a/components/profile-data/enka.js +++ b/components/profile-data/enka.js @@ -21,7 +21,7 @@ export default new ProfileServ({ // 处理服务返回 async response (data, req) { if (!data.playerInfo) { - return req.err(`请求失败:${data.msg}` || 'error', 60) + return req.err('error', 60) } let details = data.avatarInfoList if (!details || details.length === 0 || !details[0].propMap) { diff --git a/components/profile-data/miao.js b/components/profile-data/miao.js index 24852320..a866b4c2 100644 --- a/components/profile-data/miao.js +++ b/components/profile-data/miao.js @@ -11,7 +11,7 @@ export default new ProfileServ({ if (data.status !== 0) { return req.err(data.msg || 'error', 60) } - data = data.data + data = data.data || {} if (!data.showAvatarInfoList || data.showAvatarInfoList.length === 0) { return req.err('empty', 5 * 60) } diff --git a/resources/wiki/calendar.css b/resources/wiki/calendar.css index caee1724..52cf2f91 100644 --- a/resources/wiki/calendar.css +++ b/resources/wiki/calendar.css @@ -1,9 +1,3 @@ -.font-ys { - font-family: YS; -} -.font-number { - font-family: Number, YS; -} * { margin: 0; padding: 0; @@ -58,9 +52,6 @@ body { background: rgba(0, 0, 0, 0.8); height: 40px; } -.cal-bg .tr.thead td { - font-family: YS; -} .cal-bg td { box-shadow: 0 0 1px 0 #fff; } @@ -124,7 +115,6 @@ body { } .cal-list .cal-item strong { display: block; - font-family: YS; font-weight: normal; } .cal-list .cal-item span { @@ -184,6 +174,9 @@ body { display: block; margin-left: 0; } +.cal-list .cal-item.type-normal.li-col1 { + margin-top: -40px; +} .cal-list .cal-item .cal-icon { position: absolute; width: 40px; @@ -191,6 +184,9 @@ body { left: 10px; top: 10px; } +.cal-list .cal-item.li-col1 { + margin-top: -82px; +} .cal-list.char-2-1 .type-character.li-idx-2, .cal-list.char-3-1 .type-character.li-idx-2 { margin-top: -82px; diff --git a/resources/wiki/calendar.html b/resources/wiki/calendar.html index 2a4a1d6d..ccbf97c8 100644 --- a/resources/wiki/calendar.html +++ b/resources/wiki/calendar.html @@ -47,11 +47,13 @@ {{/each}} - {{each list li}} -