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