-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
57 lines (45 loc) · 1.62 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import fs from 'node:fs'
import kuroLogger from './components/logger.js'
import {
appsPath,
pluginVer,
pluginThemeColor,
} from './data/system/pluginConstants.js'
import {
initAutoTask,
checkUpdateTask,
gameEnergyPushTask,
} from './model/autoTask.js'
await kuroLogger.info(pluginThemeColor('============(≧∇≦)ノ============'))
await kuroLogger.info(pluginThemeColor(`库洛插件 V${pluginVer} 开始载入~`))
await kuroLogger.info(pluginThemeColor('-----------载入模块-----------'))
const files = fs.readdirSync(appsPath).filter((file) => file.endsWith('.js'))
let ret = []
files.forEach((file) => {
ret.push(import(`./apps/${file}`))
})
ret = await Promise.allSettled(ret)
let apps = {}
for (let i in files) {
let name = files[i].replace('.js', '')
if (ret[i].status !== 'fulfilled') {
await kuroLogger.error(`载入模块错误:${name}: ${ret[i].reason}`)
continue
} else {
await kuroLogger.info(pluginThemeColor(`载入模块成功:${name}`))
}
apps[name] = ret[i].value[Object.keys(ret[i].value)[0]]
}
await kuroLogger.info(pluginThemeColor('载入模块完成!'))
export { apps }
await kuroLogger.info(pluginThemeColor('---------载入定时任务---------'))
await initAutoTask()
await kuroLogger.info(pluginThemeColor('载入定时任务完成啦!'))
await kuroLogger.info(pluginThemeColor('插件载入完成, 欢迎使用~'))
await kuroLogger.info(pluginThemeColor('=============================='))
// 起洞就检查一下更新, 推一下体力
// 延迟5s再开始以防止第三方适配器没连接上
setTimeout(() => {
checkUpdateTask()
gameEnergyPushTask(3600)
}, 5000)