From 8e4dd67cf53faf79b2ce04a3547b7159fd786029 Mon Sep 17 00:00:00 2001 From: iapyang Date: Thu, 12 Sep 2019 15:48:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=BB=E6=8E=89=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typescript/index.ts | 70 --------------------------------------------- 1 file changed, 70 deletions(-) diff --git a/typescript/index.ts b/typescript/index.ts index 855c9a4080..8cb79dc3b5 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -33,73 +33,3 @@ export interface _BI extends _func, _i18n, _base { HighlightBehavior: ClassConstructor<_HighlightBehavior>; RedMarkBehavior: ClassConstructor<_RedMarkBehavior>; } - -interface Obj { - [key: string]: any; -} - -declare let BI: Obj & _BI; - -declare const Fix: Obj; - -export type Constructor = new(...args: any[]) => T; - -/** - * 注册widget - */ -export function shortcut () { - return function decorator (Target: Constructor & {xtype: string}): void { - BI.shortcut(Target.xtype, Target); - }; -} - -/** - * 注册model - */ -export function model () { - return function decorator}>(Target: U): void { - BI.model(Target.xtype, class extends Target { - context = Target.context; - }); - }; -} - -/** - * 类注册_store属性 - * @param Model model类 - * @param opts 额外条件 - */ -export function store (Model?: Constructor & {xtype: string}, opts: { props?(this: unknown): { [key: string]: unknown } } = {}) { - return function classDecorator(constructor:U) { - return class extends constructor { - _store () { - const props = opts.props ? opts.props.apply(this) : undefined; - - return BI.Models.getModel(Model.xtype, props); - } - }; - }; -} - -/** - * Model基类 - */ -export class Model} = {}> extends Fix.Model { - model: Pick<{[key in keyof U["types"]]: U["types"][key]}, U["context"][number]> & {[key in keyof ReturnType]: ReturnType[key]} & {[key in keyof this["computed"]]: ReturnType} & {[key: string]: unknown}; - - store: this["actions"]; - - state (): {[key: string]: any} { - return {}; - } - - context: U["context"]; - - actions:{[key: string]: (...args: any[]) => any}; - - childContext: ReadonlyArray)>; - - TYPE: Pick<{[key in keyof this["computed"]]: ReturnType} & {[key in keyof ReturnType]: ReturnType[key]}, this["childContext"][number]>; - - computed: {[key: string]: () => any}; -}