feat(editor): service新增removePlugin方法

This commit is contained in:
roymondchen 2025-06-26 16:49:32 +08:00
parent b78ef20602
commit 8d6da3712e

View File

@ -199,24 +199,33 @@ export default class extends EventEmitter {
* @deprecated 使usePlugin代替
*/
public use(options: Record<string, Function>) {
Object.entries(options).forEach(([methodName, method]: [string, Function]) => {
for (const [methodName, method] of Object.entries(options)) {
if (typeof method === 'function') this.middleware[methodName].push(method);
});
}
}
public usePlugin(options: Record<string, Function>) {
Object.entries(options).forEach(([methodName, method]: [string, Function]) => {
for (const [methodName, method] of Object.entries(options)) {
if (typeof method === 'function') this.pluginOptionsList[methodName].push(method);
});
}
}
public removePlugin(options: Record<string, Function>) {
for (const [methodName, method] of Object.entries(options)) {
if (Array.isArray(this.pluginOptionsList[methodName])) {
this.pluginOptionsList[methodName] = this.pluginOptionsList[methodName].filter((item) => item !== method);
}
}
}
public removeAllPlugins() {
Object.keys(this.pluginOptionsList).forEach((key) => {
for (const key of Object.keys(this.pluginOptionsList)) {
this.pluginOptionsList[key] = [];
});
Object.keys(this.middleware).forEach((key) => {
}
for (const key of Object.keys(this.middleware)) {
this.middleware[key] = [];
});
}
}
private async doTask() {