From b37e6de2d23d70b8e28844bc9bbb6e4480c4874f Mon Sep 17 00:00:00 2001 From: yeyang <746659424@qq.com> Date: Wed, 15 May 2024 19:03:06 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E7=BB=86=E8=8A=82?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/state.js | 12 +++--------- model/State/index.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/state.js b/apps/state.js index 7b32dd3..64f8664 100644 --- a/apps/state.js +++ b/apps/state.js @@ -1,8 +1,5 @@ -import plugin from "../../../lib/plugins/plugin.js" import { Config } from "../components/index.js" -import Monitor from "../model/State/Monitor.js" -import { getBackground } from "../model/State/style.js" -import { getData, getChartCfg } from "../model/State/index.js" +import { getMonitorData, getData } from "../model/State/index.js" import { si } from "../model/State/utils.js" import { puppeteer } from "../model/index.js" @@ -33,11 +30,8 @@ export class NewState extends plugin { } async monitor(e) { - await puppeteer.render("state/monitor", { - chartData: JSON.stringify(Monitor.chartData), - backdrop: await getBackground(), - chartCfg: JSON.stringify(getChartCfg()) - }, { + const data = await getMonitorData() + await puppeteer.render("state/monitor", data, { e, scale: 1.4 }) diff --git a/model/State/index.js b/model/State/index.js index 12b7c44..9b8c155 100644 --- a/model/State/index.js +++ b/model/State/index.js @@ -13,7 +13,7 @@ import getNode from "./NodeInfo.js" import getOtherInfo, { getCopyright } from "./OtherInfo.js" import getRAM from "./RAM.js" import getSWAP from "./SWAP.js" -import getStyle from "./style.js" +import getStyle, { getBackground } from "./style.js" export async function getData(e) { e.isPro = e.msg.includes("pro") @@ -68,7 +68,16 @@ export async function getData(e) { chartCfg: JSON.stringify(getChartCfg()) } } -export function getChartCfg() { + +export async function getMonitorData() { + return { + chartData: JSON.stringify(Monitor.chartData), + backdrop: await getBackground(), + chartCfg: JSON.stringify(getChartCfg()) + } +} + +function getChartCfg() { const echarts_theme = Data.readJSON("resources/state/theme_westeros.json") return {