fix: 兼容node多个版本的fs方法

This commit is contained in:
ningmengchongshui 2024-06-15 00:08:52 +08:00
parent 413f8ef887
commit 3fd2bfdde7
2 changed files with 11 additions and 1 deletions

View File

@ -22,7 +22,12 @@ const flies = readdirSync(join(process.cwd(), 'plugins'), {
// 解析路由
for (const flie of flies) {
const plugins = readdirSync(join(flie.path, flie.name), {
const dir = flie?.path ?? flie?.parentPath
if (!dir) {
console.log('flie.name', flie.name, '识别错误')
continue
}
const plugins = readdirSync(join(dir, flie.name), {
withFileTypes: true
}).filter(flie => flie.isFile())
for (const plugin of plugins) {

View File

@ -306,12 +306,16 @@ class PluginsLoader {
*/
await Runtime.init(e)
/**
*
*/
const priority = []
/**
*
*/
for (const i of this.priority) {
// tudo e 为参数将废弃
const p = new i.class(e)
p.e = e
/**
@ -373,6 +377,7 @@ class PluginsLoader {
*/
for (const plugin of priority) {
if (!plugin.accept) continue
// e 引入将丢失
const res = await plugin.accept(e)
// 结束所有
if (res == 'return') return