first commit
This commit is contained in:
1
dist/core/annotation/.pydio
vendored
Normal file
1
dist/core/annotation/.pydio
vendored
Normal file
@@ -0,0 +1 @@
|
||||
ec7ea387-e5ec-4847-8993-3681672646eb
|
||||
18
dist/core/annotation/Dom.annotation.js
vendored
Normal file
18
dist/core/annotation/Dom.annotation.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Dom = void 0;
|
||||
var OptionParams_model_1 = require("../model/OptionParams.model");
|
||||
var ClassName_config_1 = require("../config/ClassName.config");
|
||||
function Dom() {
|
||||
return function (target, propertyName) {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
target[propertyName] = OptionParams_model_1.default.VideoDom.querySelector("." + ClassName_config_1.ClassName[propertyName]);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("\u9519\u8BEF\u4FE1\u606F\uFF1A\u9700\u8981\u7ED1\u5B9A\u4E8B\u4EF6\u7684\u7C7B\u540D\uFF1A" + ClassName_config_1.ClassName[propertyName] + "\u4E0D\u5B58\u5728\n 1\uFF1A\u8BF7\u68C0\u67E5\u7C7B\u540D\u662F\u5426\u5B58\u5728\n 2\uFF1A\u5220\u9664 ui/*.ui.ts \u4EE3\u7801\u4E2D\u5BF9\u5E94\u7684 Dom() \u88C5\u9970\u5668 \u548C \u65B9\u6CD5\n ");
|
||||
}
|
||||
}, 300);
|
||||
};
|
||||
}
|
||||
exports.Dom = Dom;
|
||||
41
dist/core/annotation/Ioc.annotation.js
vendored
Normal file
41
dist/core/annotation/Ioc.annotation.js
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Inject = exports.Injectable = void 0;
|
||||
var Ioc_model_1 = require("../model/Ioc.model");
|
||||
/**
|
||||
* 收集类依赖
|
||||
* @constructor
|
||||
*/
|
||||
function Injectable() {
|
||||
return function (_constructor) {
|
||||
if (Ioc_model_1.default.classPool.indexOf(_constructor) !== -1) {
|
||||
throw new Error('无需重复收集类');
|
||||
}
|
||||
else {
|
||||
//注册
|
||||
Ioc_model_1.default.classPool = [_constructor];
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.Injectable = Injectable;
|
||||
/**
|
||||
* 将类依赖实例化然后注入到被装饰的属性中
|
||||
* @constructor
|
||||
*/
|
||||
function Inject() {
|
||||
return function (target, propertyName) {
|
||||
/**
|
||||
* 使用 reflect-metadata 提供的内置 类型元数据键 design:type 通过反射拿到被装饰属性的类型
|
||||
* 也就是 类属性要实例化 的 service 类
|
||||
*/
|
||||
var propertyType = Reflect.getMetadata('design:type', target, propertyName);
|
||||
if (Ioc_model_1.default.classPool.indexOf(propertyType) == -1) {
|
||||
throw new Error('被装饰的属性所属的变量类型类,没有被装饰器@Injectable()注入,请检查!');
|
||||
}
|
||||
else {
|
||||
// 从存取器的数组中通过下标取出被装饰属性对应的service类,然后实例化这个类,在放入被装饰的属性中
|
||||
target[propertyName] = new (Ioc_model_1.default.classPool[Ioc_model_1.default.classPool.indexOf(propertyType)])();
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.Inject = Inject;
|
||||
Reference in New Issue
Block a user