feat: optimize framework
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
d3d7a9cdbf
commit
aab94fe5ea
@ -43,14 +43,14 @@ class MiaoScriptCore {
|
|||||||
console.i18n("ms.core.plugin.initialize")
|
console.i18n("ms.core.plugin.initialize")
|
||||||
this.pluginManager.scan(this.pluginFolder)
|
this.pluginManager.scan(this.pluginFolder)
|
||||||
this.pluginManager.build()
|
this.pluginManager.build()
|
||||||
this.pluginManager.load()
|
this.pluginManager.load(this.pluginManager.getPlugins())
|
||||||
this.pluginManager.enable()
|
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 })
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
console.i18n("ms.core.engine.disable")
|
console.i18n("ms.core.engine.disable")
|
||||||
this.pluginManager.disable()
|
this.pluginManager.disable(this.pluginManager.getPlugins())
|
||||||
this.taskManager.disable()
|
this.taskManager.disable()
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
require.disable()
|
require.disable()
|
||||||
|
@ -87,6 +87,7 @@ export class XMLHttpRequest {
|
|||||||
private _status: number = 0;
|
private _status: number = 0;
|
||||||
private _statusText: string = null;
|
private _statusText: string = null;
|
||||||
private _response: any;
|
private _response: any;
|
||||||
|
private _responseText: any;
|
||||||
private _responseURL: string;
|
private _responseURL: string;
|
||||||
private _responseHeaders: HttpHeader = {};
|
private _responseHeaders: HttpHeader = {};
|
||||||
|
|
||||||
@ -115,10 +116,10 @@ export class XMLHttpRequest {
|
|||||||
return this._statusText;
|
return this._statusText;
|
||||||
}
|
}
|
||||||
get response() {
|
get response() {
|
||||||
return this._response ? JSON.parse(this._response) : this._response;
|
return this._response || this.get();
|
||||||
}
|
}
|
||||||
get responseText() {
|
get responseText() {
|
||||||
return this._response;
|
return this._responseText;
|
||||||
}
|
}
|
||||||
get responseXML() {
|
get responseXML() {
|
||||||
return this._response;
|
return this._response;
|
||||||
@ -181,14 +182,17 @@ export class XMLHttpRequest {
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
get() {
|
get() {
|
||||||
switch (this._responseType) {
|
if (this._response === undefined) {
|
||||||
case "json":
|
switch (this._responseType) {
|
||||||
return this.response;
|
case "json":
|
||||||
case "text":
|
return this._response = JSON.parse(this._responseText);
|
||||||
return this.responseText;
|
case "text":
|
||||||
default:
|
return this._response = this._responseText;
|
||||||
throw Error(`Unsupport ResponseType: ${this._responseType} !`)
|
default:
|
||||||
|
throw Error(`Unsupport ResponseType: ${this._responseType} !`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return this._response;
|
||||||
}
|
}
|
||||||
abort() {
|
abort() {
|
||||||
this._connection.disconnect();
|
this._connection.disconnect();
|
||||||
@ -211,11 +215,11 @@ export class XMLHttpRequest {
|
|||||||
this._status = this._connection.getResponseCode();
|
this._status = this._connection.getResponseCode();
|
||||||
this._statusText = this._connection.getResponseMessage();
|
this._statusText = this._connection.getResponseMessage();
|
||||||
if (this._status >= 0 && this._status < 300) {
|
if (this._status >= 0 && this._status < 300) {
|
||||||
this._response = this.readOutput(this._connection.getInputStream());
|
this._responseText = this.readOutput(this._connection.getInputStream());
|
||||||
} else if (this._status >= 300 && this._status < 400) {
|
} else if (this._status >= 300 && this._status < 400) {
|
||||||
this._responseURL = this.getResponseHeader('Location');
|
this._responseURL = this.getResponseHeader('Location');
|
||||||
} else {
|
} else {
|
||||||
this._response = this.readOutput(this._connection.getErrorStream());
|
this._responseText = this.readOutput(this._connection.getErrorStream());
|
||||||
}
|
}
|
||||||
this.setResponseHeaders(this._connection.getHeaderFields());
|
this.setResponseHeaders(this._connection.getHeaderFields());
|
||||||
this.onloadend && this.onloadend();
|
this.onloadend && this.onloadend();
|
||||||
|
@ -123,7 +123,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private checkAndGet(name: string | interfaces.Plugin | undefined | any): Map<string, interfaces.Plugin> | interfaces.Plugin[] {
|
private checkAndGet(name: string | interfaces.Plugin | undefined | any): Map<string, interfaces.Plugin> | interfaces.Plugin[] {
|
||||||
if (name == undefined) { return this.pluginInstanceMap }
|
if (name == this.pluginInstanceMap) { return this.pluginInstanceMap }
|
||||||
if (typeof name == 'string' && this.pluginInstanceMap.has(name)) { return [this.pluginInstanceMap.get(name)] }
|
if (typeof name == 'string' && this.pluginInstanceMap.has(name)) { return [this.pluginInstanceMap.get(name)] }
|
||||||
if (name instanceof interfaces.Plugin) { return [name as interfaces.Plugin] }
|
if (name instanceof interfaces.Plugin) { return [name as interfaces.Plugin] }
|
||||||
if (name.description || name.description.name) { return [name as interfaces.Plugin] }
|
if (name.description || name.description.name) { return [name as interfaces.Plugin] }
|
||||||
|
Loading…
Reference in New Issue
Block a user