diff --git a/apps/admin.js b/apps/admin.js
index 9fe7318..a55af1f 100644
--- a/apps/admin.js
+++ b/apps/admin.js
@@ -1,6 +1,6 @@
import plugin from '../../../lib/plugins/plugin.js'
import { update } from '../../other/update.js'
-import { Version, Common, Plugin_Name } from '../components/index.js'
+import { Version, render, Plugin_Name } from '../components/index.js'
export class admin extends plugin {
constructor() {
@@ -40,7 +40,7 @@ export class admin extends plugin {
async function versionInfo(e) {
- return await Common.render('help/version-info', {
+ return await render('help/version-info', {
currentVersion: Version.ver,
changelogs: Version.logs,
elem: 'cryo'
diff --git a/apps/help.js b/apps/help.js
index 7096b69..977ffe1 100644
--- a/apps/help.js
+++ b/apps/help.js
@@ -1,7 +1,7 @@
import plugin from '../../../lib/plugins/plugin.js'
import fs from 'fs'
import lodash from 'lodash'
-import { Common, Data } from '../components/index.js'
+import { render, Data } from '../components/index.js'
export class yenai_help extends plugin {
constructor() {
@@ -60,7 +60,7 @@ async function help(e) {
})
let bg = await rodom()
let colCount = 3;
- return await Common.render('help/index', {
+ return await render('help/index', {
helpCfg: helpConfig,
helpGroup,
bg,
diff --git a/apps/set.js b/apps/set.js
index a4415ee..b0d2d94 100644
--- a/apps/set.js
+++ b/apps/set.js
@@ -1,8 +1,7 @@
import plugin from '../../../lib/plugins/plugin.js'
import fs from "fs";
import lodash from "lodash";
-import Common from "../components/Common.js";
-import { Config } from '../components/index.js'
+import { Config, render } from '../components/index.js'
let rediskey = `yenai:proxy`
export class NewConfig extends plugin {
@@ -145,7 +144,7 @@ export class NewConfig extends plugin {
bg: await rodom(), //获取底图
}
//渲染图像
- return await Common.render("admin/index", {
+ return await render("admin/index", {
...cfg,
}, {
e,
diff --git a/apps/state.js b/apps/state.js
index 8fd5474..776cf90 100644
--- a/apps/state.js
+++ b/apps/state.js
@@ -1,10 +1,9 @@
import plugin from '../../../lib/plugins/plugin.js'
import os from 'os';
-import { Version, Common, Config } from '../components/index.js'
+import { Version, render, Config } from '../components/index.js'
import CPU from '../model/CPU.js';
import Cfg from '../model/Config.js';
import fs from 'fs'
-import fetch from 'node-fetch';
import moment from 'moment';
export class example extends plugin {
constructor() {
@@ -136,7 +135,7 @@ export class example extends plugin {
takejs: fs.readdirSync("./plugins/example")?.length || 0
}
//渲染图片
- await Common.render('state/state', {
+ await render('state/state', {
...data,
}, {
e,
diff --git a/components/Cfg.js b/components/Cfg.js
deleted file mode 100644
index 4b2e50e..0000000
--- a/components/Cfg.js
+++ /dev/null
@@ -1,45 +0,0 @@
-import fs from 'fs'
-import lodash from 'lodash'
-
-const _path = process.cwd()
-const _cfgPath = `${_path}/plugins/yenai-plugin/components/`
-let cfg = {}
-
-try {
- if (fs.existsSync(_cfgPath + 'cfg.json')) {
- cfg = JSON.parse(fs.readFileSync(_cfgPath + 'cfg.json', 'utf8')) || {}
- }
-} catch (e) {
- // do nth
-}
-
-let Cfg = {
- get(rote, def = '') {
- return lodash.get(cfg, rote, def)
- },
- set(rote, val) {
- lodash.set(cfg, rote, val)
- fs.writeFileSync(_cfgPath + 'cfg.json', JSON.stringify(cfg, null, '\t'))
- },
- del(rote) {
- lodash.set(cfg, rote, undefined)
- fs.writeFileSync(_cfgPath + 'cfg.json', JSON.stringify(cfg, null, '\t'))
- },
- scale(pct = 1) {
- let scale = Cfg.get('sys.scale', 100)
- scale = Math.min(2, Math.max(0.5, scale / 100))
- pct = pct * scale
- return `style=transform:scale(${pct})`
- },
- isDisable(e, rote) {
- if (Cfg.get(rote, true)) {
- return false
- }
- if (/^#*小飞/.test(e.msg || '')) {
- return false
- }
- return true
- }
-}
-
-export default Cfg
diff --git a/components/Common.js b/components/Common.js
deleted file mode 100644
index 23ce2b0..0000000
--- a/components/Common.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import Cfg from './Cfg.js'
-import render from './common-lib/render.js'
-
-function sleep (ms) {
- return new Promise((resolve) => setTimeout(resolve, ms))
-}
-
-export default {
- render,
- cfg: Cfg.get,
- isDisable: Cfg.isDisable,
- sleep
-}
diff --git a/components/cfg.json b/components/cfg.json
deleted file mode 100644
index e9aae3e..0000000
--- a/components/cfg.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "sys": {
- "help": true,
- "scale": 100
- },
- "char": {
- "wife": false,
- "char": true
- },
- "wiki": {
- "abyss": true,
- "wiki": false,
- "stat": true
- }
-}
\ No newline at end of file
diff --git a/components/index.js b/components/index.js
index 7a797f1..8df8951 100644
--- a/components/index.js
+++ b/components/index.js
@@ -3,8 +3,6 @@ const Plugin_Name = 'yenai-plugin'
const Plugin_Path = `${Path}/plugins/${Plugin_Name}`;
import Version from './Version.js'
import Data from './Data.js'
-import Cfg from './Cfg.js'
-import Common from './Common.js'
import Config from './Config.js'
-
-export { Cfg, Common, Config, Data, Version, Path, Plugin_Name, Plugin_Path }
\ No newline at end of file
+import render from './render.js';
+export { render, Config, Data, Version, Path, Plugin_Name, Plugin_Path }
\ No newline at end of file
diff --git a/components/common-lib/render.js b/components/render.js
similarity index 90%
rename from components/common-lib/render.js
rename to components/render.js
index f38ae8f..ed7428c 100644
--- a/components/common-lib/render.js
+++ b/components/render.js
@@ -1,7 +1,6 @@
-import { Data, Version, Plugin_Name } from '../index.js'
-import Cfg from '../Cfg.js'
+import { Data, Version, Plugin_Name } from './index.js'
import fs from 'fs'
-import puppeteer from '../../../../lib/puppeteer/puppeteer.js'
+import puppeteer from '../../../lib/puppeteer/puppeteer.js'
const _path = process.cwd()
@@ -26,7 +25,7 @@ export default async function (path, params, cfg) {
waitUntil: 'networkidle0'
},
sys: {
- scale: Cfg.scale(cfg.scale || 1),
+ scale: `style=transform:scale(${cfg.scale || 1})`,
copyright: `Created By Yunzai-Bot${Version.yunzai} & yenai-Plugin${Version.ver}`
},
quality: 100