diff --git a/image/main.ts b/image/main.ts index e7b7945..98e7052 100644 --- a/image/main.ts +++ b/image/main.ts @@ -1,10 +1,14 @@ +import '../src/init/modules.js' +import '../src/init/logger.js' +import '../src/init/config.js' +import '../src/init/redis.js' +import './tailwindcss.js' import Koa from 'koa' import KoaStatic from 'koa-static' import Router from 'koa-router' import { Component } from 'yunzai/utils' import { readdirSync } from 'fs' import { join } from 'path' -import './tailwindcss.js' const Com = new Component() const app = new Koa() diff --git a/src/init.ts b/src/init.ts index b42a0a2..a6e0f61 100644 --- a/src/init.ts +++ b/src/init.ts @@ -1,42 +1,28 @@ import './init/modules.js' import './init/logger.js' +import './init/config.js' +import './init/redis.js' import { promises } from 'node:fs' import yaml from 'yaml' -import { configInit } from './config/config' import { BOT_NAME } from './config' -import { redisInit } from './config/redis' import { CONFIG_INIT_PATH } from './config/system.js' import { checkRun } from './config/check.js' /** * */ logger.mark(`${BOT_NAME} 启动中...`) - -/** - * 初始化配置 - */ -configInit() - -/** - * 初始化客户端 - */ -await redisInit() - /** * 设置标题 */ process.title = BOT_NAME - /** * 设置时区 */ process.env.TZ = 'Asia/Shanghai' - /** * */ process.on('SIGHUP', () => process.exit()) - /** * 捕获未处理的错误 */ @@ -44,7 +30,6 @@ process.on('uncaughtException', error => { if (typeof logger == 'undefined') console.log(error) else logger.error(error) }) - /** * 捕获未处理的Promise错误 */ @@ -52,7 +37,6 @@ process.on('unhandledRejection', error => { if (typeof logger == 'undefined') console.log(error) else logger.error(error) }) - /** * 退出事件 */ @@ -66,18 +50,15 @@ process.on('exit', async () => { logger.mark(logger.magenta(`${BOT_NAME} 已停止运行`)) } }) - /** * 添加一些多余的标题内容 */ let title = BOT_NAME - // const qq = await promises .readFile(`./${CONFIG_INIT_PATH}qq.yaml`, 'utf-8') .then(yaml.parse) .catch(() => null) - /** * */ @@ -113,12 +94,10 @@ if (qq) { } } } - /** * 设置标题 */ process.title = title - /** * 检查程序 */ diff --git a/src/init/config.ts b/src/init/config.ts new file mode 100644 index 0000000..8763917 --- /dev/null +++ b/src/init/config.ts @@ -0,0 +1,2 @@ +import { configInit } from '../config/config.js' +configInit() diff --git a/src/init/redis.ts b/src/init/redis.ts new file mode 100644 index 0000000..6794d16 --- /dev/null +++ b/src/init/redis.ts @@ -0,0 +1,2 @@ +import { redisInit } from '../config/redis' +await redisInit()