#喵喵日历 适配3.0活动日期

This commit is contained in:
yoimiya-kokomi 2022-08-22 21:38:34 +08:00
parent 18faeae290
commit e59b3ded99
6 changed files with 63 additions and 30 deletions

View File

@ -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'),

View File

@ -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) {

View File

@ -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)
}

View File

@ -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;

View File

@ -47,11 +47,13 @@
</div>
{{/each}}
</div>
{{each list li}}
<div class="cal-item type-{{li.type}} {{li.idx? `li-idx-${li.idx}`:``}} {{li.elem?'elem-'+li.elem:''}} {{li.width<20 ? 'small-mode':''}}"
style="{{`margin-left:${li.left}%;width:${li.width}%`}}"
data-id="{{li.id}}"
data-type="{{li.type}}">
{{each list lis}}
{{each lis li idx}}
<div
class="cal-item type-{{li.type}} {{li.idx? `li-idx-${li.idx}`:``}} {{li.elem?'elem-'+li.elem:''}} {{li.width<20 ? 'small-mode':''}} li-col{{idx}}"
style="{{`margin-left:${li.left}%;width:${li.width}%`}}"
data-id="{{li.id}}"
data-type="{{li.type}}">
{{if li.banner2}}
<div class="banner" style="background-image:url('{{_res_path}}{{li.banner2}}')"></div>
{{else if li.banner}}
@ -66,9 +68,9 @@
<strong>{{li.title}}</strong>
<span>{{li.label}}</span>
</div>
</div>
{{/each}}
{{/each}}
</div>
<div class="now-line" style="left:{{nowLeft}}%"></div>
<div class="now-line line2" style="left:{{nowLeft}}%"></div>

View File

@ -66,7 +66,6 @@ body {
height: 40px;
td {
.font-ys;
}
}
@ -144,7 +143,6 @@ body {
strong {
display: block;
.font-ys;
font-weight: normal;
}
@ -224,6 +222,10 @@ body {
display: block;
margin-left: 0;
}
&.li-col1 {
margin-top: -40px;
}
}
.cal-icon {
@ -234,6 +236,9 @@ body {
top: 10px;
}
&.li-col1 {
margin-top: -82px;
}
}
&.char-2-1,
@ -259,6 +264,8 @@ body {
.type-weapon.li-idx-2 {
margin-top: -82px;
}
}
.calendar .now-line {