From 6005a7cd975214f211c8d449d5d5b3d260bdd29d Mon Sep 17 00:00:00 2001 From: ningmengchongshui <916415899@qq.com> Date: Tue, 18 Jun 2024 23:56:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A1=AE=E4=BF=9Dmessage=E7=9A=84?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/plugins/functional.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/core/plugins/functional.ts b/src/core/plugins/functional.ts index 79e1dd5..8330476 100644 --- a/src/core/plugins/functional.ts +++ b/src/core/plugins/functional.ts @@ -26,7 +26,6 @@ export class Messages { reg: RegExp fnc: string }[] = [] - #init = PluginSuperDefine /** @@ -62,14 +61,21 @@ export class Messages { const App = this class Children extends Plugin { constructor() { - super({ + // init + super() + // 丢给this + const init = { ...App.#init, rule: App.#rule - }) + } + for (const key in init) { + this[key] = init[key] + } for (const key of App.#rule) { // 确认存在该函数 if (App[key.fnc] instanceof Function) { - this[key.fnc] = App[key.fnc].bind(App) + // 改变this指向 确保未来废除 fun(e) 后可用 + this[key.fnc] = () => App[key.fnc].call(this, this.e); } } } @@ -82,14 +88,7 @@ export class Messages { * 事件 */ export class Events { - /** - * - */ #count = 0 - - /** - * - */ #data: { [key: string]: typeof Plugin } = {} @@ -109,4 +108,4 @@ export class Events { get ok() { return this.#data } -} +} \ No newline at end of file