-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (37 loc) · 1.52 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import fs from 'fs'
logger.info(logger.magenta('-------AFanSKyQs-----------'))
logger.info(logger.magenta(`----[Honkai-StarRail]插件初始化中------`))
const files = fs.readdirSync('./plugins/Honkai-StarRail/apps').filter(file => file.endsWith('.js'))
let ret = []
files.forEach((file) => {
ret.push(import(`./apps/${file}`))
})
ret = await Promise.allSettled(ret)
let apps = {}
let APackageFanError = 0
for (let i in files) {
let name = files[i].replace('.js', '')
if (ret[i].status !== 'fulfilled') {
logger.error(`载入插件错误:${logger.red(name)}`)
const ARegexFan = /Cannot find package '([^']+)'/;
let AFanReaSon = ret[i].reason+""
const AMatchFan = AFanReaSon.match(ARegexFan);
if (AMatchFan) {
const APackageNameY = AMatchFan[1];
logger.warn(`请运行:${logger.red(`pnpm add ${APackageNameY} -w`)}安装依赖`)
APackageFanError++
}else{
logger.error(ret[i].reason)
}
delete apps[name];
continue
}
apps[name] = ret[i].value[Object.keys(ret[i].value)[0]]
}
logger.info(logger.magenta(`----Honkai-StarRail插件载入完成------`))
if(APackageFanError>0){
logger.warn(logger.yellow(`---报错请按提示安装依赖,否则对应功能会无效喵!------`))
logger.warn(logger.yellow(`---报错请按提示安装依赖,否则对应功能会无效喵!------`))
logger.warn(logger.yellow(`---报错请按提示安装依赖,否则对应功能会无效喵!------`))
}
export {apps}