mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
* 增加#喵喵日历
功能
* 功能尚未完全完成,深渊信息及部分样式仍然在调整中
This commit is contained in:
parent
f8a333eea8
commit
1cb2032903
@ -1,5 +1,7 @@
|
||||
# 1.4.1
|
||||
# 1.4.2
|
||||
|
||||
* 增加`#喵喵日历` 功能
|
||||
* 功能尚未完全完成,深渊信息及部分样式仍然在调整中
|
||||
* `#角色面板` 伤害计算新增部分角色
|
||||
* 目前支持:雷神、胡桃、魈、神子、甘雨、宵宫、公子、绫人、绫华、心海、钟离、刻晴、阿贝多、香菱
|
||||
|
||||
|
143
apps/wiki.js
143
apps/wiki.js
@ -3,6 +3,8 @@ import fs from "fs";
|
||||
import { Character } from "../components/models.js";
|
||||
import lodash from "lodash";
|
||||
import { Cfg } from "../components/index.js";
|
||||
import fetch from "node-fetch";
|
||||
import moment from "moment";
|
||||
|
||||
//import {wikiCharacter} from "../modules/wiki.js";
|
||||
|
||||
@ -95,3 +97,144 @@ async function wikiCache(e) {
|
||||
}
|
||||
e.reply(`生成Wiki缓存${count}个`)
|
||||
}
|
||||
|
||||
export async function calendar(e, { render }) {
|
||||
let listApi = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnList?game=hk4e&game_biz=hk4e_cn&lang=zh-cn&bundle_id=hk4e_cn&platform=pc®ion=cn_gf01&level=55&uid=100000000";
|
||||
|
||||
let request = await fetch(listApi);
|
||||
let calendarData = await request.json();
|
||||
|
||||
moment.locale("zh-cn");
|
||||
|
||||
let today = moment(), now = moment();
|
||||
let temp = today.add(-7, 'days');
|
||||
let dateList = [], month = 0, date = [];
|
||||
|
||||
let startDate, endDate;
|
||||
|
||||
const ignoreIds = [495,// 有奖问卷调查开启!
|
||||
1263, // 米游社《原神》专属工具一览
|
||||
423, // 《原神》玩家社区一览
|
||||
422, // 《原神》防沉迷系统说明
|
||||
762, // 《原神》公平运营声明
|
||||
762, // 《原神》公平运营声明
|
||||
]
|
||||
const ignoreReg = /(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化)/;
|
||||
|
||||
|
||||
for (let idx = 0; idx < 13; idx++) {
|
||||
let temp = today.add(1, 'days'),
|
||||
m = temp.month() + 1, d = temp.date();
|
||||
if (month === 0) {
|
||||
startDate = temp.format("YYYY-MM-DD");
|
||||
month = m;
|
||||
}
|
||||
if (month !== m && date.length > 0) {
|
||||
dateList.push({
|
||||
month,
|
||||
date
|
||||
})
|
||||
date = [];
|
||||
month = m;
|
||||
}
|
||||
date.push(d);
|
||||
if (idx === 12) {
|
||||
dateList.push({
|
||||
month,
|
||||
date
|
||||
})
|
||||
|
||||
endDate = temp.format("YYYY-MM-DD");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let startTime = moment(startDate + " 00:00:00"),
|
||||
endTime = moment(endDate + " 23:59:59");
|
||||
|
||||
let totalRange = endTime - startTime;
|
||||
|
||||
let list = [];
|
||||
let getList = (ds, showBanner = false) => {
|
||||
let type = showBanner ? "activity" : "normal",
|
||||
id = ds.ann_id,
|
||||
title = ds.title,
|
||||
banner = showBanner ? ds.banner : '',
|
||||
extra = { sort: showBanner ? 5 : 10 };
|
||||
|
||||
if (ignoreIds.includes(id) || ignoreReg.test(title)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (/神铸赋形/.test(title)) {
|
||||
type = "weapon";
|
||||
title = title.replace(/(单手剑|双手剑|长柄武器|弓|法器|·)/g, "");
|
||||
extra.sort = 2;
|
||||
} else if (/祈愿/.test(title)) {
|
||||
type = "character";
|
||||
let regRet = /·(.*)\(/.exec(title);
|
||||
if (regRet[1]) {
|
||||
let char = Character.get(regRet[1]);
|
||||
extra.banner2 = `/meta/character/${regRet[1]}/party.png`;
|
||||
extra.character = regRet[1];
|
||||
extra.elem = char.elem;
|
||||
extra.sort = 1;
|
||||
} else if (/纪行/.test(title)) {
|
||||
type = "pass"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let sDate = moment(ds.start_time),
|
||||
eDate = moment(ds.end_time);
|
||||
let sTime = moment.max(sDate, startTime),
|
||||
eTime = moment.min(eDate, endTime);
|
||||
|
||||
let sRange = sTime - startTime,
|
||||
eRange = eTime - startTime;
|
||||
|
||||
let left = sRange / totalRange * 100,
|
||||
width = eRange / totalRange * 100 - left;
|
||||
|
||||
let label = "";
|
||||
if (now > sDate && eDate > now) {
|
||||
label = eDate.format("MM-DD HH:mm") + " (" + moment.duration(eDate - now).humanize() + ")结束"
|
||||
} else if (sDate > now) {
|
||||
label = sDate.format("MM-DD HH:mm") + " (" + moment.duration(sDate - now).humanize() + ")开始"
|
||||
}
|
||||
|
||||
list.push({
|
||||
...extra,
|
||||
id,
|
||||
title,
|
||||
type,
|
||||
banner,
|
||||
icon: ds.tag_icon,
|
||||
left,
|
||||
width,
|
||||
label,
|
||||
|
||||
duration: eTime - sTime,
|
||||
start: sDate.format("MM-DD HH:mm"),
|
||||
end: eDate.format("MM-DD HH:mm")
|
||||
})
|
||||
};
|
||||
lodash.forEach(calendarData.data.list[1].list, (ds) => getList(ds, true))
|
||||
lodash.forEach(calendarData.data.list[0].list, (ds) => getList(ds, false));
|
||||
|
||||
list = lodash.sortBy(list, ["sort", 'duration', 'start']);
|
||||
|
||||
let base64 = await render("wiki", "calendar", {
|
||||
list,
|
||||
dateList,
|
||||
now: (now - startTime) / totalRange * 100,
|
||||
nowTime: now.format("YYYY-MM-DD HH:mm"),
|
||||
cfgScale: Cfg.scale(1.1)
|
||||
});
|
||||
|
||||
if (base64) {
|
||||
e.reply(segment.image(`base64://${base64}`));
|
||||
}
|
||||
return true; //事件结束不再往下
|
||||
}
|
9
index.js
9
index.js
@ -9,7 +9,7 @@ import {
|
||||
profileHelp
|
||||
} from "./apps/character.js";
|
||||
import { consStat, abyssPct, abyssTeam } from "./apps/stat.js";
|
||||
import { wiki } from "./apps/wiki.js";
|
||||
import { wiki, calendar } from "./apps/wiki.js";
|
||||
import { help, versionInfo } from "./apps/help.js";
|
||||
import lodash from "lodash";
|
||||
import common from "../../lib/common.js";
|
||||
@ -32,7 +32,8 @@ export {
|
||||
enemyLv,
|
||||
getArtis,
|
||||
getProfileAll,
|
||||
profileHelp
|
||||
profileHelp,
|
||||
calendar
|
||||
};
|
||||
|
||||
|
||||
@ -90,6 +91,10 @@ let rule = {
|
||||
reg: "^#喵喵版本$",
|
||||
describe: "【#帮助】 喵喵版本介绍",
|
||||
},
|
||||
calendar: {
|
||||
reg: "^#喵喵日历$",
|
||||
describe: "【#日历】 活动日历",
|
||||
},
|
||||
...adminRule
|
||||
};
|
||||
|
||||
|
@ -282,7 +282,8 @@ ul.cont-msg li strong {
|
||||
background: rgba(50, 50, 50, .4);
|
||||
}
|
||||
|
||||
.cont-table .tr > div {
|
||||
.cont-table .tr > div,
|
||||
.cont-table .tr > td{
|
||||
display: table-cell;
|
||||
box-shadow: 0 0 1px 0 #fff;
|
||||
}
|
||||
@ -300,7 +301,8 @@ ul.cont-msg li strong {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cont-table .thead > div {
|
||||
.cont-table .thead > div,
|
||||
.cont-table .thead > td{
|
||||
font-family: YS;
|
||||
color: #d3bc8e;
|
||||
background: rgba(0, 0, 0, .4);
|
||||
|
250
resources/wiki/calendar.css
Normal file
250
resources/wiki/calendar.css
Normal file
@ -0,0 +1,250 @@
|
||||
@font-face {
|
||||
font-family: "tttgbnumber";
|
||||
src: url("../common/font/tttgbnumber.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 18px;
|
||||
color: #1e1f20;
|
||||
font-family: PingFangSC-Medium, PingFang SC, sans-serif;
|
||||
transform: scale(1);
|
||||
transform-origin: 0 0;
|
||||
width: 996px;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 996px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 24px;
|
||||
font-family: "tttgbnumber";
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
margin: 20px 0 10px 0;
|
||||
}
|
||||
|
||||
.calendar {
|
||||
min-height: 400px;
|
||||
position: relative;
|
||||
padding: 1px 0;
|
||||
width: 956px;
|
||||
margin: 20px;
|
||||
box-shadow: 0 0 0 10px rgba(0, 0, 0, .6);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.cal-bg {
|
||||
position: absolute;
|
||||
width: 956px;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
height: 100%;
|
||||
box-shadow: 0 0 1px 0 #fff inset;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cal-bg table {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
.cal-bg .tr.thead {
|
||||
background: rgba(0, 0, 0, .8);
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.cal-bg td {
|
||||
box-shadow: 0 0 1px 0 #fff;
|
||||
}
|
||||
|
||||
.cal-bg td.date {
|
||||
width: 7.692%
|
||||
}
|
||||
|
||||
.cal-bg td.line {
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.cal-list {
|
||||
position: relative;
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
.cal-list .cal-item {
|
||||
margin-bottom: 15px;
|
||||
border-radius: 5px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: rgba(232, 226, 216, 1);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.cal-list .cal-item:after {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 3px;
|
||||
top: 3px;
|
||||
right: 4px;
|
||||
bottom: 4px;
|
||||
box-shadow: 0 0 1px 0 #000 inset, 0 0 2px 0 #222a3b;
|
||||
}
|
||||
|
||||
.cal-list .cal-item .info {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
padding: 15px 50px 15px 55px;
|
||||
min-width: calc(100% - 480px);
|
||||
border-radius: 5px;
|
||||
background-image: linear-gradient(to right, rgba(232, 226, 216, 1), rgba(232, 226, 216, 1) 80%, rgba(232, 226, 216, 0) 100%);
|
||||
}
|
||||
|
||||
.cal-list .cal-item .banner {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
background-size: 100% auto;
|
||||
background-position: left 40%;
|
||||
|
||||
}
|
||||
|
||||
.cal-list .cal-item strong {
|
||||
display: block;
|
||||
margin-left: -5px;
|
||||
font-family: YS;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.cal-list .cal-item span {
|
||||
display: block;
|
||||
font-family: Number, YS;
|
||||
font-size: 12px;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
.cal-list .cal-item.type-weapon .info,
|
||||
.cal-list .cal-item.type-character .info {
|
||||
background-image: linear-gradient(to right, rgba(227, 164, 111), rgba(227, 164, 111) 80%, rgba(227, 164, 111, 0) 100%);
|
||||
}
|
||||
*/
|
||||
|
||||
.cal-list .cal-item.type-character {
|
||||
overflow: visible;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-character .info {
|
||||
padding-left: 65px;
|
||||
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-character .character-img {
|
||||
width: 65px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 10;
|
||||
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-normal {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-normal:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-normal:after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
.cal-list .cal-item.type-normal:first-of-type {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-normal .info {
|
||||
padding: 8px 20px 8px 15px;
|
||||
line-height: 16px;
|
||||
color: #4b5366;
|
||||
}
|
||||
|
||||
.cal-list .cal-item .cal-icon {
|
||||
position: absolute;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
left: 10px;
|
||||
top: 10px;
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-normal .cal-icon {
|
||||
|
||||
width: 23px;
|
||||
height: 23px;
|
||||
top: 7px;
|
||||
margin-left: -3px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-normal strong {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.cal-list .cal-item.type-normal .info {
|
||||
padding-left: 38px;
|
||||
}
|
||||
|
||||
|
||||
.cal-list .cal-item.type-normal strong,
|
||||
.cal-list .cal-item.type-normal span {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.calendar .now-line {
|
||||
position: absolute;
|
||||
top: 84px;
|
||||
bottom: -18px;
|
||||
width: 1px;
|
||||
background: #fff;
|
||||
opacity: .8;
|
||||
}
|
||||
|
||||
.now-time {
|
||||
text-align: center;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.now-time span {
|
||||
|
||||
color: #fff;
|
||||
font-family: Number;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border-radius: 30px;
|
||||
padding: 10px 15px;
|
||||
border:1px solid #fff;
|
||||
}
|
64
resources/wiki/calendar.html
Normal file
64
resources/wiki/calendar.html
Normal file
@ -0,0 +1,64 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||||
<link rel="shortcut icon" href="#"/>
|
||||
<link rel="stylesheet" type="text/css" href="{{_res_path}}/common/common.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="{{_res_path}}/wiki/calendar.css"/>
|
||||
</head>
|
||||
<body class="elem-hydro">
|
||||
<div class="container elem-bg" id="container">
|
||||
<div class="calendar">
|
||||
<div class="cal-bg">
|
||||
<table class="cont-table" border-collapse="collapse">
|
||||
<tr class="tr thead">
|
||||
{{each dateList d}}
|
||||
<td colspan="{{d.date.length}}" class="td month">{{d.month}}月</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
<tr class="tr thead">
|
||||
{{each dateList d}}{{each d.date dn}}
|
||||
<td class="td date">{{dn}}日</td>
|
||||
{{/each}} {{/each}}
|
||||
</tr>
|
||||
<tr class="tr">
|
||||
{{each dateList d}}{{each d.date dn}}
|
||||
<td class="line"></td>
|
||||
{{/each}} {{/each}}
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="cal-list">
|
||||
{{each list li}}
|
||||
<div class="cal-item type-{{li.type}} {{li.elem?'elem-'+li.elem:''}}"
|
||||
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}}
|
||||
<div class="banner" style="background-image:url('{{li.banner}}')"></div>
|
||||
{{/if}}
|
||||
<div class="info">
|
||||
{{if li.type === "character"}}
|
||||
<img src="{{_res_path}}meta/character/{{li.character}}/face.png" class="character-img"/>
|
||||
{{else}}
|
||||
<img src="{{li.icon}}" class="cal-icon"/>
|
||||
{{/if}}
|
||||
<strong>{{li.title}}</strong>
|
||||
<span>{{li.label}}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
<div class="now-line" style="left:{{now}}%"></div>
|
||||
</div>
|
||||
<div class="now-time">
|
||||
<span>当前时间:{{nowTime}}</span>
|
||||
</div>
|
||||
<div class="logo">Created By Yunzai-Bot & Miao-Plugin</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user