From 5b695dd6a6a19ec881541ef9d7f98f6009684a95 Mon Sep 17 00:00:00 2001 From: yeyang <746659424@qq.com> Date: Mon, 24 Jun 2024 17:10:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=B8=90=E5=8F=98=E5=8F=AA=E8=83=BD=E6=B8=90=E5=8F=98?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/update.js | 19 ++++++++++++- apps/version.js | 56 ++++++++----------------------------- resources/state/js/style.js | 20 +++++++------ 3 files changed, 41 insertions(+), 54 deletions(-) diff --git a/apps/update.js b/apps/update.js index 4d657ac..b2e61e8 100644 --- a/apps/update.js +++ b/apps/update.js @@ -1,11 +1,12 @@ /* eslint-disable import/no-unresolved */ import { common } from "../model/index.js" +import { Plugin_Name } from "../components/index.js" let Update = null try { Update = (await import("../../other/update.js").catch(e => null))?.update Update ||= (await import("../../system/apps/update.ts")).update } catch (e) { - logger.error("[yenai-plugin]未获取到更新js #椰奶更新 将无法使用") + logger.error(`[Yenai-Plugin]未获取到更新js ${logger.yellow("#椰奶更新")} 将无法使用`) } export class YenaiUpdate extends plugin { @@ -18,6 +19,10 @@ export class YenaiUpdate extends plugin { { reg: "^#*椰奶(插件)?(强制)?更新$", fnc: "update" + }, + { + reg: "^#?椰奶(插件)?更新日志$", + fnc: "update_log" } ] }) @@ -31,4 +36,16 @@ export class YenaiUpdate extends plugin { up.e = e return up.update() } + + async update_log() { + // eslint-disable-next-line new-cap + let Update_Plugin = new Update() + Update_Plugin.e = this.e + Update_Plugin.reply = this.reply + + if (Update_Plugin.getPlugin(Plugin_Name)) { + this.e.reply(await Update_Plugin.getLog(Plugin_Name)) + } + return true + } } diff --git a/apps/version.js b/apps/version.js index d8fc608..f0df436 100644 --- a/apps/version.js +++ b/apps/version.js @@ -1,13 +1,6 @@ -/* eslint-disable import/no-unresolved */ -import { Version, Plugin_Name } from "../components/index.js" +import { Version } from "../components/index.js" import { puppeteer } from "../model/index.js" -let update = null -try { - update = (await import("../../other/update.js").catch(e => null))?.update - update ||= (await import("../../system/apps/update.ts")).update -} catch (e) { - // logger.error("[yenai-plugin]未获取到更新js #椰奶更新 将无法使用") -} + export class NewVersion extends plugin { constructor() { super({ @@ -18,45 +11,20 @@ export class NewVersion extends plugin { { reg: "^#?椰奶(插件)?版本$", fnc: "plugin_version" - }, - { - reg: "^#?椰奶(插件)?更新日志$", - fnc: "update_log" } ] }) - this.key = "yenai:restart" } - async plugin_version() { - return versionInfo(this.e) - } - - async update_log() { - // eslint-disable-next-line new-cap - let Update_Plugin = new update() - Update_Plugin.e = this.e - Update_Plugin.reply = this.reply - - if (Update_Plugin.getPlugin(Plugin_Name)) { - this.e.reply(await Update_Plugin.getLog(Plugin_Name)) - } - return true + async plugin_version(e) { + return await puppeteer.render( + "help/version-info", + { + currentVersion: Version.ver, + changelogs: Version.logs, + elem: "cryo" + }, + { e, scale: 1.4 } + ) } } - -/** - * - * @param e - */ -async function versionInfo(e) { - return await puppeteer.render( - "help/version-info", - { - currentVersion: Version.ver, - changelogs: Version.logs, - elem: "cryo" - }, - { e, scale: 1.4 } - ) -} diff --git a/resources/state/js/style.js b/resources/state/js/style.js index ed9aca4..353898d 100644 --- a/resources/state/js/style.js +++ b/resources/state/js/style.js @@ -5,15 +5,17 @@ const { lowColor } = Config // 修改BotNameColor -const BotNameElement = document.querySelector(".header h1") -if (BotNameColorGradient && BotNameColorGradient !== "none") { - BotNameElement.style.backgroundImage = `linear-gradient(${BotNameColorGradient})` - BotNameElement.style.color = "transparent" - BotNameElement.style.backgroundClip = "text" -} else if (BotNameColor && BotNameColor !== "none") { - BotNameElement.style.color = BotNameColor - BotNameElement.style.backgroundImage = "none" -} +const botNameElements = document.querySelectorAll(".header h1") +botNameElements.forEach(BotNameElement => { + if (BotNameColorGradient && BotNameColorGradient !== "none") { + BotNameElement.style.backgroundImage = `linear-gradient(${BotNameColorGradient})` + BotNameElement.style.color = "transparent" + BotNameElement.style.backgroundClip = "text" + } else if (BotNameColor && BotNameColor !== "none") { + BotNameElement.style.color = BotNameColor + BotNameElement.style.backgroundImage = "none" + } +}) // 进度条颜色 const documentElement = document.documentElement documentElement.style.setProperty("--high-color", highColor)