feat: inject config folder
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
c2a71b9a7a
commit
950575edbc
@ -1,20 +1,22 @@
|
||||
import { Container } from "@ms/container";
|
||||
|
||||
export namespace plugin {
|
||||
/**
|
||||
* MiaoScript Plugin
|
||||
*/
|
||||
export const Plugin = Symbol("Plugin");
|
||||
/**
|
||||
* MiaoScript Plugin
|
||||
*/
|
||||
export const PluginFolder = Symbol("PluginFolder");
|
||||
/**
|
||||
* Runtime Plugin Instance
|
||||
*/
|
||||
export const PluginInstance = Symbol("PluginInstance");
|
||||
/**
|
||||
* MiaoScript Plugin Manager
|
||||
* MiaoScript Plugin Manager Symbol
|
||||
*/
|
||||
export const PluginManager = Symbol("PluginManager");
|
||||
/**
|
||||
* MiaoScript Plugin Manager
|
||||
* MiaoScript Plugin Manager Interface
|
||||
*/
|
||||
export interface PluginManager {
|
||||
scan(folder: string): void;
|
||||
|
@ -12,6 +12,8 @@ class MiaoScriptCore {
|
||||
private Console: Console;
|
||||
@inject(task.TaskManager)
|
||||
private taskManager: task.TaskManager;
|
||||
@inject(plugin.PluginFolder)
|
||||
private pluginFolder: string;
|
||||
@inject(plugin.PluginManager)
|
||||
private pluginManager: plugin.PluginManager;
|
||||
|
||||
@ -38,7 +40,7 @@ class MiaoScriptCore {
|
||||
loadPlugins() {
|
||||
let loadPluginStartTime = new Date().getTime()
|
||||
console.log(`Initialization MiaoScript Plugin System. Please wait...`)
|
||||
this.pluginManager.scan('plugins');
|
||||
this.pluginManager.scan(this.pluginFolder);
|
||||
this.pluginManager.build();
|
||||
this.pluginManager.load();
|
||||
this.pluginManager.enable();
|
||||
@ -78,6 +80,7 @@ function initialize() {
|
||||
let corePackageStartTime = new Date().getTime()
|
||||
container.bind(ContainerInstance).toConstantValue(container);
|
||||
container.bind(plugin.PluginInstance).toConstantValue(base.getInstance());
|
||||
container.bind(plugin.PluginFolder).toConstantValue('plugins');
|
||||
let type = detectServer();
|
||||
console.info(`Detect Compatible Server set ServerType to ${type} ...`)
|
||||
container.bind(server.ServerType).toConstantValue(type);
|
||||
|
Loading…
Reference in New Issue
Block a user