2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00

优化部分功能

This commit is contained in:
leiyilu 2022-06-24 22:01:48 +08:00
parent 1ea0910b59
commit 35244746be
6 changed files with 123 additions and 119 deletions

View File

@ -24,7 +24,7 @@ const _path = process.cwd();
export async function Note(e, { export async function Note(e, {
render render
}) { }) {
if(!Cfg.get("sys.Note")){ if (!Cfg.get("sys.Note")) {
return false; return false;
} }
let cookie, uid; let cookie, uid;
@ -110,26 +110,24 @@ export async function Note(e, {
resinMaxTime = ` ${resinMaxTime}`; resinMaxTime = ` ${resinMaxTime}`;
} }
} }
for (let val of data.expeditions) {
val.remained_time = new Date().getTime() + val.remained_time * 1000;
let remainedDate = new Date(val.remained_time);
val.remained_time = format("hh:mm", remainedDate);
if (format("dd", remainedDate) != nowDay) {
val.remained_time = `明天 ${val.remained_time}`;
} else {
val.remained_time = ` ${val.remained_time}`;
}
}
let remained_time = ""; let remained_time = "";
if (data.expeditions && data.expeditions.length >= 1) { if (data.expeditions && data.expeditions.length >= 1) {
remained_time = lodash.map(data.expeditions, "remained_time"); remained_time = lodash.map(data.expeditions, "remained_time");
remained_time = lodash.min(remained_time); remained_time = lodash.min(remained_time);
if (remained_time > 0) { if (remained_time > 0) {
for (let val of data.expeditions) {
val.remained_time = new Date().getTime() + val.remained_time * 1000;
let remainedDate = new Date(val.remained_time);
val.remained_time = format("hh:mm", remainedDate);
if (format("dd", remainedDate) != nowDay) {
val.remained_time = `明天 ${val.remained_time}`;
} else {
val.remained_time = ` ${val.remained_time}`;
}
}
remained_time = new Date().getTime() + remained_time * 1000; remained_time = new Date().getTime() + remained_time * 1000;
let remainedDate = new Date(remained_time); let remainedDate = new Date(remained_time);
remained_time = format("hh:mm", remainedDate); remained_time = format("hh:mm", remainedDate);
if (format("dd", remainedDate) != nowDay) { if (format("dd", remainedDate) != nowDay) {
remained_time = `明天 ${remained_time}`; remained_time = `明天 ${remained_time}`;
} else { } else {
@ -158,7 +156,7 @@ export async function Note(e, {
let day = format("MM-dd hh:mm", new Date()); let day = format("MM-dd hh:mm", new Date());
let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
day += " " + week[new Date().getDay()]; day += " " + week[new Date().getDay()];
//参量质变仪 //参量质变仪
if (data?.transformer?.obtained) { if (data?.transformer?.obtained) {
data.transformer.reached = data.transformer.recovery_time.reached; data.transformer.reached = data.transformer.recovery_time.reached;
@ -175,12 +173,12 @@ export async function Note(e, {
} }
data.transformer.recovery_time = recovery_time; data.transformer.recovery_time = recovery_time;
} }
var image= fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/background_image`); var image = fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/background_image`);
var list_img=[]; var list_img = [];
for (let val of image) { for (let val of image) {
list_img.push(val) list_img.push(val)
} }
var imgs=list_img[lodash.random(0, list_img.length-1)]; var imgs =list_img.length==1?list_img.length[0]:list_img[lodash.random(0, list_img.length - 1)];
return await Common.render("dailyNote/dailyNote", { return await Common.render("dailyNote/dailyNote", {
save_id: uid, save_id: uid,
uid: uid, uid: uid,

View File

@ -15,7 +15,7 @@ export async function AtlasAlias(e) {
// if (await foodInfo(e)) return true; // if (await foodInfo(e)) return true;
if (await RelicsInfo(e)) return true; if (await RelicsInfo(e)) return true;
// if (await monsterInfo(e)) return true; // if (await monsterInfo(e)) return true;
var name = e.msg.replace(/#||信息|图鉴|命座|天赋|突破|圣遗物|原魔|食物|食材|的|特殊|材|料|特色|料理|理|色/g, ""); var name = e.msg.replace(/#||信息|图鉴|命座|天赋|突破|圣遗物|食物|食材|的|特殊|材|料|特色|料理|理|色/g, "");
send_Msg(e, "all", name) send_Msg(e, "all", name)
return true; return true;
} }
@ -41,6 +41,11 @@ export async function roleInfo(e) {
} }
const send_Msg = function(e, type, name) { const send_Msg = function(e, type, name) {
let path = `${_path}/plugins/xiaoyao-cvs-plugin/resources/xiaoyao-plus/${type}/${name}.png`
if (fs.existsSync(path)) {
e.reply(segment.image(`file:///${path}`));
return true;
}
if (type == "all") { if (type == "all") {
for (let val of list) { for (let val of list) {
let new_name = info_img(e, Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`, let new_name = info_img(e, Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`,
@ -52,7 +57,7 @@ const send_Msg = function(e, type, name) {
} }
} }
} }
let path = `${_path}/plugins/xiaoyao-cvs-plugin/resources/xiaoyao-plus/${type}/${name}.png` path = `${_path}/plugins/xiaoyao-cvs-plugin/resources/xiaoyao-plus/${type}/${name}.png`
if (!fs.existsSync(path)) { if (!fs.existsSync(path)) {
return true; return true;
} }

View File

@ -15,7 +15,7 @@ export const render = async function (path, params, cfg) {
scale: Cfg.scale(cfg.scale || 1), scale: Cfg.scale(cfg.scale || 1),
copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>` copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>`
} }
}); },"png");
if (base64) { if (base64) {
e.reply(segment.image(`base64://${base64}`)); e.reply(segment.image(`base64://${base64}`));

View File

@ -13,14 +13,18 @@ import {
} from "./apps/Note.js" } from "./apps/Note.js"
import { import {
rule as adminRule, rule as adminRule,
updateRes,sysCfg, updateRes,
sysCfg,
updateMiaoPlugin updateMiaoPlugin
} from "./apps/admin.js"; } from "./apps/admin.js";
import { currentVersion } from "./components/Changelog.js"; import {
currentVersion
} from "./components/Changelog.js";
export { export {
updateRes, updateRes,
updateMiaoPlugin, updateMiaoPlugin,
versionInfo,sysCfg, versionInfo,
sysCfg,
help, help,
AtlasAlias, AtlasAlias,
Note Note
@ -29,15 +33,15 @@ export {
let rule = { let rule = {
versionInfo: { versionInfo: {
reg: "^#图鉴版本$", reg: "^#图鉴版本$",
describe: "【#帮助】 喵喵版本介绍", describe: "【#帮助】 图鉴版本介绍",
}, },
help: { help: {
reg: "^#图鉴(列表|帮助|help)$", reg: "^#?(图鉴)?(命令|帮助|菜单|help|说明|功能|指令|使用说明)$",
describe: "查看插件的功能", describe: "查看插件的功能",
}, },
AtlasAlias: { AtlasAlias: {
reg: "#*(.*)(信息|图鉴|命座|天赋|突破|材料|特色料理|特殊料理)$", reg: "#*(.*)(信息|图鉴|命座|天赋|突破|材料|特色料理|特殊料理)$",
describe: "【刻晴信息、刻晴图鉴、刻晴突破、刻晴命座】角色信息图鉴", describe: "角色、食物、怪物、武器信息图鉴",
}, },
Note: { Note: {
reg: "^#*(体力|树脂|查询体力|便笺|便签)$", reg: "^#*(体力|树脂|查询体力|便笺|便签)$",
@ -57,13 +61,13 @@ export {
}; };
console.log(`图鉴插件${currentVersion}初始化~`); console.log(`图鉴插件${currentVersion}初始化~`);
setTimeout(async function () { setTimeout(async function() {
let msgStr = await redis.get("xiaoyao:restart-msg"); let msgStr = await redis.get("xiaoyao:restart-msg");
if (msgStr) { if (msgStr) {
let msg = JSON.parse(msgStr); let msg = JSON.parse(msgStr);
await common.relpyPrivate(msg.qq, msg.msg); await common.relpyPrivate(msg.qq, msg.msg);
await redis.del("xiaoyao:restart-msg"); await redis.del("xiaoyao:restart-msg");
let msgs = [`当前版本: ${currentVersion}`, `您可使用 #图鉴版本 命令查看更新信息`]; let msgs = [`当前版本: ${currentVersion}`, `您可使用 #图鉴版本 命令查看更新信息`];
await common.relpyPrivate(msg.qq, msgs.join("\n")); await common.relpyPrivate(msg.qq, msgs.join("\n"));
} }
}, 1000); }, 1000);

View File

@ -8,84 +8,87 @@ html {
height: 100%; height: 100%;
font-family: HYWenHei-55W, monospace; font-family: HYWenHei-55W, monospace;
} }
#container { #container {
min-height: 900px; min-height: 900px;
height: auto; height: auto;
width: 100%; width: 100%;
} /* background-color: rgba(0,0,0,0.5); */
}
.title { .title {
position: absolute; position: absolute;
top: 64px; top: 75px;
left: 225px; left: 225px;
font-weight: bold; font-weight: bold;
font-size: 22px; font-size: 22px;
text-align: left; text-align: left;
} }
.item { .item {
width: 228px; width: 228px;
left: 200px; left: 200px;
top: 350px; top: 350px;
color: #7b8386; color: #7b8386;
font-weight: bold; font-weight: bold;
font-size: 22px; font-size: 22px;
margin-left: 205px; margin-left: 205px;
margin-bottom: 25px; margin-bottom: 25px;
} }
.paiqian { .paiqian {
position: absolute; position: absolute;
width: 400px; width: 400px;
height: 26px; height: 26px;
left: 520px; left: 520px;
top: 80px; top: 80px;
text-align: center; text-align: center;
color: #7b8386; color: #7b8386;
font-weight: bold; font-weight: bold;
font-size: 20px; font-size: 20px;
} }
.icon { .icon {
width: 65px; width: 65px;
margin: 5px 0 4px 13px; margin: 3px 0 4px 13px;
display: inline-block; display: inline-block;
vertical-align: bottom; vertical-align: bottom;
} }
.icon_div { .icon_div {
display: inline-block; display: inline-block;
vertical-align: super; vertical-align: super;
margin-top: -10px; margin-top: -10px;
margin-left: 15px; margin-left: 15px;
} }
.all_icon { .all_icon {
text-align: left; text-align: left;
position: relative; position: relative;
top: -25px; top: -25px;
} }
.time { .time {
position: relative; position: relative;
top: -20px; top: -20px;
} }
.item .main .time { .item .main .time {
font-size: 12px; font-size: 12px;
display: block; display: block;
position: initial; position: initial;
} }
.item .main { .item .main {
display: block; display: block;
} }
.item .top { .item .top {
font-weight: bold; font-weight: bold;
font-size: 30px; font-size: 30px;
display: block; display: block;
} }
.item:nth-last-child(2){
margin-top: 35px; .item:nth-last-child(2) {
} /* margin-top: 35px; */
}

View File

@ -5,6 +5,7 @@
<link rel="shortcut icon" href="#" /> <link rel="shortcut icon" href="#" />
<link rel="stylesheet" type="text/css" href="{{_res_path}}dailyNote/dailyNote.css?v=1.0" /> <link rel="stylesheet" type="text/css" href="{{_res_path}}dailyNote/dailyNote.css?v=1.0" />
<link rel="preload" href="{{_res_path}}font/tttgbnumber.ttf" as="font"> <link rel="preload" href="{{_res_path}}font/tttgbnumber.ttf" as="font">
</head> </head>
<body> <body>
<div class="container" id="container" <div class="container" id="container"
@ -17,14 +18,14 @@
<span>{{day}}</span> <span>{{day}}</span>
</div> </div>
</div> </div>
<div class="item" style="padding-top: 185px;"> <div class="item" style="padding-top: 175px;">
<div class="top"> <div class="top">
<span>{{current_resin}}/{{max_resin}}</span> <span>{{current_resin}}/{{max_resin}}</span>
</div> </div>
<div class="main"> <div class="main">
<div class="time"> <div class="time">
{{if resinMaxTime}} {{if resinMaxTime}}
将于{{resinMaxTime}} 全部恢复 将于<span class="span">{{resinMaxTime}}</span>全部恢复
{{else}}树脂已完全恢复{{/if}} {{else}}树脂已完全恢复{{/if}}
</div> </div>
</div> </div>
@ -41,7 +42,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="item"> <div class="item">
<div class="main"> <div class="main">
<div class="top"> <div class="top">
@ -68,7 +68,7 @@
<div class="time"> <div class="time">
{{if transformer.obtained }} {{if transformer.obtained }}
{{if transformer.reached}}已准备完成 {{if transformer.reached}}已准备完成
{{else}}{{transformer.recovery_time}}后可使用{{/if}} {{else}}<span class="span">{{transformer.recovery_time}}</span>后可使用{{/if}}
{{else}}尚未获得{{/if}} {{else}}尚未获得{{/if}}
</div> </div>
</div> </div>
@ -84,7 +84,7 @@
<div class="info"> <div class="info">
<div class="time"> <div class="time">
{{if coinTime}} {{if coinTime}}
预计{{coinTime}}后达到上限 预计<span class="span">{{coinTime}}</span>后达到上限
{{else}}存储已满{{/if}} {{else}}存储已满{{/if}}
</div> </div>
</div> </div>
@ -99,7 +99,8 @@
<div class="info"> <div class="info">
<div class="time"> <div class="time">
{{if !expeditions || expeditions.length<=0}}尚未进行派遣 {{if !expeditions || expeditions.length<=0}}尚未进行派遣
{{else if remained_time && remained_time!=0}}最快将于{{remained_time}} 完成 {{else if remained_time && remained_time!=0}}最快将于<span class="span">{{remained_time}}</span>
完成
{{else}}派遣已完成{{/if}} {{else}}派遣已完成{{/if}}
</div> </div>
</div> </div>
@ -118,12 +119,5 @@
</div> </div>
</body> </body>
<script type="text/javascript">
var count = 35;
var item = document.getElementsByClassName("item");
for (var i = 0; i < item.length; i++) {
item[i].style.top = (count) + "%"
count += 16;
}
</script>
</html> </html>