From b0264ef876680225724b137163bf6fac10fab53f Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Fri, 24 Jul 2020 15:23:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20chore:=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0inject.js=E4=B8=AD=E7=9A=84=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typescript/core/inject.ts | 47 +++++++++++++++++++++++++++++++++++++++ typescript/index.ts | 5 +++-- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 typescript/core/inject.ts diff --git a/typescript/core/inject.ts b/typescript/core/inject.ts new file mode 100644 index 000000000..29d77b328 --- /dev/null +++ b/typescript/core/inject.ts @@ -0,0 +1,47 @@ +type _module = (xtype: string, cls: any) => void; +type _constant = (xtype: string, cls: any) => void; +type _model = (xtype: string, cls: any) => void; +type _store = (xtype: string, cls: any) => void; +type _service = (xtype: string, cls: any) => void; +type _provider = (xtype: string, cls: any) => void; + +interface _modules { + getModule: (type: string) => any; + getAllModules: () => any; +} + +interface _constants { + getConstant: (type: string) => any; +} + +interface _models { + getModel: (type: string, options: any) => any; +} + +interface _stores { + getStore: (type: string, options: any) => any; +} + +interface _providers { + getProvider: (type: string, options: any) => any; +} + +interface _services { + getService: (type: string, options: any) => any; +} + + +export type _inject = { + module: _module; + constant: _constant; + model: _model; + store: _store; + provider: _provider; + service: _service; + Modules: _modules; + Constants: _constants; + Models: _models; + Stores: _stores; + Providers: _providers; + Services: _services; +} diff --git a/typescript/index.ts b/typescript/index.ts index a9243f40c..ed9f79215 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -36,6 +36,7 @@ import { _i18n } from "./core/i18n"; import { _Plugin } from "./core/plugin"; import { _OB } from "./core/ob"; import { _Widget, _WidgetStatic } from "./core/widget"; +import { _inject } from "./core/inject"; import { _Layout } from "./core/wrapper/layout"; import { _AbsoluteLayout } from "./core/wrapper/layout/layout.absolute"; import { _HTapeLayout, _VTapeLayout } from "./core/wrapper/layout/layout.tape"; @@ -49,9 +50,9 @@ type ClassConstructor = T & { readonly prototype: T; } -export interface BI extends _func, _i18n, _base { +export interface BI extends _func, _i18n, _base, _inject { OB: ClassConstructor<_OB>; - Plugin:_Plugin; + Plugin: _Plugin; Widget: ClassConstructor<_Widget> & _WidgetStatic; Single: ClassConstructor<_Single>; BasicButton: ClassConstructor<_BasicButton> & _BasicButtonStatic;