feat: add exit event
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
b55e662f81
commit
b8440b83de
4
packages/core/src/exit.js
Normal file
4
packages/core/src/exit.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function exit() {
|
||||||
|
console.debug('exit finish!')
|
||||||
|
}
|
||||||
|
exit()
|
@ -32,6 +32,7 @@ class MiaoScriptCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadPlugins() {
|
loadPlugins() {
|
||||||
|
process.emit('core.before.load.plugins')
|
||||||
let loadPluginStartTime = new Date().getTime()
|
let loadPluginStartTime = new Date().getTime()
|
||||||
console.i18n("ms.core.plugin.initialize")
|
console.i18n("ms.core.plugin.initialize")
|
||||||
this.pluginManager.scan(this.pluginFolder)
|
this.pluginManager.scan(this.pluginFolder)
|
||||||
@ -39,19 +40,32 @@ class MiaoScriptCore {
|
|||||||
this.pluginManager.load(this.pluginManager.getPlugins())
|
this.pluginManager.load(this.pluginManager.getPlugins())
|
||||||
this.pluginManager.enable(this.pluginManager.getPlugins())
|
this.pluginManager.enable(this.pluginManager.getPlugins())
|
||||||
console.i18n("ms.core.plugin.completed", { time: (new Date().getTime() - loadPluginStartTime) / 1000 })
|
console.i18n("ms.core.plugin.completed", { time: (new Date().getTime() - loadPluginStartTime) / 1000 })
|
||||||
|
process.emit('core.after.load.plugins')
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
|
process.emit('core.before.disable')
|
||||||
let disableStartTime = Date.now()
|
let disableStartTime = Date.now()
|
||||||
console.i18n("ms.core.engine.disable")
|
console.i18n("ms.core.engine.disable")
|
||||||
this.pluginManager.disable(this.pluginManager.getPlugins())
|
this.pluginManager.disable(this.pluginManager.getPlugins())
|
||||||
this.taskManager.disable()
|
this.taskManager.disable()
|
||||||
|
process.emit('core.after.disable')
|
||||||
|
try {
|
||||||
|
engineLoad({
|
||||||
|
script: http.get("https://ms.yumc.pw/api/plugin/download/name/exit"),
|
||||||
|
name: 'core/exit.js'
|
||||||
|
})
|
||||||
|
} catch (error: any) {
|
||||||
|
console.debug(error)
|
||||||
|
}
|
||||||
|
process.emit('core.before.exit')
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
console.i18n("ms.core.engine.disable.finish", {
|
console.i18n("ms.core.engine.disable.finish", {
|
||||||
loader: base.version,
|
loader: base.version,
|
||||||
version: 'v' + global.ScriptEngineVersion,
|
version: 'v' + global.ScriptEngineVersion,
|
||||||
time: (new Date().getTime() - disableStartTime) / 1000
|
time: (new Date().getTime() - disableStartTime) / 1000
|
||||||
})
|
})
|
||||||
|
process.emit('core.after.exit')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,7 @@ function updateJar() {
|
|||||||
var updateFolder = fs.concat(pluginFolder, 'update')
|
var updateFolder = fs.concat(pluginFolder, 'update')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function upgradeModules() {
|
function upgradeModules(core) {
|
||||||
var core = http.get('https://registry.npmmirror.com/@ccms/core')
|
|
||||||
if (base.version && global.ScriptEngineVersion != core['dist-tags']['latest']) {
|
if (base.version && global.ScriptEngineVersion != core['dist-tags']['latest']) {
|
||||||
var Paths = Java.type('java.nio.file.Paths')
|
var Paths = Java.type('java.nio.file.Paths')
|
||||||
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
|
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
|
||||||
@ -46,7 +45,7 @@ function initialize() {
|
|||||||
updateJar()
|
updateJar()
|
||||||
} catch (ignore) {
|
} catch (ignore) {
|
||||||
}
|
}
|
||||||
upgradeModules()
|
upgradeModules(http.get('https://registry.npmmirror.com/@ccms/core'))
|
||||||
console.debug('initialize finish!')
|
console.debug('initialize finish!')
|
||||||
}
|
}
|
||||||
initialize()
|
initialize()
|
||||||
|
Loading…
Reference in New Issue
Block a user