Skip to content

Commit

Permalink
fix: 初始化循环依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyJan committed Jun 25, 2024
1 parent 59aab11 commit 3ca16ee
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 74 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,23 @@ git -C ./plugins/Yunzai-Kuro-Plugin/ pull

### 插件配置

建议通过 [锅巴插件](https://gitee.com/guoba-yunzai/guoba-plugin) 进行配置. 当然, 你也可以自己配置, 配置文件位置 `./config/config.json`, 配置项作用不在此详细说明
建议通过 [锅巴插件](https://gitee.com/guoba-yunzai/guoba-plugin) 进行配置. 当然, 你也可以自己配置, 默认配置文件位置 `./data/system/default_config.json`, 配置文件位置 `./config/config.json`, 配置项作用:

```json
// 此处的 json 可能忘记更新, 如果和实际的配置文件字段不同, qing'ji'sh
{
"logger": { // 插件的日志器配置
"logLevel": "info", // 日志等级, 可选值: trace, debug, info, warn, error, fatal
"saveToFile": false // 是否保存日志到文件
},
"autoTask": { // 自动任务配置, 暂时只支持统一配置所有任务
"enabled": true, // 是否启用自动任务
"execTime": "0 2 0 * * ? " // 任务执行时间, cron 表达式, 默认每天 0 点 2 分 0 秒执行, 检查更新任务不受此配置影响
},
"attemptSendNonFriend": true, // 即使非好友也尝试推送消息
"botQQ": 0 // 机器人 QQ 号, 使用第三方适配器或者其他多账号框架时可能需要配置
}
```

## 功能介绍

Expand Down
3 changes: 2 additions & 1 deletion components/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chalk from 'chalk'
import fs from 'fs'
import { _CfgPath, _DataPath } from '../data/system/pluginConstants.js'
import kuroLogger from './logger.js'
Expand All @@ -23,7 +24,7 @@ class ConfigReader {
const configObject = JSON.parse(data)
return configObject
} catch (error) {
kuroLogger.error('读取配置文件失败:', error.message)
logger.error(chalk.red(`[库洛插件][WARN ] 读取配置文件失败: ${error.message}`))
return {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ logger.info(chalk.gray(`[库洛插件][LOGGER] Logger initialized!`))
while (typeof kuroLogger === 'undefined' || !(kuroLogger instanceof Logger)) {
// 类尚未初始化,可以加入适当的延时以避免阻塞主线程
// 例如:使用 setTimeout 或其他方式
sleepAsync(100)
await sleepAsync(100)
}
export default kuroLogger
159 changes: 88 additions & 71 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
"dependencies": {
"chalk": "^5.3.0",
"crypto": "^1.0.1",
"form-data": "^4.0.0"
},
Expand Down

0 comments on commit 3ca16ee

Please sign in to comment.