style(core): 统一代码风格并强化命名规范

This commit is contained in:
YHH
2025-10-31 18:33:31 +08:00
parent 3e037f4ae0
commit be7b3afb4a
3 changed files with 8 additions and 6 deletions

View File

@@ -172,7 +172,7 @@ export class ComponentStorage<T extends Component> {
*/
export class ComponentStorageManager {
private static readonly _logger = createLogger("ComponentStorage");
private storages = new Map<Function, ComponentStorage<Component> | SoAStorage<Component>>();
private storages = new Map<ComponentType, ComponentStorage<Component> | SoAStorage<Component>>();
/**
* 检查组件类型是否启用SoA存储

View File

@@ -102,7 +102,7 @@ export class ComponentRegistry {
* @param componentName 组件名称
* @returns 组件类型构造函数
*/
public static getComponentType(componentName: string): Function | null {
public static getComponentType(componentName: string): ComponentType | null {
return this.componentNameToType.get(componentName) || null;
}
@@ -110,7 +110,7 @@ export class ComponentRegistry {
* 获取所有已注册的组件类型
* @returns 组件类型映射
*/
public static getAllRegisteredTypes(): Map<Function, number> {
public static getAllRegisteredTypes(): Map<ComponentType, number> {
return new Map(this.componentTypes);
}
@@ -118,7 +118,7 @@ export class ComponentRegistry {
* 获取所有组件名称到类型的映射
* @returns 名称到类型的映射
*/
public static getAllComponentNames(): Map<string, Function> {
public static getAllComponentNames(): Map<string, ComponentType> {
return new Map(this.componentNameToType);
}

View File

@@ -1,13 +1,15 @@
type EventHandler = (...args: unknown[]) => void;
/**
* 用于包装事件的一个小类
*/
export class FuncPack<TContext = unknown> {
/** 函数 */
public func: Function;
public func: EventHandler;
/** 上下文 */
public context: TContext;
constructor(func: Function, context: TContext) {
constructor(func: EventHandler, context: TContext) {
this.func = func;
this.context = context;
}