mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
fix: #星铁日历
This commit is contained in:
parent
1cfbadb304
commit
003b866b30
@ -3,7 +3,6 @@ import fetch from 'node-fetch'
|
||||
import moment from 'moment'
|
||||
import Calendar from './Calendar.js'
|
||||
import { Common, Data } from '#miao'
|
||||
import { Character } from '#miao.models'
|
||||
|
||||
const ignoreIds = [
|
||||
257, // 保密测试参与意愿调研
|
||||
@ -26,8 +25,11 @@ let CalSr = {
|
||||
|
||||
let timeMap
|
||||
let timeMapCache = await redis.get('miao:calendarSr:detail')
|
||||
if (timeMapCache) {
|
||||
let gachaImgs
|
||||
let gachaImgsCache = await redis.get('miao:calendarSr:gachaImgs')
|
||||
if (timeMapCache && gachaImgsCache) {
|
||||
timeMap = JSON.parse(timeMapCache) || {}
|
||||
gachaImgs = JSON.parse(gachaImgsCache) || {}
|
||||
} else {
|
||||
let detailApi = 'https://hkrpg-api-static.mihoyo.com/common/hkrpg_cn/announcement/api/getAnnContent?game=hkrpg&game_biz=hkrpg_cn&lang=zh-cn&bundle_id=hkrpg_cn&platform=pc®ion=prod_gf_cn&level=65&channel_id=1'
|
||||
let request2 = await fetch(detailApi)
|
||||
@ -49,6 +51,8 @@ let CalSr = {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
gachaImgs = []
|
||||
let ret = function (ds) {
|
||||
let { ann_id: annId, content, title } = ds
|
||||
if (ignoreReg.test(title)) {
|
||||
@ -61,6 +65,9 @@ let CalSr = {
|
||||
if (!content || !content[1]) {
|
||||
return true
|
||||
}
|
||||
if (/活动跃迁/.test(content)) {
|
||||
gachaImgs.push(ds.img)
|
||||
}
|
||||
content = content[1]
|
||||
let annTime = []
|
||||
|
||||
@ -99,7 +106,7 @@ let CalSr = {
|
||||
}
|
||||
await Data.setCacheJSON('miao:calendarSr:detail', timeMap, 60 * 10)
|
||||
}
|
||||
return { listData, timeMap }
|
||||
return { listData, timeMap, gachaImgs }
|
||||
},
|
||||
|
||||
// 深渊日历信息
|
||||
@ -107,7 +114,7 @@ let CalSr = {
|
||||
let check = []
|
||||
let f = 'YYYY-MM-DD HH:mm:ss'
|
||||
|
||||
let abyss1Start = moment(versionStartTime, 'YYYY-MM-DD HH:mm:ss').add(5, 'days').subtract(3, 'hours').format(f)
|
||||
let abyss1Start = moment(versionStartTime, 'YYYY-MM-DD HH:mm:ss').subtract(2, 'days').add(4, 'hours').format(f)
|
||||
let abyss1End = moment(abyss1Start).add(14, 'days').format(f)
|
||||
let abyss2Start = abyss1End
|
||||
let abyss2End = moment(abyss2Start).add(14, 'days').format(f)
|
||||
@ -134,11 +141,10 @@ let CalSr = {
|
||||
return ret
|
||||
},
|
||||
|
||||
getList (ds, target, { startTime, endTime, totalRange, now, timeMap = {} }) {
|
||||
getList (ds, target, { startTime, endTime, totalRange, now, timeMap = {}, gachaImgs = [] }) {
|
||||
let type = 'activity'
|
||||
let id = ds.ann_id
|
||||
let title = ds.title
|
||||
let subTitle = ds.subtitle
|
||||
let banner = ds.banner
|
||||
let extra = { sort: 5 }
|
||||
let detail = timeMap[id] || {}
|
||||
@ -146,22 +152,14 @@ let CalSr = {
|
||||
if (ignoreIds.includes(id) || ignoreReg.test(title)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (/流光定影/.test(title)) {
|
||||
type = 'weapon'
|
||||
title = title.replace(/(限定5星光锥)/g, '')
|
||||
extra.sort = 2
|
||||
} else if (/跃迁/.test(subTitle)) {
|
||||
banner = gachaImgs.shift()
|
||||
} else if (/角色活动跃迁/.test(title)) {
|
||||
type = 'character'
|
||||
let regRet = /角色「(.*)((|\()/.exec(title)
|
||||
if (regRet[1]) {
|
||||
let char = Character.get(regRet[1])
|
||||
extra.banner2 = char.getImgs()?.card
|
||||
extra.face = char.face
|
||||
extra.character = regRet[1]
|
||||
extra.elem = char.elem
|
||||
extra.sort = 1
|
||||
}
|
||||
extra.sort = 1
|
||||
banner = gachaImgs.shift()
|
||||
} else if (/无名勋礼/.test(title)) {
|
||||
type = 'pass'
|
||||
}
|
||||
@ -218,14 +216,14 @@ let CalSr = {
|
||||
moment.locale('zh-cn')
|
||||
let now = moment()
|
||||
|
||||
let { listData, timeMap } = await CalSr.reqCalData()
|
||||
let { listData, timeMap, gachaImgs } = await CalSr.reqCalData()
|
||||
let dateList = Calendar.getDateList()
|
||||
|
||||
let resultList = []
|
||||
let abyss = []
|
||||
|
||||
lodash.forEach(listData.data.list[0].list, (ds) => CalSr.getList(ds, resultList, { ...dateList, now, timeMap }))
|
||||
lodash.forEach(listData.data.pic_list[0].type_list[0].list, (ds) => CalSr.getList(ds, resultList, { ...dateList, now, timeMap }))
|
||||
lodash.forEach(listData.data.list[0].list, (ds) => CalSr.getList(ds, resultList, { ...dateList, now, timeMap, gachaImgs }))
|
||||
lodash.forEach(listData.data.pic_list[0].type_list[0].list, (ds) => CalSr.getList(ds, resultList, { ...dateList, now, timeMap, gachaImgs }))
|
||||
|
||||
let versionStartTime
|
||||
lodash.forEach(listData.data.list[0].list, (ds) => {
|
||||
|
@ -151,7 +151,7 @@ body {
|
||||
max-width: 500px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
right: -10px;
|
||||
background-size: 100% auto;
|
||||
background-position: left 40%;
|
||||
}
|
||||
@ -292,7 +292,7 @@ body {
|
||||
}
|
||||
.cal-abyss-cont .cal-item {
|
||||
border-radius: 0;
|
||||
background: url("./imgs/abyss.jpg") #333465 top right no-repeat;
|
||||
background: url("imgs/abyss.jpg") #333465 top right no-repeat;
|
||||
position: absolute;
|
||||
}
|
||||
.cal-abyss-cont .cal-item .info {
|
||||
@ -450,4 +450,3 @@ body {
|
||||
.daily-talent .card .banner.city-5 .line {
|
||||
background: #557dd6;
|
||||
}
|
||||
/*# sourceMappingURL=calendar.css.map */
|
@ -75,7 +75,7 @@
|
||||
<div class="banner" style="background-image:url('{{li.banner}}')"></div>
|
||||
{{/if}}
|
||||
<div class="info">
|
||||
{{if li.type === "character"}}
|
||||
{{if li.type === "character" && game === 'gs'}}
|
||||
<img src="{{_res_path}}{{li.face}}" class="character-img"/>
|
||||
{{else if li.icon}}
|
||||
<img src="{{li.icon}}" class="cal-icon"/>
|
||||
|
@ -192,7 +192,7 @@ body {
|
||||
max-width: 500px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
right: -10px;
|
||||
background-size: 100% auto;
|
||||
background-position: left 40%;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user