|
|
@ -44,6 +44,45 @@ export function store<T>(Model: Constructor<T> & {xtype: string}, opts: { props? |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 注册mixin |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
export function mixin<T>() { |
|
|
|
|
|
|
|
return function decorator(Target: Constructor<T> & { xtype: string }): void { |
|
|
|
|
|
|
|
const mixin: { |
|
|
|
|
|
|
|
[key: string]: Function; |
|
|
|
|
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.getOwnPropertyNames(Target.prototype).forEach(name => { |
|
|
|
|
|
|
|
if (name === 'constructor') { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mixin[name] = Target.prototype[name]; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fix.mixin(Target.xtype, mixin); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 类注册mixins属性 |
|
|
|
|
|
|
|
* @param Mixins |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
export function mixins(...Mixins: ({ new (...args: any[]): {} } & { xtype: string })[]) { |
|
|
|
|
|
|
|
return function classDecorator<U extends { new (...args: any[]): {} }>(constructor: U) { |
|
|
|
|
|
|
|
const mixins: string[] = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mixins.forEach(mixin => { |
|
|
|
|
|
|
|
mixin.xtype && mixins.push(mixin.xtype); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return class extends constructor { |
|
|
|
|
|
|
|
mixins = mixins; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Model基类 |
|
|
|
* Model基类 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|