first commit

This commit is contained in:
编码猿
2024-09-27 01:25:59 +08:00
commit 546fffb620
78 changed files with 30293 additions and 0 deletions

View File

@@ -0,0 +1 @@
966472fa-a3be-4729-a71b-ae988035f1e7

View File

@@ -0,0 +1,18 @@
import OptionParamsModel from "../model/OptionParams.model";
import { ClassName } from "../config/ClassName.config";
export function Dom() {
return function (target: any, propertyName: string) {
setTimeout(()=> {
try {
target[propertyName] = OptionParamsModel.VideoDom.querySelector(`.${ClassName[propertyName]}`)
} catch (e) {
throw new Error(`错误信息:需要绑定事件的类名:${ClassName[propertyName]}不存在
1请检查类名是否存在
2删除 ui/*.ui.ts 代码中对应的 Dom() 装饰器 和 方法
`)
}
}
,300)
}
}

View File

@@ -0,0 +1,36 @@
import IocModel from "../model/Ioc.model";
/**
* 收集类依赖
* @constructor
*/
export function Injectable() {
return (_constructor: { new (...args: any[]): {}; }) => {
if(IocModel.classPool.indexOf(_constructor) !== -1) {
throw new Error('无需重复收集类');
} else {
//注册
IocModel.classPool = [_constructor]
}
}
}
/**
* 将类依赖实例化然后注入到被装饰的属性中
* @constructor
*/
export function Inject() {
return function (target: any, propertyName: string) {
/**
* 使用 reflect-metadata 提供的内置 类型元数据键 design:type 通过反射拿到被装饰属性的类型
* 也就是 类属性要实例化 的 service 类
*/
const propertyType: any = Reflect.getMetadata('design:type', target, propertyName);
if (IocModel.classPool.indexOf(propertyType) == -1) {
throw new Error('被装饰的属性所属的变量类型类,没有被装饰器@Injectable()注入,请检查!');
} else {
// 从存取器的数组中通过下标取出被装饰属性对应的service类然后实例化这个类在放入被装饰的属性中
target[propertyName] = new (IocModel.classPool[IocModel.classPool.indexOf(propertyType)])()
}
}
}